diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ComplaintResponseRepository.java b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ComplaintResponseRepository.java index 5287960c823a..d71043776e85 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ComplaintResponseRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ComplaintResponseRepository.java @@ -3,7 +3,6 @@ import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; import java.util.List; -import java.util.Optional; import java.util.Set; import org.springframework.context.annotation.Profile; @@ -25,8 +24,6 @@ @Repository public interface ComplaintResponseRepository extends ArtemisJpaRepository { - Optional findByComplaint_Id(Long complaintId); - /** * This magic method counts the number of complaints responses by complaint type associated to a course id * diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ExampleSubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ExampleSubmissionRepository.java index c3d85e893be8..d8576296b757 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ExampleSubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ExampleSubmissionRepository.java @@ -52,8 +52,6 @@ public interface ExampleSubmissionRepository extends ArtemisJpaRepository findByIdWithResultsAndFeedback(@Param("exampleSubmissionId") long exampleSubmissionId); - Optional findBySubmissionId(long submissionId); - @EntityGraph(type = LOAD, attributePaths = { "submission", "submission.results" }) Optional findWithResultsBySubmissionId(long submissionId); diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java index e873f468b0ae..87c381b777d9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java @@ -147,23 +147,6 @@ default Optional findFirstWithSubmissionAndFeedbacksAndTestCasesByPartic @EntityGraph(type = LOAD, attributePaths = "submission") Optional findResultWithSubmissionsById(long resultId); - /** - * Finds the first result by participation ID, including its submissions, ordered by completion date in descending order. - * This method avoids in-memory paging by retrieving the first result directly from the database. - * - * @param participationId the ID of the participation to find the result for - * @return an {@code Optional} containing the first {@code Result} with submissions, ordered by completion date in descending order, - * or an empty {@code Optional} if no result is found - */ - default Optional findFirstWithSubmissionsByParticipationIdOrderByCompletionDateDesc(long participationId) { - var resultOptional = findFirstByParticipationIdOrderByCompletionDateDesc(participationId); - if (resultOptional.isEmpty()) { - return Optional.empty(); - } - var id = resultOptional.get().getId(); - return findResultWithSubmissionsById(id); - } - Optional findFirstByParticipationIdAndRatedOrderByCompletionDateDesc(long participationId, boolean rated); /** @@ -184,11 +167,6 @@ default Optional findFirstByParticipationIdAndRatedWithSubmissionOrderBy return findResultWithSubmissionsById(id); } - Optional findDistinctBySubmissionId(long submissionId); - - @EntityGraph(type = LOAD, attributePaths = "feedbacks") - Optional findDistinctWithFeedbackBySubmissionId(long submissionId); - @Query(""" SELECT r FROM Result r @@ -208,8 +186,6 @@ default Optional findFirstByParticipationIdAndRatedWithSubmissionOrderBy """) Optional findByIdWithEagerFeedbacksAndAssessor(@Param("resultId") long resultId); - Set findAllByParticipationExerciseId(long exerciseId); - /** * Load a result from the database by its id together with the associated submission, the list of feedback items, its assessor and assessment note. * @@ -352,9 +328,6 @@ SELECT COUNT(r.id) """) List countNumberOfFinishedAssessmentsByExamIdIgnoreTestRuns(@Param("examId") long examId); - @EntityGraph(type = LOAD, attributePaths = { "feedbacks" }) - Set findAllWithEagerFeedbackByAssessorIsNotNullAndParticipation_ExerciseIdAndCompletionDateIsNotNull(long exerciseId); - @Query(""" SELECT COUNT(DISTINCT p) FROM Participation p @@ -802,10 +775,6 @@ default Optional findLatestResultWithFeedbacksForParticipation(long part } } - default Result findFirstWithFeedbacksByParticipationIdOrderByCompletionDateDescElseThrow(long participationId) { - return getValueElseThrow(findFirstWithFeedbacksTestCasesByParticipationIdOrderByCompletionDateDesc(participationId)); - } - default Result findWithBidirectionalSubmissionAndFeedbackAndAssessorAndAssessmentNoteAndTeamStudentsByIdElseThrow(long resultId) { return getValueElseThrow(findWithBidirectionalSubmissionAndFeedbackAndAssessorAndAssessmentNoteAndTeamStudentsById(resultId), resultId); } diff --git a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/TutorParticipationRepository.java b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/TutorParticipationRepository.java index dad67442f9ae..63312e01f52f 100644 --- a/src/main/java/de/tum/cit/aet/artemis/assessment/repository/TutorParticipationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/assessment/repository/TutorParticipationRepository.java @@ -12,7 +12,6 @@ import org.springframework.transaction.annotation.Transactional; import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; -import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; import de.tum.cit.aet.artemis.exercise.domain.Exercise; @@ -24,8 +23,6 @@ @Repository public interface TutorParticipationRepository extends ArtemisJpaRepository { - List findByAssessedExercise(Exercise assessedExercise); - @EntityGraph(type = LOAD, attributePaths = { "trainedExampleSubmissions", "trainedExampleSubmissions.submission.results" }) TutorParticipation findWithEagerExampleSubmissionAndResultsByAssessedExerciseAndTutor(Exercise assessedExercise, User tutor); @@ -34,8 +31,6 @@ public interface TutorParticipationRepository extends ArtemisJpaRepository findAllByAssessedExercise_Course_IdAndTutor_Id(long courseId, long tutorId); - List findAllByAssessedExercise_Course(Course course); - @EntityGraph(type = LOAD, attributePaths = { "trainedExampleSubmissions", "trainedExampleSubmissions.submission.results" }) List findAllByAssessedExercise_ExerciseGroup_Exam_IdAndTutor_Id(long examId, long tutorId); diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/repository/CompetencyProgressRepository.java b/src/main/java/de/tum/cit/aet/artemis/atlas/repository/CompetencyProgressRepository.java index 80f7948e8306..85c627b06408 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/repository/CompetencyProgressRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/repository/CompetencyProgressRepository.java @@ -41,10 +41,6 @@ public interface CompetencyProgressRepository extends ArtemisJpaRepository findByCompetencyIdAndUserId(@Param("competencyId") long competencyId, @Param("userId") long userId); - default CompetencyProgress findByCompetencyIdAndUserIdOrElseThrow(long competencyId, long userId) { - return getValueElseThrow(findByCompetencyIdAndUserId(competencyId, userId)); - } - @Query(""" SELECT cp FROM CompetencyProgress cp diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/repository/LearningPathRepository.java b/src/main/java/de/tum/cit/aet/artemis/atlas/repository/LearningPathRepository.java index ace7318ceace..596b50ef2e78 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/repository/LearningPathRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/repository/LearningPathRepository.java @@ -36,10 +36,6 @@ default LearningPath findWithEagerUserByIdElseThrow(long learningPathId) { @EntityGraph(type = LOAD, attributePaths = { "competencies" }) Optional findWithEagerCompetenciesByCourseIdAndUserId(long courseId, long userId); - default LearningPath findWithEagerCompetenciesByCourseIdAndUserIdElseThrow(long courseId, long userId) { - return getValueElseThrow(findWithEagerCompetenciesByCourseIdAndUserId(courseId, userId)); - } - @EntityGraph(type = LOAD, attributePaths = { "course", "competencies" }) Optional findWithEagerCourseAndCompetenciesById(long learningPathId); diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/repository/ScienceEventRepository.java b/src/main/java/de/tum/cit/aet/artemis/atlas/repository/ScienceEventRepository.java index f93db6988e1b..3c03f2d2806f 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/repository/ScienceEventRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/repository/ScienceEventRepository.java @@ -12,7 +12,6 @@ import org.springframework.transaction.annotation.Transactional; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; -import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEventType; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; /** @@ -22,8 +21,6 @@ @Repository public interface ScienceEventRepository extends ArtemisJpaRepository { - Set findAllByType(ScienceEventType type); - @Transactional // ok because of modifying query @Modifying @Query(""" diff --git a/src/main/java/de/tum/cit/aet/artemis/atlas/web/AdminStandardizedCompetencyResource.java b/src/main/java/de/tum/cit/aet/artemis/atlas/web/admin/AdminStandardizedCompetencyResource.java similarity index 99% rename from src/main/java/de/tum/cit/aet/artemis/atlas/web/AdminStandardizedCompetencyResource.java rename to src/main/java/de/tum/cit/aet/artemis/atlas/web/admin/AdminStandardizedCompetencyResource.java index aa7889ec35b0..376cedb132dc 100644 --- a/src/main/java/de/tum/cit/aet/artemis/atlas/web/AdminStandardizedCompetencyResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/atlas/web/admin/AdminStandardizedCompetencyResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.atlas.web; +package de.tum.cit.aet.artemis.atlas.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/repository/ConversationParticipantRepository.java b/src/main/java/de/tum/cit/aet/artemis/communication/repository/ConversationParticipantRepository.java index 1cbe9deb3490..aaf733332105 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/repository/ConversationParticipantRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/repository/ConversationParticipantRepository.java @@ -64,10 +64,6 @@ public interface ConversationParticipantRepository extends ArtemisJpaRepository< Optional findConversationParticipantByConversationIdAndUserId(Long conversationId, Long userId); - default ConversationParticipant findConversationParticipantByConversationIdAndUserIdElseThrow(Long conversationId, Long userId) { - return getValueElseThrow(findConversationParticipantByConversationIdAndUserId(conversationId, userId)); - } - @Query(""" SELECT DISTINCT conversationParticipant FROM ConversationParticipant conversationParticipant diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/repository/PostRepository.java b/src/main/java/de/tum/cit/aet/artemis/communication/repository/PostRepository.java index f78854c2818b..449a629fb4af 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/repository/PostRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/repository/PostRepository.java @@ -25,22 +25,6 @@ public interface PostRepository extends ArtemisJpaRepository, JpaSpe List findPostsByAuthorId(long authorId); - /** - * find all posts of a user in a course - * currently only used for testing - * - * @param authorId id of the user - * @param courseId id of the course - * @return a list of posts - */ - @Query(""" - SELECT p - FROM Post p - WHERE p.author.id =:authorId - AND p.conversation.course.id = :courseId - """) - List findPostsByAuthorIdAndCourseId(@Param("authorId") long authorId, @Param("courseId") long courseId); - @Transactional // ok because of delete @Modifying void deleteAllByConversationId(Long conversationId); diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/repository/ReactionRepository.java b/src/main/java/de/tum/cit/aet/artemis/communication/repository/ReactionRepository.java index 5a9914c6472b..4239e288500c 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/repository/ReactionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/repository/ReactionRepository.java @@ -17,9 +17,5 @@ @Repository public interface ReactionRepository extends ArtemisJpaRepository { - List findReactionsByPostId(Long postId); - List findReactionsByUserId(long userId); - - List findReactionsByAnswerPostId(Long answerPostId); } diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ChannelRepository.java b/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ChannelRepository.java index d7cbc2ae86c2..8833e1df67c7 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ChannelRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ChannelRepository.java @@ -58,15 +58,6 @@ public interface ChannelRepository extends ArtemisJpaRepository { """) List findChannelsOfUser(@Param("courseId") Long courseId, @Param("userId") Long userId); - @Query(""" - SELECT DISTINCT channel - FROM Channel channel - WHERE channel.course.id = :courseId - AND channel.isCourseWide = TRUE - ORDER BY channel.name - """) - List findCourseWideChannelsInCourse(@Param("courseId") long courseId); - @Query(""" SELECT DISTINCT channel FROM Channel channel diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ConversationRepository.java b/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ConversationRepository.java index 09faeaeead0e..c0c7303336c1 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ConversationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ConversationRepository.java @@ -27,9 +27,6 @@ public interface ConversationRepository extends ArtemisJpaRepository findAllByCourseId(long courseId); - @EntityGraph(type = LOAD, attributePaths = { "conversationParticipants" }) Optional findWithParticipantsById(long conversationId); diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/OneToOneChatRepository.java b/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/OneToOneChatRepository.java index cdd92f56c014..d1ab0058639c 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/OneToOneChatRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/OneToOneChatRepository.java @@ -11,7 +11,6 @@ import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.communication.domain.conversation.OneToOneChat; -import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; @Profile(PROFILE_CORE) @@ -73,15 +72,5 @@ AND EXISTS ( // one-to-one chats userA has in that specific course. Optional findWithParticipantsAndUserGroupsInCourseBetweenUsers(@Param("courseId") Long courseId, @Param("userIdA") Long userIdA, @Param("userIdB") Long userIdB); - @Query(""" - SELECT DISTINCT oneToOneChat - FROM OneToOneChat oneToOneChat - LEFT JOIN FETCH oneToOneChat.conversationParticipants p - LEFT JOIN FETCH p.user u - LEFT JOIN FETCH u.groups - WHERE oneToOneChat.id = :oneToOneChatId - """) - Optional findByIdWithConversationParticipantsAndUserGroups(@Param("oneToOneChatId") Long oneToOneChatId) throws EntityNotFoundException; - Integer countByCreatorIdAndCourseId(Long creatorId, Long courseId); } diff --git a/src/main/java/de/tum/cit/aet/artemis/communication/web/AdminSystemNotificationResource.java b/src/main/java/de/tum/cit/aet/artemis/communication/web/admin/AdminSystemNotificationResource.java similarity index 99% rename from src/main/java/de/tum/cit/aet/artemis/communication/web/AdminSystemNotificationResource.java rename to src/main/java/de/tum/cit/aet/artemis/communication/web/admin/AdminSystemNotificationResource.java index adee7ca161eb..6850598633e9 100644 --- a/src/main/java/de/tum/cit/aet/artemis/communication/web/AdminSystemNotificationResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/communication/web/admin/AdminSystemNotificationResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.communication.web; +package de.tum.cit.aet.artemis.communication.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/core/config/CacheConfiguration.java b/src/main/java/de/tum/cit/aet/artemis/core/config/CacheConfiguration.java index 73cb7773ed50..817b8e9e40ee 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/config/CacheConfiguration.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/config/CacheConfiguration.java @@ -241,7 +241,6 @@ public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties } config.getMapConfigs().put("default", initializeDefaultMapConfig(jHipsterProperties)); config.getMapConfigs().put("files", initializeFilesMapConfig(jHipsterProperties)); - // TODO Ole: investigate if the following * in artemis.*.domain works for database entity caching or if we need to specify all module domain paths here config.getMapConfigs().put("de.tum.cit.aet.artemis.*.domain.*", initializeDomainMapConfig(jHipsterProperties)); // Configure split brain protection if the cluster was split at some point diff --git a/src/main/java/de/tum/cit/aet/artemis/core/repository/CourseRepository.java b/src/main/java/de/tum/cit/aet/artemis/core/repository/CourseRepository.java index fb6db0e164b3..fa3bba8a4b73 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/repository/CourseRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/repository/CourseRepository.java @@ -138,9 +138,6 @@ SELECT COUNT(c) > 0 """) Optional findWithEagerLearningPathsAndLearningPathCompetencies(@Param("courseId") long courseId); - @EntityGraph(type = LOAD, attributePaths = { "competencies", "prerequisites", "learningPaths", "learningPaths.competencies" }) - Optional findWithEagerLearningPathsAndCompetenciesAndPrerequisitesById(long courseId); - // Note: we load attachments directly because otherwise, they will be loaded in subsequent DB calls due to the EAGER relationship @EntityGraph(type = LOAD, attributePaths = { "lectures", "lectures.attachments" }) Optional findWithEagerLecturesById(long courseId); @@ -488,11 +485,6 @@ default Course findWithEagerLearningPathsAndLearningPathCompetenciesByIdElseThro return getValueElseThrow(findWithEagerLearningPathsAndLearningPathCompetencies(courseId), courseId); } - @NotNull - default Course findWithEagerLearningPathsAndCompetenciesAndPrerequisitesByIdElseThrow(long courseId) { - return getValueElseThrow(findWithEagerLearningPathsAndCompetenciesAndPrerequisitesById(courseId), courseId); - } - Page findByTitleIgnoreCaseContaining(String partialTitle, Pageable pageable); /** diff --git a/src/main/java/de/tum/cit/aet/artemis/core/repository/DataExportRepository.java b/src/main/java/de/tum/cit/aet/artemis/core/repository/DataExportRepository.java index 29c060d7ba7d..fb87a2b0a8b0 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/repository/DataExportRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/repository/DataExportRepository.java @@ -67,11 +67,4 @@ public interface DataExportRepository extends ArtemisJpaRepository findAllDataExportsByUserIdOrderByRequestDateDesc(@Param("userId") long userId); - - @Query(""" - SELECT dataExport - FROM DataExport dataExport - WHERE dataExport.dataExportState = 2 - """) - Set findAllSuccessfullyCreatedDataExports(); } diff --git a/src/main/java/de/tum/cit/aet/artemis/core/repository/UserRepository.java b/src/main/java/de/tum/cit/aet/artemis/core/repository/UserRepository.java index 7451e637c56b..5b66b31aee98 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/repository/UserRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/repository/UserRepository.java @@ -162,12 +162,6 @@ public interface UserRepository extends ArtemisJpaRepository, JpaSpe @EntityGraph(type = LOAD, attributePaths = { "groups", "authorities", "guidedTourSettings", "irisAccepted" }) Optional findOneWithGroupsAndAuthoritiesAndGuidedTourSettingsAndIrisAcceptedTimestampByLogin(String login); - @EntityGraph(type = LOAD, attributePaths = { "learningPaths" }) - Optional findOneWithLearningPathsByLogin(String login); - - @EntityGraph(type = LOAD, attributePaths = { "learningPaths" }) - Optional findWithLearningPathsById(long userId); - Long countByIsDeletedIsFalseAndGroupsContains(String groupName); @Query(""" @@ -684,40 +678,6 @@ default Page searchAllWithGroupsByLoginOrNameInCourseAndReturnPage(Pageabl return new PageImpl<>(users, pageable, total); } - @Query(""" - SELECT user.id - FROM User user - WHERE user.isDeleted = FALSE - """) - List findUserIdsByIsDeletedIsFalse(Pageable pageable); - - @Query(""" - SELECT COUNT(user) - FROM User user - WHERE user.isDeleted = FALSE - """) - long countUsersByIsDeletedIsFalse(); - - /** - * Retrieves a paginated list of {@link User} entities that are not marked as deleted, - * with their associated groups. - * - * @param pageable the pagination information. - * @return a paginated list of {@link User} entities that are not marked as deleted. If no entities are found, returns an empty page. - */ - default Page findAllWithGroupsByIsDeletedIsFalse(Pageable pageable) { - List ids = findUserIdsByIsDeletedIsFalse(pageable); - if (ids.isEmpty()) { - return Page.empty(pageable); - } - List users = findUsersWithGroupsByIdIn(ids); - long total = countUsersByIsDeletedIsFalse(); - return new PageImpl<>(users, pageable, total); - } - - @EntityGraph(type = LOAD, attributePaths = { "groups", "authorities" }) - Set findAllWithGroupsAndAuthoritiesByIsDeletedIsFalse(); - @Modifying @Transactional // ok because of modifying query @Query(""" @@ -1035,17 +995,6 @@ default User findByIdWithGroupsAndAuthoritiesAndOrganizationsElseThrow(long user return getValueElseThrow(findOneWithGroupsAndAuthoritiesAndOrganizationsById(userId), userId); } - /** - * Find user with eagerly loaded learning paths by its id - * - * @param userId the id of the user to find - * @return the user with learning paths if it exists, else throw exception - */ - @NotNull - default User findWithLearningPathsByIdElseThrow(long userId) { - return getValueElseThrow(findWithLearningPathsById(userId), userId); - } - /** * Get students by given course * diff --git a/src/main/java/de/tum/cit/aet/artemis/core/web/AuditResource.java b/src/main/java/de/tum/cit/aet/artemis/core/web/admin/AuditResource.java similarity index 98% rename from src/main/java/de/tum/cit/aet/artemis/core/web/AuditResource.java rename to src/main/java/de/tum/cit/aet/artemis/core/web/admin/AuditResource.java index 03acab9f2da7..fe8af9ff7eb0 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/web/AuditResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/web/admin/AuditResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.core.web; +package de.tum.cit.aet.artemis.core.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; import static tech.jhipster.web.util.PaginationUtil.generatePaginationHttpHeaders; diff --git a/src/main/java/de/tum/cit/aet/artemis/core/web/FeatureToggleResource.java b/src/main/java/de/tum/cit/aet/artemis/core/web/admin/FeatureToggleResource.java similarity index 97% rename from src/main/java/de/tum/cit/aet/artemis/core/web/FeatureToggleResource.java rename to src/main/java/de/tum/cit/aet/artemis/core/web/admin/FeatureToggleResource.java index 6634a39ba454..84a58f7918aa 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/web/FeatureToggleResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/web/admin/FeatureToggleResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.core.web; +package de.tum.cit.aet.artemis.core.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/core/web/LogResource.java b/src/main/java/de/tum/cit/aet/artemis/core/web/admin/LogResource.java similarity index 97% rename from src/main/java/de/tum/cit/aet/artemis/core/web/LogResource.java rename to src/main/java/de/tum/cit/aet/artemis/core/web/admin/LogResource.java index 88cca685fd55..375deea352f6 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/web/LogResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/web/admin/LogResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.core.web; +package de.tum.cit.aet.artemis.core.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamLiveEventRepository.java b/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamLiveEventRepository.java index 497531b96045..18f4f98a3c0f 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamLiveEventRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exam/repository/ExamLiveEventRepository.java @@ -36,20 +36,6 @@ public interface ExamLiveEventRepository extends ArtemisJpaRepository findAllByStudentExamIdOrGlobalByExamId(@Param("examId") Long examId, @Param("studentExamId") Long studentExamId); - /** - * Find all events for the given student exam in reverse creation order. - * - * @param studentExamId the id of the student exam - * @return a list of events - */ - @Query(""" - SELECT event - FROM ExamLiveEvent event - WHERE event.studentExamId = :studentExamId - ORDER BY event.id DESC - """) - List findAllByStudentExamId(@Param("studentExamId") Long studentExamId); - /** * Delete all events for the given exam. * diff --git a/src/main/java/de/tum/cit/aet/artemis/exam/repository/StudentExamRepository.java b/src/main/java/de/tum/cit/aet/artemis/exam/repository/StudentExamRepository.java index 1b0ee4c7ff9e..2236d4d2035c 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exam/repository/StudentExamRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exam/repository/StudentExamRepository.java @@ -62,17 +62,6 @@ public interface StudentExamRepository extends ArtemisJpaRepository findWithExercisesByUserIdAndExamId(@Param("userId") long userId, @Param("examId") long examId, @Param("isTestRun") boolean isTestRun); - // Normally, there should only be one student exam for the same user/exam pair (except test runs for instructors) - @Query(""" - SELECT DISTINCT se - FROM StudentExam se - LEFT JOIN FETCH se.exercises e - WHERE se.testRun = FALSE - AND se.exam.id = :examId - AND se.user.id = :userId - """) - List findAllWithExercisesByUserIdAndExamId(@Param("userId") long userId, @Param("examId") long examId); - @Query(""" SELECT DISTINCT se FROM StudentExam se @@ -160,20 +149,6 @@ SELECT COUNT(se) """) long countStudentExamsSubmittedByExamIdIgnoreTestRuns(@Param("examId") Long examId); - @Query(""" - SELECT DISTINCT se - FROM StudentExam se - LEFT JOIN FETCH se.exercises e - LEFT JOIN FETCH e.studentParticipations sp - LEFT JOIN FETCH sp.submissions s - LEFT JOIN FETCH s.results r - LEFT JOIN FETCH r.assessor a - WHERE se.exam.id = :examId - AND se.testRun = TRUE - AND se.user.id = sp.student.id - """) - List findAllTestRunsWithExercisesParticipationsSubmissionsResultsByExamId(@Param("examId") Long examId); - /** * It might happen that multiple test exams exist for a combination of userId/examId, that's why we return a set here. * @@ -270,8 +245,6 @@ SELECT MAX(se.workingTime) """) Set findAllUnsubmittedWithExercisesByExamId(@Param("examId") Long examId); - List findAllByExamId_AndTestRunIsTrue(Long examId); - @Query(""" SELECT DISTINCT se FROM StudentExam se @@ -351,18 +324,6 @@ default StudentExam findByIdWithExercisesSubmissionPolicyAndSessionsElseThrow(Lo return getValueElseThrow(findWithExercisesSubmissionPolicyAndSessionsById(studentExamId), studentExamId); } - /** - * Get the maximal working time of all student exams for the exam with the given id. - * - * @param examId the id of the exam - * @return the maximum of all student exam working times for the given exam - * @throws EntityNotFoundException if no student exams could be found - */ - @NotNull - default Integer findMaxWorkingTimeByExamIdElseThrow(Long examId) { - return getArbitraryValueElseThrow(findMaxWorkingTimeByExamId(examId), Long.toString(examId)); - } - /** * Generates random exams for each user in the given users set and saves them. * @@ -447,34 +408,6 @@ private Exercise selectRandomExercise(SecureRandom random, ExerciseGroup exercis return exercises.get(randomIndex); } - /** - * Get all student exams for the given exam id with quiz questions. - * - * @param ids the ids of the student exams - * @return the list of student exams with quiz questions - */ - @Query(""" - SELECT DISTINCT se - FROM StudentExam se - LEFT JOIN FETCH se.quizQuestions qq - WHERE se.id IN :ids - """) - List findAllWithEagerQuizQuestionsById(@Param("ids") List ids); - - /** - * Get all student exams for the given exam id with exercises. - * - * @param ids the ids of the student exams - * @return the list of student exams with exercises - */ - @Query(""" - SELECT DISTINCT se - FROM StudentExam se - LEFT JOIN FETCH se.exercises e - WHERE se.id IN :ids - """) - List findAllWithEagerExercisesById(@Param("ids") List ids); - /** * Gets the longest working time of the exam with the given id * diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/ParticipationRepository.java b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/ParticipationRepository.java index 21d97fb368f9..3c997899454c 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/ParticipationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/ParticipationRepository.java @@ -44,19 +44,6 @@ public interface ParticipationRepository extends ArtemisJpaRepository findByIdWithLatestSubmissionAndResult(@Param("participationId") long participationId); - @Query(""" - SELECT p - FROM Participation p - LEFT JOIN FETCH p.submissions s - WHERE p.id = :participationId - AND (s.id = (SELECT MAX(s2.id) FROM p.submissions s2) OR s.id IS NULL) - """) - Optional findByIdWithLatestSubmission(@Param("participationId") long participationId); - - default Participation findByIdWithLatestSubmissionElseThrow(Long participationId) { - return getValueElseThrow(findByIdWithLatestSubmission(participationId), participationId); - } - @Query(""" SELECT p FROM Participation p @@ -119,8 +106,6 @@ SELECT MIN(p.individualDueDate) """) Optional findWithProgrammingExerciseWithBuildConfigById(@Param("participationId") long participationId); - Set findByExerciseId(long exerciseId); - /** * Removes all individual due dates of participations for which the individual due date is before the updated due date of the exercise. *

diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java index d88e3bd7bae0..aceb0bd9c2ae 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/StudentParticipationRepository.java @@ -190,17 +190,6 @@ SELECT COUNT(p) > 0 """) List findByExerciseIdAndTestRunWithEagerLegalSubmissionsResult(@Param("exerciseId") long exerciseId, @Param("testRun") boolean testRun); - @Query(""" - SELECT DISTINCT p - FROM StudentParticipation p - LEFT JOIN FETCH p.submissions s - LEFT JOIN FETCH s.results r - LEFT JOIN FETCH r.assessor - WHERE p.exercise.id = :exerciseId - AND p.testRun = :testRun - """) - List findByExerciseIdAndTestRunWithEagerSubmissionsResultAssessor(@Param("exerciseId") long exerciseId, @Param("testRun") boolean testRun); - @Query(""" SELECT DISTINCT p FROM StudentParticipation p @@ -583,17 +572,6 @@ List findByExerciseIdWithLatestSubmissionWithoutManualResu """) Optional findWithEagerResultsById(@Param("participationId") long participationId); - @Query(""" - SELECT p - FROM Participation p - LEFT JOIN FETCH p.results r - LEFT JOIN FETCH r.submission s - LEFT JOIN FETCH r.feedbacks - WHERE p.id = :participationId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - """) - Optional findWithEagerResultsAndFeedbackById(@Param("participationId") long participationId); - /** * Find the participation with the given id. Additionally, load all the submissions and results of the participation from the database. * Further, load the exercise and its course. Returns an empty Optional if the participation could not be found. @@ -619,19 +597,6 @@ List findByExerciseIdWithLatestSubmissionWithoutManualResu """) Optional findWithEagerLegalSubmissionsResultsFeedbacksById(@Param("participationId") long participationId); - @Query(""" - SELECT p - FROM StudentParticipation p - LEFT JOIN FETCH p.results r - LEFT JOIN FETCH r.submission rs - LEFT JOIN FETCH p.submissions s - LEFT JOIN FETCH r.assessor - WHERE p.id = :participationId - AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) - AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR rs.type IS NULL) - """) - Optional findWithEagerLegalSubmissionsAndResultsAssessorsById(@Param("participationId") long participationId); - @EntityGraph(type = LOAD, attributePaths = { "submissions", "submissions.results", "submissions.results.assessor" }) List findAllWithEagerSubmissionsAndEagerResultsAndEagerAssessorByExerciseId(long exerciseId); diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java index 0bb30b92be3f..16cac0f54cef 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java @@ -71,8 +71,6 @@ public interface SubmissionRepository extends ArtemisJpaRepository findByParticipationIdOrderBySubmissionDateDesc(long participationId); - List findByParticipation_Exercise_ExerciseGroup_Exam_Id(long examId); - /** * Get all submissions of a participation and eagerly load results * @@ -342,21 +340,6 @@ SELECT COUNT(DISTINCT p) """) List countByExerciseIdsSubmittedBeforeDueDateIgnoreTestRuns(@Param("exerciseIds") Set exerciseIds); - /** - * Calculate the number of submitted submissions for the given exercise. This query uses the participations to make sure that each student is only counted once - * - * @param exerciseId the exercise id we are interested in - * @return the number of submissions belonging to the exercise id, which have the submitted flag set to true - */ - @Query(""" - SELECT COUNT(DISTINCT p) - FROM StudentParticipation p - JOIN p.submissions s - WHERE p.exercise.id = :exerciseId - AND s.submitted = TRUE - """) - long countByExerciseIdSubmitted(@Param("exerciseId") long exerciseId); - /** * Calculate the number of submissions for the given exercise by the given student. * @@ -543,14 +526,6 @@ SELECT MAX(s2.submissionDate) """) Page findLatestSubmittedSubmissionsByExerciseId(@Param("exerciseId") long exerciseId, Pageable pageable); - /** - * Gets all submitted Submissions for the given exercise. Note that you usually only want the latest submissions. - * - * @param exerciseId the ID of the exercise - * @return Set of Submissions - */ - Set findByParticipation_ExerciseIdAndSubmittedIsTrue(long exerciseId); - /** * GChecks if unassessed Quiz Submissions exist for the given exam * diff --git a/src/main/java/de/tum/cit/aet/artemis/exercise/web/AdminExerciseResource.java b/src/main/java/de/tum/cit/aet/artemis/exercise/web/admin/AdminExerciseResource.java similarity index 96% rename from src/main/java/de/tum/cit/aet/artemis/exercise/web/AdminExerciseResource.java rename to src/main/java/de/tum/cit/aet/artemis/exercise/web/admin/AdminExerciseResource.java index cc824e67405d..306ad29ddd4f 100644 --- a/src/main/java/de/tum/cit/aet/artemis/exercise/web/AdminExerciseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/exercise/web/admin/AdminExerciseResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.web; +package de.tum.cit.aet.artemis.exercise.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisHestiaSessionRepository.java b/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisHestiaSessionRepository.java index 346ca70d8cef..22a14bd98bd7 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisHestiaSessionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisHestiaSessionRepository.java @@ -1,12 +1,10 @@ package de.tum.cit.aet.artemis.iris.repository; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; -import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; import java.util.List; import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; @@ -27,14 +25,4 @@ public interface IrisHestiaSessionRepository extends ArtemisJpaRepository findByCodeHintIdOrderByCreationDateDesc(Long codeHintId); - - /** - * Finds a single {@link IrisHestiaSession} by its ID and eagerly loads all messages and their contents, - * as well as the code hint and its solution entries - * - * @param sessionId The ID of the session to find - * @return The session with the given ID - */ - @EntityGraph(type = LOAD, attributePaths = { "messages", "messages.content", "codeHint", "codeHint.exercise", "codeHint.solutionEntries" }) - IrisHestiaSession findWithMessagesAndContentsAndCodeHintById(long sessionId); } diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisMessageRepository.java b/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisMessageRepository.java index 608831867c79..ffff9586b92b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisMessageRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisMessageRepository.java @@ -1,23 +1,17 @@ package de.tum.cit.aet.artemis.iris.repository; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; -import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; import java.time.ZonedDateTime; import java.util.List; -import java.util.Optional; - -import jakarta.validation.constraints.NotNull; import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; import de.tum.cit.aet.artemis.iris.domain.message.IrisMessage; -import de.tum.cit.aet.artemis.iris.domain.message.IrisMessageSender; /** * Spring Data repository for the IrisMessage entity. @@ -45,26 +39,4 @@ JOIN TREAT (m.session AS IrisChatSession) s AND m.sentAt BETWEEN :start AND :end """) int countLlmResponsesOfUserWithinTimeframe(@Param("userId") long userId, @Param("start") ZonedDateTime start, @Param("end") ZonedDateTime end); - - Optional findFirstBySessionIdAndSenderOrderBySentAtDesc(long sessionId, @NotNull IrisMessageSender sender); - - @EntityGraph(type = LOAD, attributePaths = { "content" }) - IrisMessage findIrisMessageById(long irisMessageId); - - /** - * Finds the first message with content by session ID and sender, ordered by the sent date in descending order. - * This method avoids in-memory paging by retrieving the message directly from the database. - * - * @param sessionId the ID of the session to find the message for - * @param sender the sender of the message - * @return the first {@code IrisMessage} with content, ordered by sent date in descending order, - * or null if no message is found - */ - default IrisMessage findFirstWithContentBySessionIdAndSenderOrderBySentAtDesc(long sessionId, @NotNull IrisMessageSender sender) { - var irisMessage = findFirstBySessionIdAndSenderOrderBySentAtDesc(sessionId, sender); - if (irisMessage.isEmpty()) { - return null; - } - return findIrisMessageById(irisMessage.get().getId()); - } } diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisConnectorService.java b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisConnectorService.java index 6d54a5592771..785fc59b9ed7 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisConnectorService.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisConnectorService.java @@ -24,7 +24,7 @@ import de.tum.cit.aet.artemis.iris.exception.IrisInternalPyrisErrorException; import de.tum.cit.aet.artemis.iris.service.pyris.dto.PyrisModelDTO; import de.tum.cit.aet.artemis.iris.service.pyris.dto.lectureingestionwebhook.PyrisWebhookLectureIngestionExecutionDTO; -import de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource; +import de.tum.cit.aet.artemis.iris.web.open.PublicPyrisStatusUpdateResource; /** * This service connects to the Python implementation of Iris (called Pyris). diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/web/AdminIrisSettingsResource.java b/src/main/java/de/tum/cit/aet/artemis/iris/web/admin/AdminIrisSettingsResource.java similarity index 97% rename from src/main/java/de/tum/cit/aet/artemis/iris/web/AdminIrisSettingsResource.java rename to src/main/java/de/tum/cit/aet/artemis/iris/web/admin/AdminIrisSettingsResource.java index 03bfaaad6c62..b8ea1f92ba31 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/web/AdminIrisSettingsResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/web/admin/AdminIrisSettingsResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.iris.web; +package de.tum.cit.aet.artemis.iris.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; diff --git a/src/main/java/de/tum/cit/aet/artemis/iris/web/PublicPyrisStatusUpdateResource.java b/src/main/java/de/tum/cit/aet/artemis/iris/web/open/PublicPyrisStatusUpdateResource.java similarity index 99% rename from src/main/java/de/tum/cit/aet/artemis/iris/web/PublicPyrisStatusUpdateResource.java rename to src/main/java/de/tum/cit/aet/artemis/iris/web/open/PublicPyrisStatusUpdateResource.java index 117aa63c1202..05fecc5a287e 100644 --- a/src/main/java/de/tum/cit/aet/artemis/iris/web/PublicPyrisStatusUpdateResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/iris/web/open/PublicPyrisStatusUpdateResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.iris.web; +package de.tum.cit.aet.artemis.iris.web.open; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; diff --git a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java index f9c2241c02d2..3470d2ccf477 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lecture/repository/SlideRepository.java @@ -2,8 +2,6 @@ import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; -import java.util.List; - import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Repository; @@ -17,8 +15,6 @@ @Repository public interface SlideRepository extends ArtemisJpaRepository { - List findAllByAttachmentUnitId(Long attachmentUnitId); - Slide findSlideByAttachmentUnitIdAndSlideNumber(Long attachmentUnitId, Integer slideNumber); } diff --git a/src/main/java/de/tum/cit/aet/artemis/lti/repository/LtiPlatformConfigurationRepository.java b/src/main/java/de/tum/cit/aet/artemis/lti/repository/LtiPlatformConfigurationRepository.java index 206671c53e9e..604068c5e397 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lti/repository/LtiPlatformConfigurationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/lti/repository/LtiPlatformConfigurationRepository.java @@ -51,12 +51,4 @@ default LtiPlatformConfiguration findLtiPlatformConfigurationWithEagerLoadedCour */ @EntityGraph(type = LOAD, attributePaths = { "onlineCourseConfigurations" }) LtiPlatformConfiguration findWithEagerOnlineCourseConfigurationsById(long platformId); - - /** - * Finds an LTI platform configuration by its client ID. - * - * @param clientId The registration ID. - * @return Optional of LtiPlatformConfiguration. - */ - Optional findByClientId(String clientId); } diff --git a/src/main/java/de/tum/cit/aet/artemis/lti/web/AdminLtiConfigurationResource.java b/src/main/java/de/tum/cit/aet/artemis/lti/web/admin/AdminLtiConfigurationResource.java similarity index 99% rename from src/main/java/de/tum/cit/aet/artemis/lti/web/AdminLtiConfigurationResource.java rename to src/main/java/de/tum/cit/aet/artemis/lti/web/admin/AdminLtiConfigurationResource.java index 622879915037..654facd44302 100644 --- a/src/main/java/de/tum/cit/aet/artemis/lti/web/AdminLtiConfigurationResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/lti/web/admin/AdminLtiConfigurationResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.lti.web; +package de.tum.cit.aet.artemis.lti.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_LTI; diff --git a/src/main/java/de/tum/cit/aet/artemis/modeling/repository/ModelingSubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/modeling/repository/ModelingSubmissionRepository.java index c5c2645d3b24..07eb0e37c28e 100644 --- a/src/main/java/de/tum/cit/aet/artemis/modeling/repository/ModelingSubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/modeling/repository/ModelingSubmissionRepository.java @@ -22,15 +22,6 @@ @Repository public interface ModelingSubmissionRepository extends ArtemisJpaRepository { - @Query(""" - SELECT DISTINCT submission - FROM ModelingSubmission submission - LEFT JOIN FETCH submission.results r - LEFT JOIN FETCH r.assessor - WHERE submission.id = :submissionId - """) - Optional findByIdWithEagerResult(@Param("submissionId") Long submissionId); - @Query(""" SELECT DISTINCT submission FROM ModelingSubmission submission @@ -51,9 +42,6 @@ public interface ModelingSubmissionRepository extends ArtemisJpaRepository findWithResultsFeedbacksAssessorAssessmentNoteAndParticipationResultsById(Long submissionId); - @EntityGraph(type = LOAD, attributePaths = { "results" }) - Optional findWithEagerResultById(Long submissionId); - @Query(""" SELECT DISTINCT submission FROM ModelingSubmission submission diff --git a/src/main/java/de/tum/cit/aet/artemis/modeling/web/AdminModelingExerciseResource.java b/src/main/java/de/tum/cit/aet/artemis/modeling/web/admin/AdminModelingExerciseResource.java similarity index 98% rename from src/main/java/de/tum/cit/aet/artemis/modeling/web/AdminModelingExerciseResource.java rename to src/main/java/de/tum/cit/aet/artemis/modeling/web/admin/AdminModelingExerciseResource.java index 25c4c6a83df8..215ea0a05293 100644 --- a/src/main/java/de/tum/cit/aet/artemis/modeling/web/AdminModelingExerciseResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/modeling/web/admin/AdminModelingExerciseResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.modeling.web; +package de.tum.cit.aet.artemis.modeling.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/BuildJobRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/BuildJobRepository.java index dfce5b56ef52..7c341585f60f 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/BuildJobRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/BuildJobRepository.java @@ -11,7 +11,6 @@ import org.springframework.context.annotation.Profile; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; @@ -19,7 +18,6 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.buildagent.dto.BuildJobResultCountDTO; import de.tum.cit.aet.artemis.buildagent.dto.DockerImageBuild; import de.tum.cit.aet.artemis.buildagent.dto.ResultBuildJob; @@ -31,10 +29,6 @@ @Repository public interface BuildJobRepository extends ArtemisJpaRepository, JpaSpecificationExecutor { - Optional findFirstByParticipationIdOrderByBuildStartDateDesc(Long participationId); - - Optional findBuildJobByResult(Result result); - @EntityGraph(type = LOAD, attributePaths = { "result", "result.participation", "result.participation.exercise", "result.submission" }) List findWithDataByIdIn(List ids); @@ -67,31 +61,6 @@ Page findIdsByFilterCriteria(@Param("buildStatus") BuildStatus buildStatus """) Set findAllLastBuildDatesForDockerImages(); - @Query(""" - SELECT b.id - FROM BuildJob b - WHERE b.courseId = :courseId - """) - List findIdsByCourseId(@Param("courseId") long courseId, Pageable pageable); - - long countBuildJobByCourseId(long courseId); - - /** - * Retrieves a paginated list of all {@link BuildJob} entities that have a given course id. - * - * @param courseId the course id. - * @param pageable the pagination information. - * @return a paginated list of {@link BuildJob} entities. If no entities are found, returns an empty page. - */ - default Page findAllWithDataByCourseId(long courseId, Pageable pageable) { - List ids = findIdsByCourseId(courseId, pageable); - if (ids.isEmpty()) { - return Page.empty(pageable); - } - List result = findWithDataByIdIn(ids); - return new PageImpl<>(result, pageable, countBuildJobByCourseId(courseId)); - } - @Query(""" SELECT new de.tum.cit.aet.artemis.buildagent.dto.ResultBuildJob( b.result.id, diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java index 1e27f9a20b24..370c191e0ac0 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java @@ -246,15 +246,6 @@ default ProgrammingExercise findOneByProjectKeyOrThrow(String projectKey, boolea """) List findAllWithStudentParticipationByRecentExamEndDate(@Param("endDate1") ZonedDateTime endDate1, @Param("endDate2") ZonedDateTime endDate2); - @Query(""" - SELECT DISTINCT pe - FROM ProgrammingExercise pe - LEFT JOIN FETCH pe.templateParticipation - LEFT JOIN FETCH pe.solutionParticipation - WHERE pe.id = :exerciseId - """) - Optional findWithEagerTemplateAndSolutionParticipationsById(@Param("exerciseId") long exerciseId); - @EntityGraph(type = LOAD, attributePaths = { "studentParticipations", "studentParticipations.team", "studentParticipations.team.students" }) Optional findWithEagerStudentParticipationsById(long exerciseId); @@ -271,9 +262,6 @@ default ProgrammingExercise findOneByProjectKeyOrThrow(String projectKey, boolea """) Optional findWithEagerStudentParticipationsStudentAndLegalSubmissionsById(@Param("exerciseId") long exerciseId); - @EntityGraph(type = LOAD, attributePaths = { "templateParticipation", "solutionParticipation", "studentParticipations.team.students", "buildConfig" }) - Optional findWithAllParticipationsAndBuildConfigById(long exerciseId); - @Query(""" SELECT pe FROM ProgrammingExercise pe @@ -495,12 +483,6 @@ SELECT COUNT (DISTINCT p) """) long countAllSubmissionsByExerciseIdsSubmitted(@Param("exerciseIds") Set exerciseIds); - List findAllByCourse_InstructorGroupNameIn(Set groupNames); - - List findAllByCourse_EditorGroupNameIn(Set groupNames); - - List findAllByCourse_TeachingAssistantGroupNameIn(Set groupNames); - // Note: we have to use left join here to avoid issues in the where clause, there can be at most one indirection (e.g. c1.editorGroupName) in the WHERE clause when using "OR" // Multiple different indirection in the WHERE clause (e.g. pe.course.instructorGroupName and ex.course.instructorGroupName) would not work @Query(""" @@ -533,9 +515,6 @@ SELECT COUNT (DISTINCT p) @EntityGraph(type = LOAD, attributePaths = { "plagiarismDetectionConfig", "teamAssignmentConfig", "buildConfig" }) Optional findWithPlagiarismDetectionConfigTeamConfigAndBuildConfigById(long exerciseId); - @EntityGraph(type = LOAD, attributePaths = { "buildConfig" }) - Optional findWithBuildConfigById(long exerciseId); - long countByShortNameAndCourse(String shortName, Course course); long countByTitleAndCourse(String shortName, Course course); @@ -574,11 +553,6 @@ default ProgrammingExercise findByIdWithPlagiarismDetectionConfigTeamConfigAndBu return getValueElseThrow(findWithPlagiarismDetectionConfigTeamConfigAndBuildConfigById(programmingExerciseId), programmingExerciseId); } - @NotNull - default ProgrammingExercise findByIdWithBuildConfigElseThrow(long programmingExerciseId) throws EntityNotFoundException { - return getValueElseThrow(findWithBuildConfigById(programmingExerciseId), programmingExerciseId); - } - /** * Find a programming exercise with auxiliary repositories by its id and throw an EntityNotFoundException if it cannot be found * @@ -862,19 +836,6 @@ default ProgrammingExercise getProgrammingExerciseFromParticipationElseThrow(Pro return programmingExercise; } - /** - * Fetch the programming exercise with the build config, or throw an EntityNotFoundException if it cannot be found. - * - * @param programmingExercise The programming exercise to fetch the build config for. - * @return The programming exercise with the build config. - */ - default ProgrammingExercise getProgrammingExerciseWithBuildConfigElseThrow(ProgrammingExercise programmingExercise) { - if (programmingExercise.getBuildConfig() == null || !Hibernate.isInitialized(programmingExercise.getBuildConfig())) { - return getValueElseThrow(findWithBuildConfigById(programmingExercise.getId()), programmingExercise.getId()); - } - return programmingExercise; - } - /** * Validate the programming exercise title. * 1. Check presence and length of exercise title diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java index 63bab2cd8573..8929c407336b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseStudentParticipationRepository.java @@ -125,8 +125,6 @@ Optional findWithSubmissionsAndEagerStu """) Optional findTeamParticipationByExerciseIdAndStudentId(@Param("exerciseId") long exerciseId, @Param("studentId") long studentId); - List findByExerciseId(long exerciseId); - @EntityGraph(type = LOAD, attributePaths = { "submissions", "team.students" }) List findWithSubmissionsById(long participationId); diff --git a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseTestCaseRepository.java b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseTestCaseRepository.java index be709d2d8ce4..0ec309e45e8b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseTestCaseRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseTestCaseRepository.java @@ -23,8 +23,6 @@ public interface ProgrammingExerciseTestCaseRepository extends ArtemisJpaReposit Set findByExerciseId(long exerciseId); - Optional findByExerciseIdAndTestName(long exerciseId, String testName); - default ProgrammingExerciseTestCase findByIdWithExerciseElseThrow(long testCaseId) { return getValueElseThrow(findByIdWithExercise(testCaseId), testCaseId); } @@ -43,20 +41,6 @@ default ProgrammingExerciseTestCase findByIdWithExerciseElseThrow(long testCaseI """) Optional findByIdWithExercise(@Param("testCaseId") long testCaseId); - /** - * Returns all test cases with the associated solution entries for a programming exercise - * - * @param exerciseId of the exercise - * @return all test cases with the associated solution entries - */ - @Query(""" - SELECT DISTINCT tc - FROM ProgrammingExerciseTestCase tc - LEFT JOIN FETCH tc.solutionEntries se - WHERE tc.exercise.id = :exerciseId - """) - Set findByExerciseIdWithSolutionEntries(@Param("exerciseId") long exerciseId); - /** * Returns all test cases with the associated solution entries for a programming exercise * diff --git a/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizExerciseRepository.java b/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizExerciseRepository.java index db0380cf3d1e..5ab0a9bbb1a1 100644 --- a/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizExerciseRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizExerciseRepository.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Optional; -import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotNull; import org.springframework.context.annotation.Profile; @@ -42,14 +41,6 @@ public interface QuizExerciseRepository extends ArtemisJpaRepository findByExamId(@Param("examId") Long examId); - @Query(""" - SELECT DISTINCT qe - FROM QuizExercise qe - LEFT JOIN qe.quizBatches b - WHERE b.startTime > :earliestReleaseDate - """) - List findAllPlannedToStartAfter(@Param("earliestReleaseDate") ZonedDateTime earliestReleaseDate); - /** * Find all quiz exercises that are planned to start in the future * @@ -86,17 +77,6 @@ default QuizExercise findWithEagerBatchesByIdOrElseThrow(Long quizExerciseId) { return getValueElseThrow(findWithEagerBatchesById(quizExerciseId), quizExerciseId); } - /** - * Get one quiz exercise - * - * @param quizExerciseId the id of the entity - * @return the entity - */ - @Nullable - default QuizExercise findOne(Long quizExerciseId) { - return findById(quizExerciseId).orElse(null); - } - /** * Get one quiz exercise by id and eagerly load questions * @@ -130,17 +110,6 @@ default QuizExercise findByIdWithBatchesElseThrow(Long quizExerciseId) { return getValueElseThrow(findWithEagerBatchesById(quizExerciseId), quizExerciseId); } - /** - * Get one quiz exercise by id and eagerly load questions and statistics - * - * @param quizExerciseId the id of the entity - * @return the quiz exercise entity - */ - @Nullable - default QuizExercise findOneWithQuestionsAndStatistics(Long quizExerciseId) { - return findWithEagerQuestionsAndStatisticsById(quizExerciseId).orElse(null); - } - @NotNull default QuizExercise findByIdWithQuestionsAndStatisticsElseThrow(Long quizExerciseId) { return getValueElseThrow(findWithEagerQuestionsAndStatisticsById(quizExerciseId), quizExerciseId); @@ -150,9 +119,4 @@ default QuizExercise findByIdWithQuestionsAndStatisticsElseThrow(Long quizExerci default QuizExercise findByIdWithQuestionsAndStatisticsAndCompetenciesElseThrow(Long quizExerciseId) { return getValueElseThrow(findWithEagerQuestionsAndStatisticsAndCompetenciesById(quizExerciseId), quizExerciseId); } - - default List findAllPlannedToStartInTheFuture() { - return findAllPlannedToStartAfter(ZonedDateTime.now()); - } - } diff --git a/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizSubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizSubmissionRepository.java index 6d0cfed3573f..4202d525190b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizSubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/quiz/repository/QuizSubmissionRepository.java @@ -39,17 +39,6 @@ public interface QuizSubmissionRepository extends ArtemisJpaRepository findWithEagerSubmittedAnswersByParticipationId(long participationId); - Set findByParticipation_Exercise_Id(long exerciseId); - - @Query(""" - SELECT submission - FROM QuizSubmission submission - JOIN submission.participation participation - JOIN participation.exercise exercise - WHERE exercise.id = :quizExerciseId - """) - Optional findByQuizExerciseId(@Param("quizExerciseId") long quizExerciseId); - /** * Retrieve QuizSubmission for given quiz batch and studentLogin * diff --git a/src/main/java/de/tum/cit/aet/artemis/text/repository/TextSubmissionRepository.java b/src/main/java/de/tum/cit/aet/artemis/text/repository/TextSubmissionRepository.java index a32a04a63d3c..9929c1b5f9db 100644 --- a/src/main/java/de/tum/cit/aet/artemis/text/repository/TextSubmissionRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/text/repository/TextSubmissionRepository.java @@ -4,7 +4,6 @@ import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; import java.util.Optional; -import java.util.Set; import jakarta.validation.constraints.NotNull; @@ -47,25 +46,11 @@ public interface TextSubmissionRepository extends ArtemisJpaRepository findWithEagerResultAndTextBlocksAndFeedbackByResults_Id(long resultId); - /** - * Gets all TextSubmissions which are submitted and loads all blocks - * - * @param exerciseId the ID of the exercise - * @return Set of Text Submissions - */ - @EntityGraph(type = LOAD, attributePaths = { "blocks" }) - Set findByParticipation_ExerciseIdAndSubmittedIsTrue(long exerciseId); - @NotNull default TextSubmission getTextSubmissionWithResultAndTextBlocksAndFeedbackByResultIdElseThrow(long resultId) { return getValueElseThrow(findWithEagerResultAndTextBlocksAndFeedbackByResults_Id(resultId)); } - @NotNull - default TextSubmission findByIdWithParticipationExerciseResultAssessorElseThrow(long submissionId) { - return getValueElseThrow(findWithEagerParticipationExerciseResultAssessorById(submissionId), submissionId); - } - @NotNull default TextSubmission findByIdWithParticipationExerciseResultAssessorAssessmentNoteElseThrow(long submissionId) { return getValueElseThrow(findWithEagerParticipationExerciseResultAssessorAssessmentNoteById(submissionId), submissionId); diff --git a/src/main/java/de/tum/cit/aet/artemis/text/web/AdminTextAssessmentEventResource.java b/src/main/java/de/tum/cit/aet/artemis/text/web/admin/AdminTextAssessmentEventResource.java similarity index 97% rename from src/main/java/de/tum/cit/aet/artemis/text/web/AdminTextAssessmentEventResource.java rename to src/main/java/de/tum/cit/aet/artemis/text/web/admin/AdminTextAssessmentEventResource.java index 51ee57b167b2..78b6a9f8871b 100644 --- a/src/main/java/de/tum/cit/aet/artemis/text/web/AdminTextAssessmentEventResource.java +++ b/src/main/java/de/tum/cit/aet/artemis/text/web/admin/AdminTextAssessmentEventResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.text.web; +package de.tum.cit.aet.artemis.text.web.admin; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRegistrationRepository.java b/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRegistrationRepository.java index a5b4f96c79db..38fdcbd35fbb 100644 --- a/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRegistrationRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRegistrationRepository.java @@ -5,8 +5,6 @@ import java.util.Optional; import java.util.Set; -import jakarta.validation.constraints.NotNull; - import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.Modifying; import org.springframework.stereotype.Repository; @@ -30,20 +28,7 @@ Optional findTutorialGroupRegistrationByTutorialGroup Set findAllByTutorialGroup(TutorialGroup tutorialGroup); - @Transactional // ok because of delete - @Modifying - void deleteAllByStudent(User student); - - @Transactional // ok because of delete - @Modifying - void deleteById(@NotNull Long tutorialGroupRegistrationId); - @Transactional // ok because of delete @Modifying void deleteAllByStudentIsInAndTypeAndTutorialGroupCourse(Set students, TutorialGroupRegistrationType type, Course course); - - boolean existsByTutorialGroupTitleAndStudentAndType(String title, User student, TutorialGroupRegistrationType type); - - Integer countByStudentAndTutorialGroupCourseIdAndType(User student, Long courseId, TutorialGroupRegistrationType type); - } diff --git a/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRepository.java b/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRepository.java index 111ec21fbfb3..58ca8c4ffbc7 100644 --- a/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupRepository.java @@ -119,20 +119,8 @@ public interface TutorialGroupRepository extends ArtemisJpaRepository findByIdWithTeachingAssistantAndCourse(@Param("tutorialGroupId") long tutorialGroupId); - @Query(""" - SELECT tutorialGroup - FROM TutorialGroup tutorialGroup - LEFT JOIN FETCH tutorialGroup.teachingAssistant - LEFT JOIN FETCH tutorialGroup.registrations - WHERE tutorialGroup.title = :title - AND tutorialGroup.course.id = :courseId - """) - Optional findByTitleAndCourseIdWithTeachingAssistantAndRegistrations(@Param("title") String title, @Param("courseId") Long courseId); - Optional findByTutorialGroupChannelId(Long channelId); - boolean existsByTitleAndCourseId(String title, Long courseId); - @Query(""" SELECT tutorialGroup FROM TutorialGroup tutorialGroup diff --git a/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupScheduleRepository.java b/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupScheduleRepository.java index a2f8f67f2db5..3bb2868a0ed8 100644 --- a/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupScheduleRepository.java +++ b/src/main/java/de/tum/cit/aet/artemis/tutorialgroup/repository/TutorialGroupScheduleRepository.java @@ -28,8 +28,6 @@ public interface TutorialGroupScheduleRepository extends ArtemisJpaRepository getAllByTutorialGroupCourse(Course course); - Optional findByTutorialGroupId(Long tutorialGroupId); - default TutorialGroupSchedule findByIdWithSessionsElseThrow(long tutorialGroupScheduleId) { return getValueElseThrow(findByIdWithSessions(tutorialGroupScheduleId), tutorialGroupScheduleId); } diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentComplaintIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentComplaintIntegrationTest.java index 1eed5b32df7f..38367caa5163 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentComplaintIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentComplaintIntegrationTest.java @@ -16,7 +16,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; @@ -29,43 +28,45 @@ import de.tum.cit.aet.artemis.assessment.dto.ComplaintRequestDTO; import de.tum.cit.aet.artemis.assessment.dto.ComplaintResponseUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ComplaintResponseRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ComplaintResponseTestRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamFactory; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.SubmissionWithComplaintDTO; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AssessmentComplaintIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "assessmentcomplaintintegration"; @Autowired - private SubmissionRepository submissionRepo; + private SubmissionTestRepository submissionRepo; @Autowired private ComplaintRepository complaintRepo; @Autowired - private ComplaintResponseRepository complaintResponseRepo; + private ComplaintResponseTestRepository complaintResponseTestRepository; @Autowired private ExamRepository examRepository; @@ -356,7 +357,7 @@ void submitComplaintResponse_examExercise() throws Exception { assertThat(complaintRepo.findByResultId(textSubmission.getLatestResult().getId())).isPresent(); Complaint finalExamExerciseComplaint = examExerciseComplaint; - await().untilAsserted(() -> assertThat(complaintResponseRepo.findByComplaint_Id(finalExamExerciseComplaint.getId())).isPresent()); + await().untilAsserted(() -> assertThat(complaintResponseTestRepository.findByComplaintId(finalExamExerciseComplaint.getId())).isPresent()); } @Test @@ -421,7 +422,7 @@ void getComplaintByResultid_tutor_sensitiveDataHidden() throws Exception { void getComplaintByResultid_student_sensitiveDataHidden() throws Exception { complaint = complaintRepo.save(complaint); ComplaintResponse complaintResponse = complaintUtilService.createInitialEmptyResponse(TEST_PREFIX + "tutor2", complaint); - complaintResponseRepo.save(complaintResponse); + complaintResponseTestRepository.save(complaintResponse); final var params = new LinkedMultiValueMap(); params.add("submissionId", modelingSubmission.getId().toString()); diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentTeamComplaintIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentTeamComplaintIntegrationTest.java index 7ef8267ed785..9c27ccab0d46 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentTeamComplaintIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/AssessmentTeamComplaintIntegrationTest.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; import de.tum.cit.aet.artemis.assessment.domain.ComplaintType; @@ -26,19 +25,21 @@ import de.tum.cit.aet.artemis.assessment.dto.ComplaintRequestDTO; import de.tum.cit.aet.artemis.assessment.dto.ComplaintResponseUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.team.TeamUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AssessmentTeamComplaintIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -48,7 +49,7 @@ class AssessmentTeamComplaintIntegrationTest extends AbstractSpringIntegrationIn private ComplaintRepository complaintRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ModelingExerciseUtilService modelingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/bonus/BonusIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/BonusIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/bonus/BonusIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/BonusIntegrationTest.java index 5ca197382d45..5df20e1ba70d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/bonus/BonusIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/BonusIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.bonus; +package de.tum.cit.aet.artemis.assessment; import static org.assertj.core.api.Assertions.assertThat; @@ -16,9 +16,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleFactory; -import de.tum.cit.aet.artemis.assessment.GradingScaleUtilService; import de.tum.cit.aet.artemis.assessment.domain.Bonus; import de.tum.cit.aet.artemis.assessment.domain.BonusStrategy; import de.tum.cit.aet.artemis.assessment.domain.GradeStep; @@ -27,13 +24,17 @@ import de.tum.cit.aet.artemis.assessment.dto.BonusExampleDTO; import de.tum.cit.aet.artemis.assessment.repository.BonusRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; +import de.tum.cit.aet.artemis.assessment.util.BonusFactory; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleFactory; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class BonusIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintResponseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintResponseIntegrationTest.java index 7026c88294d5..d341e73a0166 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintResponseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintResponseIntegrationTest.java @@ -14,7 +14,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; import de.tum.cit.aet.artemis.assessment.domain.ComplaintType; @@ -22,18 +21,19 @@ import de.tum.cit.aet.artemis.assessment.dto.ComplaintAction; import de.tum.cit.aet.artemis.assessment.dto.ComplaintResponseUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ComplaintResponseRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ComplaintResponseTestRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class ComplaintResponseIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -45,13 +45,13 @@ class ComplaintResponseIntegrationTest extends AbstractSpringIntegrationIndepend private ParticipationService participationService; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ComplaintRepository complaintRepository; @Autowired - private ComplaintResponseRepository complaintResponseRepository; + private ComplaintResponseTestRepository complaintResponseTestRepository; private Complaint complaint; @@ -70,7 +70,7 @@ void initTestCase() throws Exception { textExercise = exerciseRepository.saveAndFlush(textExercise); // creating participation of student1 by starting the exercise - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); StudentParticipation studentParticipation = participationService.startExercise(textExercise, student1, false); // creating submission of student1 TextSubmission submission = new TextSubmission(); @@ -81,7 +81,7 @@ void initTestCase() throws Exception { submission.text("hello world"); submission = submissionRepository.saveAndFlush(submission); // creating assessment by tutor1 - User tutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User tutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); Result result = ParticipationFactory.generateResult(true, 50D); result.setAssessor(tutor1); result.setHasComplaint(true); @@ -136,7 +136,7 @@ void testAll_asStudent() throws Exception { @WithMockUser(username = TEST_PREFIX + "tutor2", roles = "TA") void createLock_noFailureCondition_shouldCreateEmptyComplaintResponse() throws Exception { request.postWithoutLocation("/api/complaints/" + complaint.getId() + "/response", null, HttpStatus.CREATED, null); - Optional optionalComplaintResponse = complaintResponseRepository.findByComplaint_Id(complaint.getId()); + Optional optionalComplaintResponse = complaintResponseTestRepository.findByComplaintId(complaint.getId()); assertThat(optionalComplaintResponse).isPresent(); ComplaintResponse complaintResponse = optionalComplaintResponse.get(); assertThat(complaintResponse.getComplaint().isAccepted()).isNull(); // not handled yet @@ -174,7 +174,7 @@ void createLock_alreadyResolved_shouldThrowIllegalArgumentException() throws Exc void createLock_alreadyConnectedToComplaintResponse_shouldThrowIllegalArgumentException() throws Exception { ComplaintResponse complaintResponse = new ComplaintResponse(); complaintResponse.setComplaint(complaint); - complaintResponseRepository.saveAndFlush(complaintResponse); + complaintResponseTestRepository.saveAndFlush(complaintResponse); ComplaintResponseUpdateDTO complaintResponseUpdate = new ComplaintResponseUpdateDTO(null, null, ComplaintAction.RESOLVE_COMPLAINT); request.patch("/api/complaints/" + complaint.getId() + "/response", complaintResponseUpdate, HttpStatus.INTERNAL_SERVER_ERROR); } @@ -214,7 +214,7 @@ void refreshLock_LockActiveBUTInitialCreatorOfLock_shouldRefreshLock() throws Ex } private void assertThatLockWasReplaced(ComplaintResponse originalLock, String loginOfNewLockCreator) { - Optional optionalComplaintResponse = complaintResponseRepository.findByComplaint_Id(complaint.getId()); + Optional optionalComplaintResponse = complaintResponseTestRepository.findByComplaintId(complaint.getId()); assertThat(optionalComplaintResponse).isPresent(); ComplaintResponse complaintResponse = optionalComplaintResponse.get(); assertThat(complaintResponse.getComplaint().isAccepted()).isNull(); // not handled yet @@ -223,7 +223,7 @@ private void assertThatLockWasReplaced(ComplaintResponse originalLock, String lo assertThat(complaintResponse.isCurrentlyLocked()).isTrue(); // should be locked now assertThat(complaintResponse.lockEndDate()).isNotNull(); // lock end date should be available assertThat(originalLock.getId()).isNotEqualTo(complaintResponse.getId()); // lock should have been replaced - assertThat(complaintResponseRepository.existsById(originalLock.getId())).isFalse(); // lock should have been replaced + assertThat(complaintResponseTestRepository.existsById(originalLock.getId())).isFalse(); // lock should have been replaced } @Test @@ -235,7 +235,7 @@ void refreshLock_LockStillActive_shouldThrowComplaintResponseLockedException() t ComplaintResponseUpdateDTO complaintResponseUpdate = new ComplaintResponseUpdateDTO(null, null, ComplaintAction.REFRESH_LOCK); request.patch("/api/complaints/" + complaint.getId() + "/response", complaintResponseUpdate, HttpStatus.BAD_REQUEST); // initial lock should still exist - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -252,7 +252,7 @@ void refreshLock_complaintDoesNotExist_shouldThrowIllegalArgumentException() thr assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isFalse(); ComplaintResponseUpdateDTO complaintResponseUpdate = new ComplaintResponseUpdateDTO(null, null, ComplaintAction.REFRESH_LOCK); request.patch("/api/complaints/" + 0 + "/response", complaintResponseUpdate, HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -264,7 +264,7 @@ void refreshLock_complaintAlreadyResolved_shouldThrowIllegalArgumentException() complaint = complaintRepository.saveAndFlush(complaint); ComplaintResponseUpdateDTO complaintResponseUpdate = new ComplaintResponseUpdateDTO(null, null, ComplaintAction.REFRESH_LOCK); request.patch("/api/complaints/" + complaint.getId() + "/response", complaintResponseUpdate, HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -274,7 +274,7 @@ void refreshLock_sameAsAssessor_shouldThrowAccessForbiddenException() throws Exc assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isFalse(); ComplaintResponseUpdateDTO complaintResponseUpdate = new ComplaintResponseUpdateDTO(null, null, ComplaintAction.REFRESH_LOCK); request.patch("/api/complaints/" + complaint.getId() + "/response", complaintResponseUpdate, HttpStatus.FORBIDDEN); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -283,10 +283,10 @@ void refreshLock_complaintResponseAlreadySubmitted_shouldThrowIllegalArgumentExc ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", true); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isFalse(); initialLockComplaintResponse.setSubmittedTime(ZonedDateTime.now()); - complaintResponseRepository.saveAndFlush(initialLockComplaintResponse); + complaintResponseTestRepository.saveAndFlush(initialLockComplaintResponse); ComplaintResponseUpdateDTO complaintResponseUpdate = new ComplaintResponseUpdateDTO(null, null, ComplaintAction.REFRESH_LOCK); request.patch("/api/complaints/" + complaint.getId() + "/response", complaintResponseUpdate, HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } // === TESTING REMOVE LOCK === @@ -297,7 +297,7 @@ void removeLock_creatorAndLockActive_shouldRemoveLock() throws Exception { ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", false); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.OK); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); } @Test @@ -306,7 +306,7 @@ void removeLock_creatorAndLockInactive_shouldRemoveLock() throws Exception { ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", true); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isFalse(); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.OK); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); } @Test @@ -315,7 +315,7 @@ void removeLock_notCreatorAndLockActive_shouldThrowComplaintResponseLockedExcept ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", false); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.BAD_REQUEST); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -324,7 +324,7 @@ void removeLock_notCreatorAndLockNotActive_shouldRemoveLock() throws Exception { ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", true); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isFalse(); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.OK); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); } @Test @@ -333,7 +333,7 @@ void removeLock_ComplaintNotFoundInDatabase_shouldThrowIllegalArgumentException( ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", false); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); request.delete("/api/complaints/" + 0 + "/response", HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -344,7 +344,7 @@ void removeLock_complaintIsAlreadyHandled_shouldThrowIllegalArgumentException() complaint.setAccepted(true); complaintRepository.saveAndFlush(complaint); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -359,9 +359,9 @@ void removeLock_complaintResponseIsAlreadySubmitted_shouldThrowIllegalArgumentEx ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", false); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); initialLockComplaintResponse.setSubmittedTime(ZonedDateTime.now()); - complaintResponseRepository.saveAndFlush(initialLockComplaintResponse); + complaintResponseTestRepository.saveAndFlush(initialLockComplaintResponse); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -370,7 +370,7 @@ void removeLock_IsAssessor_shouldThrowAccessForbiddenException() throws Exceptio ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor1", false); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.FORBIDDEN); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isTrue(); } @Test @@ -379,7 +379,7 @@ void removeLock_asInstructor_shouldRemoveLock() throws Exception { ComplaintResponse initialLockComplaintResponse = createLockOnComplaint(TEST_PREFIX + "tutor2", false); assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); request.delete("/api/complaints/" + complaint.getId() + "/response", HttpStatus.OK); - assertThat(complaintResponseRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); + assertThat(complaintResponseTestRepository.existsById(initialLockComplaintResponse.getId())).isFalse(); } // === TESTING RESOLVE COMPLAINT === @@ -432,7 +432,7 @@ void resolveComplaint_complaintResponseInDatabaseNotEmpty_shouldThrowIllegalArgu assertThat(initialLockComplaintResponse.isCurrentlyLocked()).isTrue(); initialLockComplaintResponse.setSubmittedTime(ZonedDateTime.now()); initialLockComplaintResponse.setResponseText("NotEmpty"); - complaintResponseRepository.saveAndFlush(initialLockComplaintResponse); + complaintResponseTestRepository.saveAndFlush(initialLockComplaintResponse); ComplaintResponseUpdateDTO initialLockComplaintResponseUpdated = new ComplaintResponseUpdateDTO("Accepted", true, ComplaintAction.RESOLVE_COMPLAINT); @@ -523,7 +523,7 @@ void resolveComplaint_LockActiveBUTCreatorOfLock_shouldResolve() throws Exceptio } private void validateThatComplaintIsResolved(String loginOfResolver) { - Optional optionalComplaintResponse = complaintResponseRepository.findByComplaint_Id(complaint.getId()); + Optional optionalComplaintResponse = complaintResponseTestRepository.findByComplaintId(complaint.getId()); assertThat(optionalComplaintResponse).isPresent(); ComplaintResponse complaintResponse = optionalComplaintResponse.get(); assertThat(complaintResponse.getComplaint().isAccepted()).isTrue(); @@ -535,9 +535,9 @@ private void validateThatComplaintIsResolved(String loginOfResolver) { private ComplaintResponse createLockOnComplaint(String lockOwnerLogin, boolean runOut) { ComplaintResponse complaintResponse = new ComplaintResponse(); complaintResponse.setComplaint(complaint); - User tutor = userRepository.findOneByLogin(lockOwnerLogin).orElseThrow(); + User tutor = userTestRepository.findOneByLogin(lockOwnerLogin).orElseThrow(); complaintResponse.setReviewer(tutor); - complaintResponse = complaintResponseRepository.saveAndFlush(complaintResponse); + complaintResponse = complaintResponseTestRepository.saveAndFlush(complaintResponse); // manually modifying the created date set by entity listener if (runOut) { diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/ExampleSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ExampleSubmissionIntegrationTest.java index b30771e42c5a..3125a5a7ebcd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/ExampleSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ExampleSubmissionIntegrationTest.java @@ -19,7 +19,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission; import de.tum.cit.aet.artemis.assessment.domain.Feedback; @@ -27,23 +26,24 @@ import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.dto.TextAssessmentDTO; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ExampleSubmissionIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -52,10 +52,10 @@ class ExampleSubmissionIntegrationTest extends AbstractSpringIntegrationIndepend private static final String TEST_PREFIX = "examplesubmissionintegration"; @Autowired - private GradingCriterionRepository gradingCriterionRepo; + private GradingCriterionRepository gradingCriterionRepository; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepo; + private ExampleSubmissionTestRepository exampleSubmissionRepository; @Autowired private ParticipationUtilService participationUtilService; @@ -99,7 +99,7 @@ void createAndUpdateExampleModelingSubmissionTutorial(boolean usedForTutorial) t ExampleSubmission.class, HttpStatus.OK); modelingExerciseUtilService.checkModelingSubmissionCorrectlyStored(returnedExampleSubmission.getSubmission().getId(), emptyModel); - Optional storedExampleSubmission = exampleSubmissionRepo.findBySubmissionId(returnedExampleSubmission.getSubmission().getId()); + Optional storedExampleSubmission = exampleSubmissionRepository.findBySubmissionId(returnedExampleSubmission.getSubmission().getId()); assertThat(storedExampleSubmission).as("example submission correctly stored").isPresent(); assertThat(storedExampleSubmission.orElseThrow().getSubmission().isExampleSubmission()).as("submission flagged as example submission").isTrue(); @@ -108,7 +108,7 @@ void createAndUpdateExampleModelingSubmissionTutorial(boolean usedForTutorial) t HttpStatus.OK); modelingExerciseUtilService.checkModelingSubmissionCorrectlyStored(returnedExampleSubmission.getSubmission().getId(), validModel); - storedExampleSubmission = exampleSubmissionRepo.findBySubmissionId(returnedExampleSubmission.getSubmission().getId()); + storedExampleSubmission = exampleSubmissionRepository.findBySubmissionId(returnedExampleSubmission.getSubmission().getId()); assertThat(storedExampleSubmission).as("example submission correctly stored").isPresent(); assertThat(storedExampleSubmission.orElseThrow().getSubmission().isExampleSubmission()).as("submission flagged as example submission").isTrue(); } @@ -124,7 +124,7 @@ void updateExampleModelingSubmission(boolean usedForTutorial) throws Exception { returnedExampleSubmission, ExampleSubmission.class, HttpStatus.OK); modelingExerciseUtilService.checkModelingSubmissionCorrectlyStored(updateExistingExampleSubmission.getSubmission().getId(), emptyModel); - Optional storedExampleSubmission = exampleSubmissionRepo.findBySubmissionId(updateExistingExampleSubmission.getSubmission().getId()); + Optional storedExampleSubmission = exampleSubmissionRepository.findBySubmissionId(updateExistingExampleSubmission.getSubmission().getId()); assertThat(storedExampleSubmission).as("example submission correctly stored").isPresent(); assertThat(storedExampleSubmission.orElseThrow().getSubmission().isExampleSubmission()).as("submission flagged as example submission").isTrue(); @@ -133,7 +133,7 @@ void updateExampleModelingSubmission(boolean usedForTutorial) throws Exception { updatedExampleSubmission, ExampleSubmission.class, HttpStatus.OK); modelingExerciseUtilService.checkModelingSubmissionCorrectlyStored(returnedUpdatedExampleSubmission.getSubmission().getId(), validModel); - storedExampleSubmission = exampleSubmissionRepo.findBySubmissionId(returnedUpdatedExampleSubmission.getSubmission().getId()); + storedExampleSubmission = exampleSubmissionRepository.findBySubmissionId(returnedUpdatedExampleSubmission.getSubmission().getId()); assertThat(storedExampleSubmission).as("example submission correctly stored").isPresent(); assertThat(storedExampleSubmission.orElseThrow().getSubmission().isExampleSubmission()).as("submission flagged as example submission").isTrue(); } @@ -148,12 +148,12 @@ void createAndDeleteExampleModelingSubmission(boolean usedForTutorial) throws Ex Long submissionId = returnedExampleSubmission.getSubmission().getId(); modelingExerciseUtilService.checkModelingSubmissionCorrectlyStored(submissionId, validModel); - Optional storedExampleSubmission = exampleSubmissionRepo.findBySubmissionId(submissionId); + Optional storedExampleSubmission = exampleSubmissionRepository.findBySubmissionId(submissionId); assertThat(storedExampleSubmission).as("example submission correctly stored").isPresent(); assertThat(storedExampleSubmission.orElseThrow().getSubmission().isExampleSubmission()).as("submission flagged as example submission").isTrue(); request.delete("/api/example-submissions/" + storedExampleSubmission.get().getId(), HttpStatus.OK); - assertThat(exampleSubmissionRepo.findAllByExerciseId(modelingExercise.getId())).isEmpty(); + assertThat(exampleSubmissionRepository.findAllByExerciseId(modelingExercise.getId())).isEmpty(); } @ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}") @@ -167,12 +167,12 @@ void createAndDeleteExampleModelingSubmissionWithResult(boolean usedForTutorial) Long submissionId = returnedExampleSubmission.getSubmission().getId(); modelingExerciseUtilService.checkModelingSubmissionCorrectlyStored(submissionId, validModel); - Optional storedExampleSubmission = exampleSubmissionRepo.findBySubmissionId(submissionId); + Optional storedExampleSubmission = exampleSubmissionRepository.findBySubmissionId(submissionId); assertThat(storedExampleSubmission).as("example submission correctly stored").isPresent(); assertThat(storedExampleSubmission.orElseThrow().getSubmission().isExampleSubmission()).as("submission flagged as example submission").isTrue(); request.delete("/api/example-submissions/" + storedExampleSubmission.get().getId(), HttpStatus.OK); - assertThat(exampleSubmissionRepo.findAllByExerciseId(modelingExercise.getId())).isEmpty(); + assertThat(exampleSubmissionRepository.findAllByExerciseId(modelingExercise.getId())).isEmpty(); } @Test @@ -293,7 +293,7 @@ void createExampleTextAssessmentNotExistentId() throws Exception { long randomId = 1233; request.putWithResponseBody("/api/exercises/" + textExercise.getId() + "/example-submissions/" + randomId + "/example-text-assessment", dto, Result.class, HttpStatus.NOT_FOUND); - assertThat(exampleSubmissionRepo.findBySubmissionId(randomId)).isEmpty(); + assertThat(exampleSubmissionRepository.findBySubmissionId(randomId)).isEmpty(); } @Test @@ -312,7 +312,7 @@ void createExampleTextAssessment_wrongExerciseId() throws Exception { long randomId = 1233; request.putWithResponseBody("/api/exercises/" + randomId + "/example-submissions/" + storedExampleSubmission.getId() + "/example-text-assessment", dto, Result.class, HttpStatus.BAD_REQUEST); - assertThat(exampleSubmissionRepo.findBySubmissionId(randomId)).isEmpty(); + assertThat(exampleSubmissionRepository.findBySubmissionId(randomId)).isEmpty(); } private ExampleSubmission importExampleSubmission(Long exerciseId, Long submissionId, HttpStatus expectedStatus) throws Exception { @@ -380,7 +380,7 @@ void importExampleSubmissionForTextExerciseCopiesGradingInstruction() throws Exc private void testGradingCriteriaAreImported(Exercise exercise) throws Exception { Set gradingCriteria = exerciseUtilService.addGradingInstructionsToExercise(exercise); - gradingCriterionRepo.saveAll(gradingCriteria); + gradingCriterionRepository.saveAll(gradingCriteria); var studentParticipation = participationUtilService.addAssessmentWithFeedbackWithGradingInstructionsForExercise(exercise, TEST_PREFIX + "instructor1"); Submission originalSubmission = studentParticipation.findLatestSubmission().orElseThrow(); Optional orginalResult = resultRepository.findDistinctWithFeedbackBySubmissionId(originalSubmission.getId()); diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/ExerciseScoresChartIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ExerciseScoresChartIntegrationTest.java index 7aecdc57d201..fd48d4a5ace5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/ExerciseScoresChartIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ExerciseScoresChartIntegrationTest.java @@ -17,7 +17,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.util.ReflectionTestUtils; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.repository.ParticipantScoreRepository; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.core.domain.Course; @@ -25,11 +24,12 @@ import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.dto.ExerciseScoresDTO; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ExerciseScoresChartIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -76,12 +76,12 @@ void setupTestScenario() { Exercise teamExercise = textExerciseUtilService.createTeamTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); idOfTeamTextExercise = teamExercise.getId(); - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); - User tutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User tutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); Long idOfTeam1 = teamUtilService.createTeam(Set.of(student1), tutor1, teamExercise, TEST_PREFIX + "team1").getId(); - User student2 = userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); - User student3 = userRepository.findOneByLogin(TEST_PREFIX + "student3").orElseThrow(); - User tutor2 = userRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); + User student2 = userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); + User student3 = userTestRepository.findOneByLogin(TEST_PREFIX + "student3").orElseThrow(); + User tutor2 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); Long idOfTeam2 = teamUtilService.createTeam(Set.of(student2, student3), tutor2, teamExercise, TEST_PREFIX + "team2").getId(); // Creating result for student1 diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/FeedbackTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/FeedbackTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/domain/FeedbackTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/FeedbackTest.java index 796f9dc0e946..03262ffc15bd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/FeedbackTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/FeedbackTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.assessment; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/GradeStepIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/GradeStepIntegrationTest.java index 793a6c77d053..9021848f5936 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/GradeStepIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/GradeStepIntegrationTest.java @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.GradeStep; import de.tum.cit.aet.artemis.assessment.domain.GradeType; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; @@ -21,15 +20,16 @@ import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class GradeStepIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -281,7 +281,7 @@ void testGetGradeStepByPercentageForCourse() throws Exception { TextExercise textExercise = textExerciseUtilService.createIndividualTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); Long individualTextExerciseId = textExercise.getId(); textExerciseUtilService.createIndividualTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); - User student = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); participationUtilService.createParticipationSubmissionAndResult(individualTextExerciseId, student, 10.0, 10.0, 70, true); GradeDTO foundGrade = request.get("/api/courses/" + course.getId() + "/grading-scale/match-grade-step?gradePercentage=70", HttpStatus.OK, GradeDTO.class); @@ -328,7 +328,7 @@ void testGetGradeStepForPlagiarismSpecialGradeForCourse() throws Exception { ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(5); TextExercise textExercise = textExerciseUtilService.createIndividualTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); Long individualTextExerciseId = textExercise.getId(); - User student = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); participationUtilService.createParticipationSubmissionAndResult(individualTextExerciseId, student, 10.0, 10.0, 50, true); var coursePlagiarismCase = new PlagiarismCase(); diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleIntegrationTest.java index 325318fbde75..ca84329ef52c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleIntegrationTest.java @@ -12,17 +12,18 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.GradeStep; import de.tum.cit.aet.artemis.assessment.domain.GradeType; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.dto.SortingOrder; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class GradingScaleIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -61,7 +62,7 @@ void init() { userUtilService.addUsers(TEST_PREFIX, 0, 0, 0, 1); var instructor = userUtilService.getUserByLogin(TEST_PREFIX + "instructor1"); instructor.setGroups(Set.of("gradingscaleintegrationinstructors")); - userRepository.save(instructor); + userTestRepository.save(instructor); course = courseUtilService.addEmptyCourse(); course.setInstructorGroupName("gradingscaleintegrationinstructors"); diff --git a/src/test/java/de/tum/cit/aet/artemis/LongFeedbackResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/LongFeedbackResourceIntegrationTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/LongFeedbackResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/LongFeedbackResourceIntegrationTest.java index de5cba8fc5ac..cd7d3c1c58db 100644 --- a/src/test/java/de/tum/cit/aet/artemis/LongFeedbackResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/LongFeedbackResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.assessment; import static org.assertj.core.api.Assertions.assertThat; @@ -12,9 +12,10 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LongFeedbackResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/ParticipantScoreIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ParticipantScoreIntegrationTest.java index a5d523e31d62..85f521f00be5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/ParticipantScoreIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ParticipantScoreIntegrationTest.java @@ -17,30 +17,31 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.util.ReflectionTestUtils; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.dto.score.ScoreDTO; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; import de.tum.cit.aet.artemis.assessment.repository.ParticipantScoreRepository; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleFactory; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ParticipantScoreIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -69,7 +70,7 @@ class ParticipantScoreIntegrationTest extends AbstractSpringIntegrationLocalCILo private LectureUnitRepository lectureUnitRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ParticipantScoreRepository participantScoreRepository; @@ -121,9 +122,9 @@ void setupTestScenario() { idOfIndividualTextExercise = textExercise.getId(); Exercise teamExercise = textExerciseUtilService.createTeamTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); idOfTeamTextExercise = teamExercise.getId(); - student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); - User tutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User tutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); Long idOfTeam1 = teamUtilService.createTeam(Set.of(student1), tutor1, teamExercise, TEST_PREFIX + "team1").getId(); // Creating result for student1 diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/RatingResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/RatingResourceIntegrationTest.java index 92d04ae92bdc..0c3bf8f70c9d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/RatingResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/RatingResourceIntegrationTest.java @@ -12,18 +12,18 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Rating; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.service.RatingService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class RatingResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/entitylistener/ResultListenerIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ResultListenerIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/entitylistener/ResultListenerIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/ResultListenerIntegrationTest.java index 8c1ec1ba3289..4877e18e8c99 100644 --- a/src/test/java/de/tum/cit/aet/artemis/entitylistener/ResultListenerIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ResultListenerIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.entitylistener; +package de.tum.cit.aet.artemis.assessment; import static de.tum.cit.aet.artemis.core.util.RoundingUtil.round; import static org.assertj.core.api.Assertions.assertThat; @@ -19,7 +19,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.util.ReflectionTestUtils; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.ParticipantScore; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.StudentScore; @@ -34,12 +33,13 @@ import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ResultListenerIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -54,7 +54,7 @@ class ResultListenerIntegrationTest extends AbstractSpringIntegrationLocalCILoca private Long idOfStudent1; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private StudentScoreRepository studentScoreRepository; @@ -94,7 +94,7 @@ void setupTestScenario() { ZonedDateTime pastAssessmentDueDate = ZonedDateTime.now().minusDays(2); userUtilService.addUsers(TEST_PREFIX, 1, 1, 0, 1); - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); idOfStudent1 = student1.getId(); // creating course Course course = courseUtilService.createCourse(); @@ -102,7 +102,7 @@ void setupTestScenario() { idOfIndividualTextExercise = textExercise.getId(); Exercise teamExercise = textExerciseUtilService.createTeamTextExercise(course, pastReleaseDate, pastDueDate, pastAssessmentDueDate); idOfTeamTextExercise = teamExercise.getId(); - User tutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User tutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); idOfTeam1 = teamUtilService.createTeam(Set.of(student1), tutor1, teamExercise, "team1").getId(); } @@ -406,7 +406,7 @@ private ParticipantScore setupTestScenarioWithOneResultSaved(boolean isRatedResu idOfExercise = idOfTeamTextExercise; } else { - participant = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + participant = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); idOfExercise = idOfIndividualTextExercise; } @@ -443,7 +443,7 @@ private void verifyStructureOfParticipantScoreInDatabase(boolean isTeamTest, Lon idOfExercise = idOfTeamTextExercise; } else { - participant = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + participant = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); idOfExercise = idOfIndividualTextExercise; } diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/ResultServiceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ResultServiceIntegrationTest.java index b0b28eb32133..c9ce9e923042 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/ResultServiceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ResultServiceIntegrationTest.java @@ -25,7 +25,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; @@ -35,46 +34,47 @@ import de.tum.cit.aet.artemis.assessment.dto.ResultWithPointsPerGradingCriterionDTO; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseFactory; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadExerciseRepository; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.SolutionProgrammingExerciseParticipation; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class ResultServiceIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -84,7 +84,7 @@ class ResultServiceIntegrationTest extends AbstractSpringIntegrationLocalCILocal private FeedbackRepository feedbackRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private SolutionProgrammingExerciseParticipationRepository solutionProgrammingExerciseRepository; @@ -93,7 +93,7 @@ class ResultServiceIntegrationTest extends AbstractSpringIntegrationLocalCILocal private ModelingExerciseRepository modelingExerciseRepository; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseRepository; @Autowired private FileUploadExerciseRepository fileUploadExerciseRepository; @@ -102,13 +102,13 @@ class ResultServiceIntegrationTest extends AbstractSpringIntegrationLocalCILocal private TextExerciseRepository textExerciseRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ExamRepository examRepository; @@ -569,7 +569,7 @@ void createResultForExternalSubmission_wrongExerciseId() throws Exception { @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void createResultForExternalSubmission_programmingExercise() throws Exception { var studentLogin = TEST_PREFIX + "student1"; - User user = userRepository.findOneByLogin(studentLogin).orElseThrow(); + User user = userTestRepository.findOneByLogin(studentLogin).orElseThrow(); mockConnectorRequestsForStartParticipation(programmingExercise, user.getParticipantIdentifier(), Set.of(user), true); Result result = new Result().rated(false); programmingExercise.setDueDate(ZonedDateTime.now().minusMinutes(5)); @@ -642,7 +642,7 @@ void testGetAssessmentCountByCorrectionRound() { // participation StudentParticipation studentParticipation = new StudentParticipation(); - studentParticipation.setParticipant(userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); + studentParticipation.setParticipant(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); studentParticipation.setExercise(textExercise); studentParticipationRepository.save(studentParticipation); @@ -689,7 +689,7 @@ void testGetAssessmentCountByCorrectionRoundForProgrammingExercise() { // participation ProgrammingExerciseStudentParticipation programmingExerciseStudentParticipation = new ProgrammingExerciseStudentParticipation(); - programmingExerciseStudentParticipation.setParticipant(userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); + programmingExerciseStudentParticipation.setParticipant(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); programmingExerciseStudentParticipation.setExercise(programmingExercise); programmingExerciseStudentParticipationRepository.save(programmingExerciseStudentParticipation); diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/ResultTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/ResultTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/domain/ResultTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/ResultTest.java index 957325d28775..b8214b3bfab2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/ResultTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/ResultTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.assessment; import static org.assertj.core.api.Assertions.assertThat; @@ -10,20 +10,20 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentNote; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; class ResultTest extends AbstractSpringIntegrationIndependentTest { @@ -37,7 +37,7 @@ class ResultTest extends AbstractSpringIntegrationIndependentTest { Double offsetByTenThousandth = 0.0001; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private CourseUtilService courseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.java index 76a3f0c9e21b..008eff5356b4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.java @@ -13,27 +13,27 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.dto.TutorEffortDTO; import de.tum.cit.aet.artemis.assessment.repository.TextAssessmentEventRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextAssessmentEvent; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class TutorEffortIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "tutoreffort"; // only lower case is supported @Autowired - private TextSubmissionRepository textSubmissionRepository; + private TextSubmissionTestRepository textSubmissionTestRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private TextAssessmentEventRepository textAssessmentEventRepository; @@ -57,10 +57,10 @@ void initTestCase() { course = courseUtilService.createCourseWithTextExerciseAndTutor(TEST_PREFIX + "tutor1"); exercise = course.getExercises().iterator().next(); studentParticipation = studentParticipationRepository.findByExerciseId(exercise.getId()).stream().iterator().next(); - textSubmission = textSubmissionRepository.findByParticipation_ExerciseIdAndSubmittedIsTrue(exercise.getId()).iterator().next(); + textSubmission = textSubmissionTestRepository.findByParticipation_ExerciseIdAndSubmittedIsTrue(exercise.getId()).iterator().next(); var instructor = userUtilService.createAndSaveUser(TEST_PREFIX + "instructor"); instructor.setGroups(Set.of(course.getInstructorGroupName())); - userRepository.save(instructor); + userTestRepository.save(instructor); } /** diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorLeaderboardServiceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorLeaderboardServiceIntegrationTest.java index 1f86f9c85d79..7e84fd63a28e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorLeaderboardServiceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorLeaderboardServiceIntegrationTest.java @@ -12,15 +12,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.service.TutorLeaderboardService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.dto.TutorLeaderboardDTO; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TutorLeaderboardServiceIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -53,7 +53,7 @@ void initTestCase() { for (int i = 1; i <= TUTOR_COUNT; i++) { var tutor = userUtilService.getUserByLogin(TEST_PREFIX + "tutor" + i); tutor.setGroups(Set.of("leaderboardgroup")); - userRepository.save(tutor); + userTestRepository.save(tutor); } var student1 = userUtilService.getUserByLogin(TEST_PREFIX + "student1"); var tutor1 = userUtilService.getUserByLogin(TEST_PREFIX + "tutor1"); diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationIntegrationTest.java index 5eea0d938b44..246f29ddad4f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationIntegrationTest.java @@ -16,7 +16,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; @@ -26,19 +25,20 @@ import de.tum.cit.aet.artemis.assessment.service.ResultService; import de.tum.cit.aet.artemis.assessment.service.TutorParticipationService; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseFactory; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.service.SubmissionService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseFactory; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorParticipationStatus; -import de.tum.cit.aet.artemis.util.TestResourceUtils; class TutorParticipationIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -66,7 +66,7 @@ class TutorParticipationIntegrationTest extends AbstractSpringIntegrationIndepen private ResultService resultService; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; private ModelingExercise modelingExercise; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationResourceIntegrationTest.java index e9ca776383c9..1178d65b8cee 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/TutorParticipationResourceIntegrationTest.java @@ -10,25 +10,25 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission; import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; -import de.tum.cit.aet.artemis.assessment.repository.TutorParticipationRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.TutorParticipationTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TutorParticipationResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "tutorparticipationresource"; @Autowired - private TutorParticipationRepository tutorParticipationRepository; + private TutorParticipationTestRepository tutorParticipationRepository; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepository; + private ExampleSubmissionTestRepository exampleSubmissionRepository; @Autowired private ParticipationUtilService participationUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ComplaintResponseServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/service/ComplaintResponseServiceTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/ComplaintResponseServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/service/ComplaintResponseServiceTest.java index 4fbcd4f99873..8b8c9e1e5387 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ComplaintResponseServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/service/ComplaintResponseServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.assessment.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -10,25 +10,24 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; -import de.tum.cit.aet.artemis.assessment.service.ComplaintResponseService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.Team; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ComplaintResponseServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -38,13 +37,13 @@ class ComplaintResponseServiceTest extends AbstractSpringIntegrationIndependentT private ComplaintResponseService complaintResponseService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private ComplaintRepository complaintRepository; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/CourseScoreCalculationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/CourseScoreCalculationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.java index 3f6a7f581b1c..89d594d99982 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/CourseScoreCalculationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.assessment.service; import static org.assertj.core.api.Assertions.assertThat; @@ -17,30 +17,29 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleFactory; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.dto.BonusSourceResultDTO; import de.tum.cit.aet.artemis.assessment.dto.MaxAndReachablePointsDTO; import de.tum.cit.aet.artemis.assessment.dto.score.StudentScoresDTO; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; -import de.tum.cit.aet.artemis.assessment.service.CourseScoreCalculationService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleFactory; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.CourseForDashboardDTO; import de.tum.cit.aet.artemis.core.dto.CourseScoresDTO; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class CourseScoreCalculationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -50,13 +49,13 @@ class CourseScoreCalculationServiceTest extends AbstractSpringIntegrationIndepen private ExerciseRepository exerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private CourseScoreCalculationService courseScoreCalculationService; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private GradingScaleRepository gradingScaleRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/FeedbackServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/service/FeedbackServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/FeedbackServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/service/FeedbackServiceTest.java index b02eef5a5283..5c93c12aaf9f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/FeedbackServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/service/FeedbackServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.assessment.service; import static org.assertj.core.api.Assertions.assertThat; @@ -7,13 +7,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.LongFeedbackText; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.assessment.repository.LongFeedbackTextRepository; -import de.tum.cit.aet.artemis.assessment.service.FeedbackService; import de.tum.cit.aet.artemis.core.config.Constants; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FeedbackServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/GradingScaleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/service/GradingScaleServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/GradingScaleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/service/GradingScaleServiceTest.java index d8bdeecf5648..e0ed3a9544a8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/GradingScaleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/service/GradingScaleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.assessment.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -15,21 +15,20 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleUtilService; import de.tum.cit.aet.artemis.assessment.domain.GradeStep; import de.tum.cit.aet.artemis.assessment.domain.GradeType; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; -import de.tum.cit.aet.artemis.assessment.service.GradingScaleService; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class GradingScaleServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ResultServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/assessment/service/ResultServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/ResultServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/service/ResultServiceTest.java index 0098b991c37d..82a9cd78f070 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ResultServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/service/ResultServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.assessment.service; import static org.assertj.core.api.Assertions.assertThat; @@ -12,32 +12,31 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.service.ResultService; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ResultServiceTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "resultservice"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ExamRepository examRepository; @@ -46,7 +45,7 @@ class ResultServiceTest extends AbstractSpringIntegrationIndependentTest { private ResultService resultService; @Autowired - private ProgrammingExerciseStudentParticipationRepository participationRepository; + private ProgrammingExerciseStudentParticipationTestRepository participationRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ComplaintResponseTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ComplaintResponseTestRepository.java new file mode 100644 index 000000000000..614567ef0271 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ComplaintResponseTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.assessment.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; +import de.tum.cit.aet.artemis.assessment.repository.ComplaintResponseRepository; + +@Repository +@Primary +public interface ComplaintResponseTestRepository extends ComplaintResponseRepository { + + Optional findByComplaintId(long complaintId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ExampleSubmissionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ExampleSubmissionTestRepository.java new file mode 100644 index 000000000000..b5146efb449c --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ExampleSubmissionTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.assessment.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission; +import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; + +@Repository +@Primary +public interface ExampleSubmissionTestRepository extends ExampleSubmissionRepository { + + Optional findBySubmissionId(long submissionId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ResultTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ResultTestRepository.java new file mode 100644 index 000000000000..52337290d051 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/ResultTestRepository.java @@ -0,0 +1,49 @@ +package de.tum.cit.aet.artemis.assessment.test_repository; + +import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; + +import java.util.Optional; +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.assessment.domain.Result; +import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; + +@Repository +@Primary +public interface ResultTestRepository extends ResultRepository { + + Set findAllByParticipationExerciseId(long exerciseId); + + @EntityGraph(type = LOAD, attributePaths = { "feedbacks" }) + Set findAllWithEagerFeedbackByAssessorIsNotNullAndParticipation_ExerciseIdAndCompletionDateIsNotNull(long exerciseId); + + Optional findDistinctBySubmissionId(long submissionId); + + @EntityGraph(type = LOAD, attributePaths = "feedbacks") + Optional findDistinctWithFeedbackBySubmissionId(long submissionId); + + default Result findFirstWithFeedbacksByParticipationIdOrderByCompletionDateDescElseThrow(long participationId) { + return getValueElseThrow(findFirstWithFeedbacksTestCasesByParticipationIdOrderByCompletionDateDesc(participationId)); + } + + /** + * Finds the first result by participation ID, including its submissions, ordered by completion date in descending order. + * This method avoids in-memory paging by retrieving the first result directly from the database. + * + * @param participationId the ID of the participation to find the result for + * @return an {@code Optional} containing the first {@code Result} with submissions, ordered by completion date in descending order, + * or an empty {@code Optional} if no result is found + */ + default Optional findFirstWithSubmissionsByParticipationIdOrderByCompletionDateDesc(long participationId) { + var resultOptional = findFirstByParticipationIdOrderByCompletionDateDesc(participationId); + if (resultOptional.isEmpty()) { + return Optional.empty(); + } + var id = resultOptional.get().getId(); + return findResultWithSubmissionsById(id); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/TutorParticipationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/TutorParticipationTestRepository.java new file mode 100644 index 000000000000..1b9ed7e34b87 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/test_repository/TutorParticipationTestRepository.java @@ -0,0 +1,21 @@ +package de.tum.cit.aet.artemis.assessment.test_repository; + +import java.util.List; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; +import de.tum.cit.aet.artemis.assessment.repository.TutorParticipationRepository; +import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.exercise.domain.Exercise; + +@Repository +@Primary +public interface TutorParticipationTestRepository extends TutorParticipationRepository { + + List findByAssessedExercise(Exercise assessedExercise); + + List findAllByAssessedExercise_Course(Course course); + +} diff --git a/src/test/java/de/tum/cit/aet/artemis/bonus/BonusFactory.java b/src/test/java/de/tum/cit/aet/artemis/assessment/util/BonusFactory.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/bonus/BonusFactory.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/util/BonusFactory.java index 3c8679064faa..c9e1bcefdb23 100644 --- a/src/test/java/de/tum/cit/aet/artemis/bonus/BonusFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/util/BonusFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.bonus; +package de.tum.cit.aet.artemis.assessment.util; import de.tum.cit.aet.artemis.assessment.domain.Bonus; import de.tum.cit.aet.artemis.assessment.domain.BonusStrategy; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintUtilService.java b/src/test/java/de/tum/cit/aet/artemis/assessment/util/ComplaintUtilService.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/util/ComplaintUtilService.java index 67072c4a38be..67c9274fa981 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/ComplaintUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/util/ComplaintUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.assessment; +package de.tum.cit.aet.artemis.assessment.util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -9,14 +9,14 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.dto.AssessmentUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ComplaintResponseRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ComplaintResponseTestRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; -import de.tum.cit.aet.artemis.user.UserUtilService; /** * Service responsible for initializing the database with specific testdata related to complaints for use in integration tests. @@ -28,16 +28,16 @@ public class ComplaintUtilService { private UserUtilService userUtilService; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultTestRepository; @Autowired private ComplaintRepository complaintRepo; @Autowired - private ComplaintResponseRepository complaintResponseRepo; + private ComplaintResponseTestRepository complaintResponseRepo; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; /** * Crates and saves a complaint and response for the given result and user. @@ -53,7 +53,7 @@ public class ComplaintUtilService { */ public void generateComplaintAndResponses(String userPrefix, int currentIndex, int numberOfComplaints, int numberComplaintResponses, boolean typeComplaint, Result result, User currentUser) { - result = resultRepo.save(result); + result = resultTestRepository.save(result); if (numberOfComplaints >= currentIndex) { Complaint complaint = typeComplaint ? new Complaint().complaintType(ComplaintType.COMPLAINT) : new Complaint().complaintType(ComplaintType.MORE_FEEDBACK); complaint.setResult(result); @@ -96,7 +96,7 @@ public ComplaintResponse createInitialEmptyResponse(String loginOfTutor, Complai public void addComplaints(String studentLogin, Participation participation, int numberOfComplaints, ComplaintType complaintType) { for (int i = 0; i < numberOfComplaints; i++) { Result dummyResult = new Result().participation(participation); - dummyResult = resultRepo.save(dummyResult); + dummyResult = resultTestRepository.save(dummyResult); Complaint complaint = new Complaint().participant(userUtilService.getUserByLogin(studentLogin)).result(dummyResult).complaintType(complaintType); complaintRepo.save(complaint); } @@ -113,7 +113,7 @@ public void addComplaintToSubmission(Submission submission, String userLogin, Co Result result = submission.getLatestResult(); if (result != null) { result.hasComplaint(true); - resultRepo.save(result); + resultTestRepository.save(result); } Complaint complaint = new Complaint().participant(userUtilService.getUserByLogin(userLogin)).result(result).complaintType(complaintType); complaintRepo.save(complaint); @@ -130,7 +130,7 @@ public void addComplaintToSubmission(Submission submission, String userLogin, Co public void addTeamComplaints(Team team, Participation participation, int numberOfComplaints, ComplaintType complaintType) { for (int i = 0; i < numberOfComplaints; i++) { Result dummyResult = new Result().participation(participation); - dummyResult = resultRepo.save(dummyResult); + dummyResult = resultTestRepository.save(dummyResult); Complaint complaint = new Complaint().participant(team).result(dummyResult).complaintType(complaintType); complaintRepo.save(complaint); } diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/GradingCriterionUtil.java b/src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingCriterionUtil.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/GradingCriterionUtil.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingCriterionUtil.java index 1ae76a4bb417..8302d9672147 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/GradingCriterionUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingCriterionUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise; +package de.tum.cit.aet.artemis.assessment.util; import java.util.Objects; import java.util.Optional; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleFactory.java b/src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingScaleFactory.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleFactory.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingScaleFactory.java index 7ff10a886970..71ffad9823c2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingScaleFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.assessment; +package de.tum.cit.aet.artemis.assessment.util; import de.tum.cit.aet.artemis.assessment.domain.GradeType; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; diff --git a/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleUtilService.java b/src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingScaleUtilService.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingScaleUtilService.java index 52d14ad44eb8..bd44eb0d28d6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/assessment/GradingScaleUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/util/GradingScaleUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.assessment; +package de.tum.cit.aet.artemis.assessment.util; import static org.assertj.core.api.Assertions.fail; diff --git a/src/test/java/de/tum/cit/aet/artemis/StudentScoreUtilService.java b/src/test/java/de/tum/cit/aet/artemis/assessment/util/StudentScoreUtilService.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/StudentScoreUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/assessment/util/StudentScoreUtilService.java index 5fab36709fcf..409c18fdc45d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/StudentScoreUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/assessment/util/StudentScoreUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.assessment.util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/src/test/java/de/tum/cit/aet/artemis/AbstractAthenaTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/AbstractAthenaTest.java similarity index 75% rename from src/test/java/de/tum/cit/aet/artemis/AbstractAthenaTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/AbstractAthenaTest.java index 07d6ded8d191..2936a760f6f0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/AbstractAthenaTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/AbstractAthenaTest.java @@ -1,10 +1,11 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.athena; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; /** * Base class for Athena tests providing common functionality diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/AthenaExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/AthenaExerciseIntegrationTest.java similarity index 89% rename from src/test/java/de/tum/cit/aet/artemis/exercise/AthenaExerciseIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/AthenaExerciseIntegrationTest.java index 13729c840e36..3597d9c89683 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/AthenaExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/AthenaExerciseIntegrationTest.java @@ -1,9 +1,9 @@ -package de.tum.cit.aet.artemis.exercise; +package de.tum.cit.aet.artemis.athena; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_TEXT_TEST; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -19,18 +19,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractAthenaTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseTestService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.CourseTestService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AthenaExerciseIntegrationTest extends AbstractAthenaTest { @@ -52,7 +51,7 @@ class AthenaExerciseIntegrationTest extends AbstractAthenaTest { private CourseTestService courseTestService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private TextExerciseRepository textExerciseRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/AthenaResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/AthenaResourceIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/exercise/AthenaResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/AthenaResourceIntegrationTest.java index 64bdfc14f6c3..c3a75a581447 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/AthenaResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/AthenaResourceIntegrationTest.java @@ -1,11 +1,11 @@ -package de.tum.cit.aet.artemis.exercise; - -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_MODELING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_MODELING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_TEXT_TEST; +package de.tum.cit.aet.artemis.athena; + +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_MODELING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_MODELING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_RESTRICTED_MODULE_TEXT_TEST; import static org.assertj.core.api.Assertions.assertThat; import java.time.ZonedDateTime; @@ -23,31 +23,30 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractAthenaTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.core.domain.Language; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; -import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.modeling.test_repository.ModelingSubmissionTestRepository; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AthenaResourceIntegrationTest extends AbstractAthenaTest { @@ -66,19 +65,19 @@ class AthenaResourceIntegrationTest extends AbstractAthenaTest { private ModelingExerciseUtilService modelingExerciseUtilService; @Autowired - private TextSubmissionRepository textSubmissionRepository; + private TextSubmissionTestRepository textSubmissionRepository; @Autowired private ProgrammingSubmissionTestRepository programmingSubmissionRepository; @Autowired - private ModelingSubmissionRepository modelingSubmissionRepository; + private ModelingSubmissionTestRepository modelingSubmissionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private TextExerciseRepository textExerciseRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaFeedbackSendingServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaFeedbackSendingServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaFeedbackSendingServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaFeedbackSendingServiceTest.java index c31ad49de404..eae7d0041044 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaFeedbackSendingServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaFeedbackSendingServiceTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.service.connectors.athena; +package de.tum.cit.aet.artemis.athena.service.connectors; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.when; import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath; @@ -15,7 +15,6 @@ import org.mockito.Mock; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractAthenaTest; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; @@ -23,22 +22,23 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; import de.tum.cit.aet.artemis.assessment.repository.TextBlockRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; +import de.tum.cit.aet.artemis.athena.AbstractAthenaTest; import de.tum.cit.aet.artemis.athena.service.AthenaDTOConverterService; import de.tum.cit.aet.artemis.athena.service.AthenaFeedbackSendingService; import de.tum.cit.aet.artemis.athena.service.AthenaModuleService; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AthenaFeedbackSendingServiceTest extends AbstractAthenaTest { @@ -52,7 +52,7 @@ class AthenaFeedbackSendingServiceTest extends AbstractAthenaTest { private TextExerciseRepository textExerciseRepository; @Mock - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Mock private GradingCriterionRepository gradingCriterionRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaFeedbackSuggestionsServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaFeedbackSuggestionsServiceTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaFeedbackSuggestionsServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaFeedbackSuggestionsServiceTest.java index 5bc53379f4fa..318495ba8ff5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaFeedbackSuggestionsServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaFeedbackSuggestionsServiceTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.service.connectors.athena; +package de.tum.cit.aet.artemis.athena.service.connectors; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath; @@ -13,19 +13,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractAthenaTest; +import de.tum.cit.aet.artemis.athena.AbstractAthenaTest; import de.tum.cit.aet.artemis.athena.dto.ProgrammingFeedbackDTO; import de.tum.cit.aet.artemis.athena.dto.TextFeedbackDTO; import de.tum.cit.aet.artemis.athena.service.AthenaFeedbackSuggestionsService; import de.tum.cit.aet.artemis.core.exception.ConflictException; import de.tum.cit.aet.artemis.core.exception.NetworkingException; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AthenaFeedbackSuggestionsServiceTest extends AbstractAthenaTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaHealthIndicatorTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaHealthIndicatorTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaHealthIndicatorTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaHealthIndicatorTest.java index 2290863e30b5..e3a2e2baac9d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaHealthIndicatorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaHealthIndicatorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.athena; +package de.tum.cit.aet.artemis.athena.service.connectors; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,7 @@ import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Status; -import de.tum.cit.aet.artemis.AbstractAthenaTest; +import de.tum.cit.aet.artemis.athena.AbstractAthenaTest; import de.tum.cit.aet.artemis.athena.config.AthenaHealthIndicator; class AthenaHealthIndicatorTest extends AbstractAthenaTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaRepositoryExportServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaRepositoryExportServiceTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaRepositoryExportServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaRepositoryExportServiceTest.java index 23182fb48c16..163d1821e1bc 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaRepositoryExportServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaRepositoryExportServiceTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.service.connectors.athena; +package de.tum.cit.aet.artemis.athena.service.connectors; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -16,18 +16,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.athena.service.AthenaRepositoryExportService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.exception.ServiceUnavailableException; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.RepositoryType; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AthenaRepositoryExportServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -40,7 +40,7 @@ class AthenaRepositoryExportServiceTest extends AbstractSpringIntegrationIndepen private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private AthenaRepositoryExportService athenaRepositoryExportService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaSubmissionSelectionServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaSubmissionSelectionServiceTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaSubmissionSelectionServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaSubmissionSelectionServiceTest.java index 57206c6a6b6f..f2ed2ede444d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaSubmissionSelectionServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaSubmissionSelectionServiceTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.service.connectors.athena; +package de.tum.cit.aet.artemis.athena.service.connectors; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -15,17 +15,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractAthenaTest; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; +import de.tum.cit.aet.artemis.athena.AbstractAthenaTest; import de.tum.cit.aet.artemis.athena.service.AthenaSubmissionSelectionService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AthenaSubmissionSelectionServiceTest extends AbstractAthenaTest { @@ -44,7 +44,7 @@ class AthenaSubmissionSelectionServiceTest extends AbstractAthenaTest { private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; private TextExercise textExercise; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaSubmissionSendingServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaSubmissionSendingServiceTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaSubmissionSendingServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaSubmissionSendingServiceTest.java index 74e0faa5835b..347fd6d328a9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/athena/AthenaSubmissionSendingServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/athena/service/connectors/AthenaSubmissionSendingServiceTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.service.connectors.athena; +package de.tum.cit.aet.artemis.athena.service.connectors; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath; @@ -11,21 +11,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractAthenaTest; +import de.tum.cit.aet.artemis.athena.AbstractAthenaTest; import de.tum.cit.aet.artemis.athena.service.AthenaDTOConverterService; import de.tum.cit.aet.artemis.athena.service.AthenaModuleService; import de.tum.cit.aet.artemis.athena.service.AthenaSubmissionSendingService; import de.tum.cit.aet.artemis.core.domain.Language; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AthenaSubmissionSendingServiceTest extends AbstractAthenaTest { @@ -38,7 +38,7 @@ class AthenaSubmissionSendingServiceTest extends AbstractAthenaTest { private static final String DEFAULT_SUBMISSION_TEXT = "This is a test submission."; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private AthenaModuleService athenaModuleService; @@ -53,7 +53,7 @@ class AthenaSubmissionSendingServiceTest extends AbstractAthenaTest { private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/AbstractCompetencyPrerequisiteIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/AbstractCompetencyPrerequisiteIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/competency/AbstractCompetencyPrerequisiteIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/AbstractCompetencyPrerequisiteIntegrationTest.java index 7b1bf0d4fb8f..899bcaa60ec7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/AbstractCompetencyPrerequisiteIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/AbstractCompetencyPrerequisiteIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; @@ -16,7 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyProgressUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.PrerequisiteUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.StandardizedCompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyRelation; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyTaxonomy; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; @@ -32,8 +34,6 @@ import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; @@ -44,7 +44,10 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; import de.tum.cit.aet.artemis.lecture.repository.TextUnitRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; abstract class AbstractCompetencyPrerequisiteIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/CompetencyIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/competency/CompetencyIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/CompetencyIntegrationTest.java index 99ce9e864b88..291f4065211c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/CompetencyIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency; import java.util.Collections; import java.util.List; @@ -13,6 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; import de.tum.cit.aet.artemis.atlas.dto.CompetencyImportResponseDTO; diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyJolIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/CompetencyJolIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/competency/CompetencyJolIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/CompetencyJolIntegrationTest.java index 4f7ae3b9818e..2df138a71271 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyJolIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/CompetencyJolIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency; import static org.assertj.core.api.Assertions.assertThat; @@ -13,12 +13,14 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyProgressUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyProgress; import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolPairDTO; import de.tum.cit.aet.artemis.atlas.repository.CompetencyJolRepository; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class CompetencyJolIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/CourseCompetencyIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/CourseCompetencyIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/competency/CourseCompetencyIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/CourseCompetencyIntegrationTest.java index a413ae808e1d..36c66c335239 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/CourseCompetencyIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/CourseCompetencyIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.within; @@ -19,9 +19,11 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; -import de.tum.cit.aet.artemis.StudentScoreUtilService; import de.tum.cit.aet.artemis.assessment.domain.Result; +import de.tum.cit.aet.artemis.assessment.util.StudentScoreUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyProgressUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.PrerequisiteUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyProgress; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyRelation; @@ -39,7 +41,9 @@ import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.CourseCompetencyProgressDTO; import de.tum.cit.aet.artemis.core.dto.SearchResultPageDTO; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; @@ -47,12 +51,12 @@ import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; @@ -63,15 +67,14 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.TextUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class CourseCompetencyIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -114,7 +117,7 @@ class CourseCompetencyIntegrationTest extends AbstractSpringIntegrationLocalCILo private PageableSearchUtilService pageableSearchUtilService; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ParticipationService participationService; @@ -363,7 +366,7 @@ class GetCompetencyCourseProgress { @Test @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void shouldGetCompetencyCourseProgressWhenTeamExercise() throws Exception { - User tutor = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User tutor = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); var teams = teamUtilService.addTeamsForExerciseFixedTeamSize(TEST_PREFIX, "lgi", teamTextExercise, 2, tutor, 1); createTextExerciseParticipationSubmissionAndResult(teamTextExercise, teams.getFirst(), 10.0, 0.0, 100, true); // will be ignored in favor of last submission from team @@ -382,9 +385,9 @@ void shouldGetCompetencyCourseProgressWhenTeamExercise() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void shouldGetCompetencyCourseProgress() throws Exception { - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); - User student2 = userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); - User instructor1 = userRepository.findOneByLogin(TEST_PREFIX + "instructor1").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student2 = userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); + User instructor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "instructor1").orElseThrow(); createTextExerciseParticipationSubmissionAndResult(textExercise, student1, 10.0, 0.0, 100, true); // will be ignored in favor of last submission from team createTextExerciseParticipationSubmissionAndResult(textExercise, student1, 10.0, 0.0, 50, false); @@ -414,7 +417,7 @@ void setupTestScenario() { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void getCompetencyStudentProgressShouldReturnProgress() throws Exception { - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); lectureUnitService.setLectureUnitCompletion(textUnitRepository.findById(idOfTextUnitOfLectureOne).orElseThrow(), student1, true); createTextExerciseParticipationSubmissionAndResult(textExercise, student1, 10.0, 0.0, 90, true); @@ -444,7 +447,7 @@ void getCompetencyStudentProgressMultipleExercises() throws Exception { // Therefore creating the participant scores manually participantScoreScheduleService.shutdown(); - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); Result textResult = createTextExerciseParticipationSubmissionAndResult(textExercise, student1, textExercise.getMaxPoints(), 0.0, 90, true); Result programming1Result = createProgrammingExerciseParticipationSubmissionAndResult(programmingExercises[0], student1, 85, true, 10); Result programming2Result = createProgrammingExerciseParticipationSubmissionAndResult(programmingExercises[1], student1, 75, false, 1); diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/PrerequisiteIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/PrerequisiteIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/competency/PrerequisiteIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/PrerequisiteIntegrationTest.java index edbbc3b5849d..d67697afba9c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/PrerequisiteIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/PrerequisiteIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency; import java.util.Collections; import java.util.List; @@ -13,6 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; +import de.tum.cit.aet.artemis.atlas.competency.util.PrerequisiteUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite; import de.tum.cit.aet.artemis.atlas.dto.CompetencyImportResponseDTO; diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/StandardizedCompetencyIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/StandardizedCompetencyIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/competency/StandardizedCompetencyIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/StandardizedCompetencyIntegrationTest.java index 27dd0bb81a9c..09c050bce269 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/StandardizedCompetencyIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/StandardizedCompetencyIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency; import static de.tum.cit.aet.artemis.atlas.domain.competency.StandardizedCompetency.FIRST_VERSION; import static org.assertj.core.api.Assertions.assertThat; @@ -17,7 +17,7 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.StandardizedCompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyTaxonomy; import de.tum.cit.aet.artemis.atlas.domain.competency.KnowledgeArea; @@ -33,6 +33,7 @@ import de.tum.cit.aet.artemis.atlas.repository.KnowledgeAreaRepository; import de.tum.cit.aet.artemis.atlas.repository.SourceRepository; import de.tum.cit.aet.artemis.atlas.repository.StandardizedCompetencyRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class StandardizedCompetencyIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyProgressUtilService.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/CompetencyProgressUtilService.java similarity index 86% rename from src/test/java/de/tum/cit/aet/artemis/competency/CompetencyProgressUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/CompetencyProgressUtilService.java index fb1161fc8f45..3fda78b8d7a8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyProgressUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/CompetencyProgressUtilService.java @@ -1,11 +1,11 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency.util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyProgress; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository; +import de.tum.cit.aet.artemis.atlas.test_repository.CompetencyProgressTestRepository; import de.tum.cit.aet.artemis.core.domain.User; /** @@ -15,7 +15,7 @@ public class CompetencyProgressUtilService { @Autowired - private CompetencyProgressRepository competencyProgressRepository; + private CompetencyProgressTestRepository competencyProgressRepository; /** * Creates Competency progress for given competency and user. diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyUtilService.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/CompetencyUtilService.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/competency/CompetencyUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/CompetencyUtilService.java index f8f6c3aa97c4..cd5121642ce2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/CompetencyUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/CompetencyUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency.util; import java.time.ZonedDateTime; diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/PrerequisiteUtilService.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/PrerequisiteUtilService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/competency/PrerequisiteUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/PrerequisiteUtilService.java index 476ec5598d77..e23ce52e6579 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/PrerequisiteUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/PrerequisiteUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency.util; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/StandardizedCompetencyUtilService.java b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/StandardizedCompetencyUtilService.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/competency/StandardizedCompetencyUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/StandardizedCompetencyUtilService.java index c8170df85953..1204f387aa78 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/StandardizedCompetencyUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/competency/util/StandardizedCompetencyUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.competency.util; import java.util.ArrayList; import java.util.stream.Stream; @@ -89,7 +89,7 @@ public static KnowledgeAreaRequestDTO toDTO(KnowledgeArea knowledgeArea) { return new KnowledgeAreaRequestDTO(knowledgeArea.getTitle(), knowledgeArea.getShortTitle(), knowledgeArea.getDescription(), parentId); } - static class CheckStandardizedCompetencyValidationProvider implements ArgumentsProvider { + public static class CheckStandardizedCompetencyValidationProvider implements ArgumentsProvider { @Override public Stream provideArguments(ExtensionContext extensionContext) { @@ -107,7 +107,7 @@ public Stream provideArguments(ExtensionContext extensionContext) { } } - static class CheckKnowledgeAreaValidationProvider implements ArgumentsProvider { + public static class CheckKnowledgeAreaValidationProvider implements ArgumentsProvider { @Override public Stream provideArguments(ExtensionContext extensionContext) { diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/LearningPathIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/learningpath/LearningPathIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/competency/LearningPathIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/learningpath/LearningPathIntegrationTest.java index 1d3db7ad24e7..fb0bf6dcb286 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/LearningPathIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/learningpath/LearningPathIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.learningpath; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; @@ -23,10 +23,10 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.StudentScoreUtilService; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; +import de.tum.cit.aet.artemis.assessment.util.StudentScoreUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.LearningObject; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyRelation; @@ -42,24 +42,26 @@ import de.tum.cit.aet.artemis.atlas.dto.LearningPathNavigationObjectDTO; import de.tum.cit.aet.artemis.atlas.dto.LearningPathNavigationOverviewDTO; import de.tum.cit.aet.artemis.atlas.dto.NgxLearningPathDTO; -import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository; +import de.tum.cit.aet.artemis.atlas.learningpath.util.LearningPathUtilService; import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository; -import de.tum.cit.aet.artemis.atlas.repository.LearningPathRepository; import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; +import de.tum.cit.aet.artemis.atlas.test_repository.CompetencyProgressTestRepository; +import de.tum.cit.aet.artemis.atlas.test_repository.LearningPathTestRepository; import de.tum.cit.aet.artemis.atlas.web.LearningPathResource; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.TextUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class LearningPathIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -72,7 +74,7 @@ class LearningPathIntegrationTest extends AbstractSpringIntegrationIndependentTe private PageableSearchUtilService pageableSearchUtilService; @Autowired - private LearningPathRepository learningPathRepository; + private LearningPathTestRepository learningPathRepository; @Autowired private TextExerciseUtilService textExerciseUtilService; @@ -96,7 +98,7 @@ class LearningPathIntegrationTest extends AbstractSpringIntegrationIndependentTe private LearningPathUtilService learningPathUtilService; @Autowired - private CompetencyProgressRepository competencyProgressRepository; + private CompetencyProgressTestRepository competencyProgressRepository; @Autowired private CompetencyRelationRepository competencyRelationRepository; @@ -156,7 +158,7 @@ void setupTestScenario() throws Exception { lecture.setCourse(course); lectureRepository.save(lecture); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); textUnit = createAndLinkTextUnit(student, competencies[0], true); textExercise = createAndLinkTextExercise(competencies[1], false); @@ -269,11 +271,11 @@ void testEnableLearningPathsAlreadyEnabled() throws Exception { void testGenerateMissingLearningPathsForCourse() throws Exception { course.setLearningPathsEnabled(true); courseRepository.save(course); - final var students = userRepository.getStudents(course); - students.stream().map(User::getId).map(userRepository::findWithLearningPathsByIdElseThrow).forEach(learningPathUtilService::deleteLearningPaths); + final var students = userTestRepository.getStudents(course); + students.stream().map(User::getId).map(userTestRepository::findWithLearningPathsByIdElseThrow).forEach(learningPathUtilService::deleteLearningPaths); request.put("/api/courses/" + course.getId() + "/learning-paths/generate-missing", null, HttpStatus.OK); students.forEach(user -> { - user = userRepository.findWithLearningPathsByIdElseThrow(user.getId()); + user = userTestRepository.findWithLearningPathsByIdElseThrow(user.getId()); assertThat(user.getLearningPaths()).hasSize(1); }); @@ -295,7 +297,7 @@ void testGenerateLearningPathOnEnrollment() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); request.postWithResponseBody("/api/courses/" + course.getId() + "/enroll", null, Set.class, HttpStatus.OK); - final var user = userRepository.findOneWithLearningPathsByLogin(TEST_PREFIX + "student1337").orElseThrow(); + final var user = userTestRepository.findOneWithLearningPathsByLogin(TEST_PREFIX + "student1337").orElseThrow(); assertThat(user.getLearningPaths()).isNotNull(); assertThat(user.getLearningPaths().size()).as("should create LearningPath for student").isEqualTo(1); @@ -357,7 +359,7 @@ void addCompetencyToLearningPaths(Function competencyProgressService.updateCompetencyProgress(competency.getId(), student)); @@ -489,7 +491,7 @@ void testGetLearningPathCompetencyGraph() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningPathNgxForLearningPathsDisabled(LearningPathResource.NgxRequestType type) throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); course.setLearningPathsEnabled(false); courseRepository.save(course); @@ -501,7 +503,7 @@ void testGetLearningPathNgxForLearningPathsDisabled(LearningPathResource.NgxRequ @WithMockUser(username = TEST_PREFIX + "student2", roles = "USER") void testGetLearningPathNgxForOtherStudent(LearningPathResource.NgxRequestType type) throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); request.get("/api/learning-path/" + learningPath.getId() + "/" + type, HttpStatus.FORBIDDEN, NgxLearningPathDTO.class); } @@ -517,7 +519,7 @@ void testGetLearningPathNgxForOtherStudent(LearningPathResource.NgxRequestType t @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningPathNgxAsStudent(LearningPathResource.NgxRequestType type) throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); request.get("/api/learning-path/" + learningPath.getId() + "/" + type, HttpStatus.OK, NgxLearningPathDTO.class); } @@ -533,7 +535,7 @@ void testGetLearningPathNgxAsStudent(LearningPathResource.NgxRequestType type) t @WithMockUser(username = TUTOR_OF_COURSE, roles = "TA") void testGetLearningPathNgxAsTutor(LearningPathResource.NgxRequestType type) throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var tutor = userRepository.findOneByLogin(TUTOR_OF_COURSE).orElseThrow(); + final var tutor = userTestRepository.findOneByLogin(TUTOR_OF_COURSE).orElseThrow(); final var learningPath = learningPathUtilService.createLearningPathInCourseForUser(course, tutor); request.get("/api/learning-path/" + learningPath.getId() + "/" + type, HttpStatus.OK, NgxLearningPathDTO.class); } @@ -549,7 +551,7 @@ void testGetLearningPathNgxAsTutor(LearningPathResource.NgxRequestType type) thr @WithMockUser(username = EDITOR_OF_COURSE, roles = "EDITOR") void testGetLearningPathNgxAsEditor(LearningPathResource.NgxRequestType type) throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var editor = userRepository.findOneByLogin(EDITOR_OF_COURSE).orElseThrow(); + final var editor = userTestRepository.findOneByLogin(EDITOR_OF_COURSE).orElseThrow(); final var learningPath = learningPathUtilService.createLearningPathInCourseForUser(course, editor); request.get("/api/learning-path/" + learningPath.getId() + "/" + type, HttpStatus.OK, NgxLearningPathDTO.class); } @@ -565,7 +567,7 @@ void testGetLearningPathNgxAsEditor(LearningPathResource.NgxRequestType type) th @WithMockUser(username = INSTRUCTOR_OF_COURSE, roles = "INSTRUCTOR") void testGetLearningPathNgxAsInstructor(LearningPathResource.NgxRequestType type) throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); request.get("/api/learning-path/" + learningPath.getId() + "/" + type, HttpStatus.OK, NgxLearningPathDTO.class); } @@ -577,7 +579,7 @@ class GetLearningPathId { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void shouldReturnExistingId() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); final var result = request.get("/api/courses/" + course.getId() + "/learning-path-id", HttpStatus.OK, Long.class); assertThat(result).isEqualTo(learningPath.getId()); @@ -588,8 +590,8 @@ void shouldReturnExistingId() throws Exception { void shouldReturnNotFoundIfNotExists() throws Exception { course.setLearningPathsEnabled(true); course = courseRepository.save(course); - var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); - student = userRepository.findWithLearningPathsByIdElseThrow(student.getId()); + var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + student = userTestRepository.findWithLearningPathsByIdElseThrow(student.getId()); learningPathRepository.deleteAll(student.getLearningPaths()); request.get("/api/courses/" + course.getId() + "/learning-path-id", HttpStatus.NOT_FOUND, Long.class); } @@ -618,7 +620,7 @@ void shouldGenerateLearningPath() throws Exception { course = courseRepository.save(course); final var response = request.postWithResponseBody("/api/courses/" + course.getId() + "/learning-path", null, Long.class, HttpStatus.CREATED); assertThat(response).isNotNull(); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); assertThat(learningPath).isNotNull(); } @@ -628,7 +630,7 @@ void shouldGenerateLearningPath() throws Exception { @WithMockUser(username = TEST_PREFIX + "student2", roles = "USER") void testGetCompetencyProgressForLearningPathByOtherStudent() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); request.get("/api/learning-path/" + learningPath.getId() + "/competency-progress", HttpStatus.FORBIDDEN, Set.class); } @@ -649,7 +651,7 @@ void testGetCompetencyProgressForLearningPathByInstructor() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningPathNavigation() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); competencyProgressService.updateProgressByLearningObjectSync(textUnit, Set.of(student)); @@ -664,7 +666,7 @@ void testGetLearningPathNavigation() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningPathNavigationEmptyCompetencies() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); textExercise.setCompetencies(Set.of()); @@ -689,7 +691,7 @@ void testGetLearningPathNavigationEmptyCompetencies() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningPathNavigationDoesNotLeakUnreleasedLearningObjects() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); textExercise.setCompetencies(Set.of()); @@ -737,7 +739,7 @@ private void verifyNavigationObjectResult(LearningObject expectedObject, Learnin @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetRelativeLearningPathNavigation() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); final var result = request.get("/api/learning-path/" + learningPath.getId() + "/relative-navigation?learningObjectId=" + textUnit.getId() + "&learningObjectType=" + LearningPathNavigationObjectDTO.LearningObjectType.LECTURE + "&competencyId=" + competencies[0].getId(), HttpStatus.OK, LearningPathNavigationDTO.class); @@ -751,7 +753,7 @@ void testGetRelativeLearningPathNavigation() throws Exception { @WithMockUser(username = TEST_PREFIX + "student1337", roles = "USER") void testGetLearningPathNavigationForOtherStudent() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); request.get("/api/learning-path/" + learningPath.getId() + "/navigation", HttpStatus.FORBIDDEN, LearningPathNavigationDTO.class); } @@ -760,7 +762,7 @@ void testGetLearningPathNavigationForOtherStudent() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningPathNavigationOverview() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); final var result = request.get("/api/learning-path/" + learningPath.getId() + "/navigation-overview", HttpStatus.OK, LearningPathNavigationOverviewDTO.class); @@ -774,7 +776,7 @@ void testGetLearningPathNavigationOverview() throws Exception { @WithMockUser(username = TEST_PREFIX + "student1337", roles = "USER") void testGetLearningPathNavigationOverviewForOtherStudent() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); request.get("/api/learning-path/" + learningPath.getId() + "/navigation-overview", HttpStatus.FORBIDDEN, LearningPathNavigationOverviewDTO.class); } @@ -783,7 +785,7 @@ void testGetLearningPathNavigationOverviewForOtherStudent() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetCompetencyOrderForLearningPath() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); final var result = request.getList("/api/learning-path/" + learningPath.getId() + "/competencies", HttpStatus.OK, CompetencyNameDTO.class); assertThat(result).containsExactlyElementsOf(Arrays.stream(competencies).map(CompetencyNameDTO::of).toList()); @@ -793,7 +795,7 @@ void testGetCompetencyOrderForLearningPath() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningObjectsForCompetency() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); var result = request.getList("/api/learning-path/" + learningPath.getId() + "/competencies/" + competencies[0].getId() + "/learning-objects", HttpStatus.OK, LearningPathNavigationObjectDTO.class); @@ -810,7 +812,7 @@ void testGetLearningObjectsForCompetency() throws Exception { @WithMockUser(username = STUDENT_OF_COURSE, roles = "USER") void testGetLearningObjectsForCompetencyMultipleObjects() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); List completedLectureUnits = List.of(createAndLinkTextUnit(student, competencies[4], true), createAndLinkTextUnit(student, competencies[4], true)); @@ -841,7 +843,7 @@ void testGetLearningObjectsForCompetencyMultipleObjects() throws Exception { void testGetCompetencyProgressForLearningPath() throws Exception { course = learningPathUtilService.enableAndGenerateLearningPathsForCourse(course); - final var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + final var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); final var learningPath = learningPathRepository.findByCourseIdAndUserIdElseThrow(course.getId(), student.getId()); final var result = request.get("/api/learning-path/" + learningPath.getId() + "/competency-progress", HttpStatus.OK, Set.class); assertThat(result).hasSize(5); @@ -852,7 +854,7 @@ private TextExercise createAndLinkTextExercise(Competency competency, boolean wi Set gradingCriteria = exerciseUtilService.addGradingInstructionsToExercise(textExercise); gradingCriterionRepository.saveAll(gradingCriteria); if (withAssessment) { - var student = userRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); + var student = userTestRepository.findOneByLogin(STUDENT_OF_COURSE).orElseThrow(); studentScoreUtilService.createStudentScore(textExercise, student, 100.0); } competencyUtilService.linkExerciseToCompetency(competency, textExercise); diff --git a/src/test/java/de/tum/cit/aet/artemis/competency/LearningPathUtilService.java b/src/test/java/de/tum/cit/aet/artemis/atlas/learningpath/util/LearningPathUtilService.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/competency/LearningPathUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/learningpath/util/LearningPathUtilService.java index b1ca5b684a7b..fc922e932d68 100644 --- a/src/test/java/de/tum/cit/aet/artemis/competency/LearningPathUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/learningpath/util/LearningPathUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.competency; +package de.tum.cit.aet.artemis.atlas.learningpath.util; import java.util.Set; @@ -9,11 +9,11 @@ import de.tum.cit.aet.artemis.atlas.domain.competency.LearningPath; import de.tum.cit.aet.artemis.atlas.repository.CompetencyRepository; import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository; -import de.tum.cit.aet.artemis.atlas.repository.LearningPathRepository; import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService; +import de.tum.cit.aet.artemis.atlas.test_repository.LearningPathTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; /** * Service responsible for initializing the database with specific testdata related to learning paths for use in integration tests. @@ -22,13 +22,13 @@ public class LearningPathUtilService { @Autowired - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; @Autowired private LearningPathService learningPathService; @Autowired - private LearningPathRepository learningPathRepository; + private LearningPathTestRepository learningPathRepository; @Autowired private CompetencyRepository competencyRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/science/ScienceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/science/ScienceIntegrationTest.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/science/ScienceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/science/ScienceIntegrationTest.java index 9105429b6126..a4ac82d52470 100644 --- a/src/test/java/de/tum/cit/aet/artemis/science/ScienceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/science/ScienceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.science; +package de.tum.cit.aet.artemis.atlas.science; import static org.assertj.core.api.Assertions.assertThat; @@ -11,17 +11,17 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEventType; import de.tum.cit.aet.artemis.atlas.dto.ScienceEventDTO; -import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository; +import de.tum.cit.aet.artemis.atlas.test_repository.ScienceEventTestRepository; import de.tum.cit.aet.artemis.core.service.feature.Feature; import de.tum.cit.aet.artemis.core.service.feature.FeatureToggleService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ScienceIntegrationTest extends AbstractSpringIntegrationIndependentTest { @Autowired - private ScienceEventRepository scienceEventRepository; + private ScienceEventTestRepository scienceEventRepository; @Autowired private FeatureToggleService featureToggleService; diff --git a/src/test/java/de/tum/cit/aet/artemis/science/ScienceSettingsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/science/ScienceSettingsIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/science/ScienceSettingsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/science/ScienceSettingsIntegrationTest.java index 9681adb42498..c1657bd2a391 100644 --- a/src/test/java/de/tum/cit/aet/artemis/science/ScienceSettingsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/science/ScienceSettingsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.science; +package de.tum.cit.aet.artemis.atlas.science; import static org.assertj.core.api.Assertions.assertThat; @@ -11,10 +11,10 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceSetting; import de.tum.cit.aet.artemis.atlas.repository.ScienceSettingRepository; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ScienceSettingsIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/science/ScienceUtilService.java b/src/test/java/de/tum/cit/aet/artemis/atlas/science/util/ScienceUtilService.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/science/ScienceUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/science/util/ScienceUtilService.java index b844e00e5d5a..fc40cb1a18dc 100644 --- a/src/test/java/de/tum/cit/aet/artemis/science/ScienceUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/science/util/ScienceUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.science; +package de.tum.cit.aet.artemis.atlas.science.util; import java.time.Duration; import java.time.ZonedDateTime; @@ -9,13 +9,13 @@ import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEventType; -import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository; +import de.tum.cit.aet.artemis.atlas.test_repository.ScienceEventTestRepository; @Service public class ScienceUtilService { @Autowired - private ScienceEventRepository scienceEventRepository; + private ScienceEventTestRepository scienceEventRepository; /** * Creates a science event with the passed type and resource id. diff --git a/src/test/java/de/tum/cit/aet/artemis/service/LearningObjectServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/service/LearningObjectServiceTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/service/LearningObjectServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/service/LearningObjectServiceTest.java index 35509630a95e..d6a8f34228a2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/LearningObjectServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/service/LearningObjectServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.atlas.service; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; @@ -14,19 +14,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.StudentScoreUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; +import de.tum.cit.aet.artemis.assessment.util.StudentScoreUtilService; import de.tum.cit.aet.artemis.atlas.domain.LearningObject; import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.lecture.service.LearningObjectService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LearningObjectServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/LearningPathServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/atlas/service/LearningPathServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/LearningPathServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/atlas/service/LearningPathServiceTest.java index 902ac5f916bb..6717bbd6b508 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/LearningPathServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/service/LearningPathServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.atlas.service; import static org.assertj.core.api.Assertions.assertThat; @@ -18,36 +18,36 @@ import org.junit.jupiter.params.provider.MethodSource; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.StudentScoreUtilService; +import de.tum.cit.aet.artemis.assessment.util.StudentScoreUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyProgressUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.LearningObject; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.LearningPath; import de.tum.cit.aet.artemis.atlas.domain.competency.RelationType; import de.tum.cit.aet.artemis.atlas.dto.LearningPathHealthDTO; import de.tum.cit.aet.artemis.atlas.dto.NgxLearningPathDTO; +import de.tum.cit.aet.artemis.atlas.learningpath.util.LearningPathUtilService; import de.tum.cit.aet.artemis.atlas.repository.CompetencyRepository; import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathNgxService; import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathRecommendationService; import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService; import de.tum.cit.aet.artemis.atlas.web.LearningPathResource; -import de.tum.cit.aet.artemis.competency.CompetencyProgressUtilService; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; -import de.tum.cit.aet.artemis.competency.LearningPathUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LearningPathServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/CompetencyProgressTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/CompetencyProgressTestRepository.java new file mode 100644 index 000000000000..4297aa442385 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/CompetencyProgressTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.atlas.test_repository; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyProgress; +import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository; + +@Repository +@Primary +public interface CompetencyProgressTestRepository extends CompetencyProgressRepository { + + default CompetencyProgress findByCompetencyIdAndUserIdOrElseThrow(long competencyId, long userId) { + return getValueElseThrow(findByCompetencyIdAndUserId(competencyId, userId)); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/LearningPathTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/LearningPathTestRepository.java new file mode 100644 index 000000000000..630fbe4965d3 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/LearningPathTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.atlas.test_repository; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.atlas.domain.competency.LearningPath; +import de.tum.cit.aet.artemis.atlas.repository.LearningPathRepository; + +@Repository +@Primary +public interface LearningPathTestRepository extends LearningPathRepository { + + default LearningPath findWithEagerCompetenciesByCourseIdAndUserIdElseThrow(long courseId, long userId) { + return getValueElseThrow(findWithEagerCompetenciesByCourseIdAndUserId(courseId, userId)); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/ScienceEventTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/ScienceEventTestRepository.java new file mode 100644 index 000000000000..973601c0b589 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/atlas/test_repository/ScienceEventTestRepository.java @@ -0,0 +1,17 @@ +package de.tum.cit.aet.artemis.atlas.test_repository; + +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; +import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEventType; +import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository; + +@Repository +@Primary +public interface ScienceEventTestRepository extends ScienceEventRepository { + + Set findAllByType(ScienceEventType type); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/localci/buildagent/TestResultXmlParserTest.java b/src/test/java/de/tum/cit/aet/artemis/buildagent/service/connectors/localci/TestResultXmlParserTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/localci/buildagent/TestResultXmlParserTest.java rename to src/test/java/de/tum/cit/aet/artemis/buildagent/service/connectors/localci/TestResultXmlParserTest.java index 56ea258e9952..083e6ac0a047 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/localci/buildagent/TestResultXmlParserTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/buildagent/service/connectors/localci/TestResultXmlParserTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.localci.buildagent; +package de.tum.cit.aet.artemis.buildagent.service.connectors.localci; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/AbstractConversationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/AbstractConversationTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/metis/AbstractConversationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/AbstractConversationTest.java index d12bf29a6baa..f068806af671 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/AbstractConversationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/AbstractConversationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -18,7 +18,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; import de.tum.cit.aet.artemis.communication.domain.DisplayPriority; import de.tum.cit.aet.artemis.communication.domain.Post; @@ -28,19 +27,20 @@ import de.tum.cit.aet.artemis.communication.dto.MetisCrudAction; import de.tum.cit.aet.artemis.communication.dto.PostContextFilterDTO; import de.tum.cit.aet.artemis.communication.repository.ConversationMessageRepository; -import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.GroupChatRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.OneToOneChatRepository; import de.tum.cit.aet.artemis.communication.service.conversation.ConversationService; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationParticipantTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.OneToOneChatTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * Contains useful methods for testing the conversations futures @@ -48,16 +48,16 @@ abstract class AbstractConversationTest extends AbstractSpringIntegrationIndependentTest { @Autowired - CourseRepository courseRepository; + CourseTestRepository courseRepository; @Autowired - UserRepository userRepository; + UserTestRepository userRepository; @Autowired - ConversationRepository conversationRepository; + ConversationTestRepository conversationRepository; @Autowired - ConversationParticipantRepository conversationParticipantRepository; + ConversationParticipantTestRepository conversationParticipantRepository; @Autowired ChannelRepository channelRepository; @@ -66,7 +66,7 @@ abstract class AbstractConversationTest extends AbstractSpringIntegrationIndepen GroupChatRepository groupChatRepository; @Autowired - OneToOneChatRepository oneToOneChatRepository; + OneToOneChatTestRepository oneToOneChatRepository; @Autowired ConversationMessageRepository conversationMessageRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/AnswerMessageIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/AnswerMessageIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/metis/AnswerMessageIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/AnswerMessageIntegrationTest.java index a47ab459a3db..6d1f0520110f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/AnswerMessageIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/AnswerMessageIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -15,6 +15,7 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -24,7 +25,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.NotificationType; import de.tum.cit.aet.artemis.communication.domain.Post; @@ -33,15 +33,16 @@ import de.tum.cit.aet.artemis.communication.dto.PostDTO; import de.tum.cit.aet.artemis.communication.repository.AnswerPostRepository; import de.tum.cit.aet.artemis.communication.repository.ConversationMessageRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AnswerMessageIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -155,6 +156,7 @@ void testCreateAnswerInExerciseChannel() throws Exception { } @Test + @Disabled // ToDo: Find out why "JsonException No _valueDeserializer assigned" is thrown when running the whole test suite @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testCreateAnswerInExamChannel() throws Exception { Course course = courseRepository.findByIdElseThrow(courseId); diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/ChannelIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/ChannelIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/metis/ChannelIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/ChannelIntegrationTest.java index 7d0f15fec1d8..80fb86f7e167 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/ChannelIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/ChannelIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; @@ -23,27 +23,27 @@ import de.tum.cit.aet.artemis.communication.dto.ChannelDTO; import de.tum.cit.aet.artemis.communication.dto.ChannelIdAndNameDTO; import de.tum.cit.aet.artemis.communication.dto.MetisCrudAction; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; import de.tum.cit.aet.artemis.tutorialgroup.service.TutorialGroupChannelManagementService; -import de.tum.cit.aet.artemis.tutorialgroups.TutorialGroupUtilService; -import de.tum.cit.aet.artemis.user.UserFactory; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupTestRepository; +import de.tum.cit.aet.artemis.tutorialgroups.util.TutorialGroupUtilService; class ChannelIntegrationTest extends AbstractConversationTest { private static final String TEST_PREFIX = "chtest"; @Autowired - TutorialGroupRepository tutorialGroupRepository; + TutorialGroupTestRepository tutorialGroupRepository; @Autowired TutorialGroupChannelManagementService tutorialGroupChannelManagementService; diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/ConversationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/ConversationIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/metis/ConversationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/ConversationIntegrationTest.java index 41ad12b7219c..ef488a032399 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/ConversationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/ConversationIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; @@ -25,18 +25,18 @@ import de.tum.cit.aet.artemis.communication.dto.GroupChatDTO; import de.tum.cit.aet.artemis.communication.dto.OneToOneChatDTO; import de.tum.cit.aet.artemis.communication.dto.ResponsibleUserDTO; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ConversationIntegrationTest extends AbstractConversationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/GroupChatIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/GroupChatIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/metis/GroupChatIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/GroupChatIntegrationTest.java index a6a71c1ca325..e349eda63b65 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/GroupChatIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/GroupChatIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; @@ -20,7 +20,7 @@ import de.tum.cit.aet.artemis.communication.dto.MetisCrudAction; import de.tum.cit.aet.artemis.communication.dto.PostDTO; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; -import de.tum.cit.aet.artemis.user.UserFactory; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; class GroupChatIntegrationTest extends AbstractConversationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/MessageIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/MessageIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/metis/MessageIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/MessageIntegrationTest.java index 6c3f6702985f..39598ae3d591 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/MessageIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/MessageIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -44,7 +44,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; import de.tum.cit.aet.artemis.communication.domain.DisplayPriority; import de.tum.cit.aet.artemis.communication.domain.Post; @@ -56,9 +55,10 @@ import de.tum.cit.aet.artemis.communication.dto.PostContextFilterDTO; import de.tum.cit.aet.artemis.communication.dto.PostDTO; import de.tum.cit.aet.artemis.communication.repository.ConversationMessageRepository; -import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationNotificationRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.OneToOneChatRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationParticipantTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.OneToOneChatTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.User; @@ -66,7 +66,7 @@ import de.tum.cit.aet.artemis.core.security.SecurityUtils; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class MessageIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -78,10 +78,10 @@ class MessageIntegrationTest extends AbstractSpringIntegrationIndependentTest { private ConversationMessageRepository conversationMessageRepository; @Autowired - private OneToOneChatRepository oneToOneChatRepository; + private OneToOneChatTestRepository oneToOneChatRepository; @Autowired - private ConversationParticipantRepository conversationParticipantRepository; + private ConversationParticipantTestRepository conversationParticipantRepository; @Autowired private ObjectMapper objectMapper; @@ -153,7 +153,7 @@ void testCreateConversationPost(CourseInformationSharingConfiguration courseInfo Post createdPost = createPostAndAwaitAsyncCode(postToSave); checkCreatedMessagePost(postToSave, createdPost); assertThat(createdPost.getConversation().getId()).isNotNull(); - var requestingUser = userRepository.getUser(); + var requestingUser = userTestRepository.getUser(); PostContextFilterDTO postContextFilter = new PostContextFilterDTO(courseId, null, null, createdPost.getConversation().getId(), null, false, false, false, null, null); assertThat(conversationMessageRepository.findMessages(postContextFilter, Pageable.unpaged(), requestingUser.getId())).hasSize(1); @@ -316,15 +316,15 @@ void testBroadCastWithNotification() throws Exception { @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testFindMessagesWithPageSizes(int pageSize) { - var student1 = userRepository.findOneWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student1").orElseThrow(); - var student2 = userRepository.findOneWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student2").orElseThrow(); + var student1 = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student1").orElseThrow(); + var student2 = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student2").orElseThrow(); List posts = conversationUtilService.createPostsWithAnswersAndReactionsAndConversation(course, student1, student2, NUMBER_OF_POSTS, TEST_PREFIX); long conversationId = posts.getFirst().getConversation().getId(); for (Post post : posts) { assertThat(post.getConversation().getId()).isNotNull(); assertThat(post.getConversation().getId()).isEqualTo(conversationId); } - var requestingUser = userRepository.getUser(); + var requestingUser = userTestRepository.getUser(); PostContextFilterDTO postContextFilter = new PostContextFilterDTO(course.getId(), null, null, posts.getFirst().getConversation().getId(), null, false, false, false, null, null); @@ -345,7 +345,7 @@ void testMessagingNotAllowedIfDisabledSetting() throws Exception { assertThat(persistedCourse.getCourseInformationSharingConfiguration()).isEqualTo(CourseInformationSharingConfiguration.DISABLED); Post postToSave = createPostWithOneToOneChat(TEST_PREFIX); - var requestingUser = userRepository.getUser(); + var requestingUser = userTestRepository.getUser(); PostContextFilterDTO postContextFilter = new PostContextFilterDTO(courseId, null, null, postToSave.getConversation().getId(), null, false, false, false, null, null); var numberOfPostsBefore = conversationMessageRepository.findMessages(postContextFilter, Pageable.unpaged(), requestingUser.getId()).getSize(); @@ -371,7 +371,7 @@ void testCreateConversationPost_forbidden() throws Exception { Post postToSave = createPostWithOneToOneChat(TEST_PREFIX); // attempt to save new post under someone else's conversation postToSave.setConversation(existingConversationMessages.getFirst().getConversation()); - var requestingUser = userRepository.getUser(); + var requestingUser = userTestRepository.getUser(); PostContextFilterDTO postContextFilter = new PostContextFilterDTO(courseId, null, null, postToSave.getConversation().getId(), null, false, false, false, null, null); var numberOfPostsBefore = conversationMessageRepository.findMessages(postContextFilter, Pageable.unpaged(), requestingUser.getId()).getSize(); @@ -695,8 +695,8 @@ void testDecreaseUnreadMessageCountWhenDeletingMessage() throws Exception { } private Post createPostWithOneToOneChat(String userPrefix) { - var student1 = userRepository.findOneWithGroupsAndAuthoritiesByLogin(userPrefix + "student1").orElseThrow(); - var student2 = userRepository.findOneWithGroupsAndAuthoritiesByLogin(userPrefix + "student2").orElseThrow(); + var student1 = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(userPrefix + "student1").orElseThrow(); + var student2 = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(userPrefix + "student2").orElseThrow(); var chat = new OneToOneChat(); chat.setCourse(course); chat.setCreator(student1); diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/OneToOneChatIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/OneToOneChatIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/metis/OneToOneChatIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/OneToOneChatIntegrationTest.java index a3fe6817831b..737d57cc104c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/OneToOneChatIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/OneToOneChatIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyString; @@ -20,7 +20,7 @@ import de.tum.cit.aet.artemis.communication.dto.OneToOneChatDTO; import de.tum.cit.aet.artemis.communication.dto.PostDTO; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; -import de.tum.cit.aet.artemis.user.UserFactory; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; class OneToOneChatIntegrationTest extends AbstractConversationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/PostingServiceUnitTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/PostingServiceUnitTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/metis/PostingServiceUnitTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/PostingServiceUnitTest.java index ecd465a0f5ec..c3673c8a3dfd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/PostingServiceUnitTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/PostingServiceUnitTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -25,8 +25,8 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; class PostingServiceUnitTest { @@ -34,7 +34,7 @@ class PostingServiceUnitTest { private ConversationMessagingService postingService; @Mock - private UserRepository userRepository; + private UserTestRepository userRepository; @Mock private AuthorizationCheckService authorizationCheckService; diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/ReactionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/ReactionIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/metis/ReactionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/ReactionIntegrationTest.java index d47ce3bf5313..063f9be0fab2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/ReactionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/ReactionIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis; +package de.tum.cit.aet.artemis.communication; import static de.tum.cit.aet.artemis.core.config.Constants.VOTE_EMOJI_ID; import static org.assertj.core.api.Assertions.assertThat; @@ -23,29 +23,29 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.Post; import de.tum.cit.aet.artemis.communication.domain.PostSortCriterion; import de.tum.cit.aet.artemis.communication.domain.Reaction; import de.tum.cit.aet.artemis.communication.repository.ConversationMessageRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; -import de.tum.cit.aet.artemis.communication.repository.ReactionRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ReactionTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.SortingOrder; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ReactionIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "reactionintegration"; @Autowired - private ReactionRepository reactionRepository; + private ReactionTestRepository reactionRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private ConversationMessageRepository conversationMessageRepository; @@ -511,7 +511,7 @@ private Reaction saveReactionOfOtherUserOnPost(Post postReactedOn, String userPr reaction.setEmojiId("smiley"); reaction.setPost(postReactedOn); Reaction savedReaction = reactionRepository.save(reaction); - User user = userRepository.getUserWithGroupsAndAuthorities(userPrefix + "student2"); + User user = userTestRepository.getUserWithGroupsAndAuthorities(userPrefix + "student2"); savedReaction.setUser(user); reactionRepository.save(savedReaction); return savedReaction; diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/LinkPreviewIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/LinkPreviewIntegrationTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/LinkPreviewIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/LinkPreviewIntegrationTest.java index c2bea7be643e..efba8cfce577 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/LinkPreviewIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/LinkPreviewIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis.linkpreview; +package de.tum.cit.aet.artemis.communication.linkpreview; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @@ -21,8 +21,8 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.dto.LinkPreviewDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LinkPreviewIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -31,7 +31,7 @@ class LinkPreviewIntegrationTest extends AbstractSpringIntegrationIndependentTes // this link will return null for all fields because it does not include OG tags private static final String GOOGLE_URL = "https://google.com"; - private static final String MOCK_FILE_PATH_PREFIX = "src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/"; + private static final String MOCK_FILE_PATH_PREFIX = "src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/"; @Autowired private CacheManager cacheManager; diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/github_home.txt b/src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/github_home.txt similarity index 100% rename from src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/github_home.txt rename to src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/github_home.txt diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/github_pull_request_6615.txt b/src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/github_pull_request_6615.txt similarity index 100% rename from src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/github_pull_request_6615.txt rename to src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/github_pull_request_6615.txt diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/github_pull_request_6618.txt b/src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/github_pull_request_6618.txt similarity index 100% rename from src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/github_pull_request_6618.txt rename to src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/github_pull_request_6618.txt diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/google.txt b/src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/google.txt similarity index 100% rename from src/test/java/de/tum/cit/aet/artemis/metis/linkpreview/mockFiles/google.txt rename to src/test/java/de/tum/cit/aet/artemis/communication/linkpreview/mockFiles/google.txt diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/notification/GroupNotificationFactoryTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/domain/notification/GroupNotificationFactoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java index 932bb305abe8..fd2cdc919724 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/notification/GroupNotificationFactoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationFactoryTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.NotificationPriority.HIGH; import static de.tum.cit.aet.artemis.communication.domain.NotificationPriority.MEDIUM; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/GroupNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/notification/GroupNotificationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationServiceTest.java index bf660a471c6e..88dbd05d6ccb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/GroupNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/GroupNotificationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.NotificationType.COURSE_ARCHIVE_FAILED; import static de.tum.cit.aet.artemis.communication.domain.NotificationType.COURSE_ARCHIVE_FINISHED; @@ -43,7 +43,6 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.domain.Post; @@ -54,23 +53,24 @@ import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationScheduleService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class GroupNotificationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -92,7 +92,7 @@ class GroupNotificationServiceTest extends AbstractSpringIntegrationIndependentT private GroupNotificationScheduleService groupNotificationScheduleService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private CourseUtilService courseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/notification/NotificationPlaceholderArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderArchitectureTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/domain/notification/NotificationPlaceholderArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderArchitectureTest.java index 8454190ed5af..1ec6346eebca 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/notification/NotificationPlaceholderArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain.notification; +package de.tum.cit.aet.artemis.communication.notification; import static com.tngtech.archunit.base.DescribedPredicate.allElements; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.type; @@ -18,8 +18,8 @@ import com.tngtech.archunit.lang.ArchCondition; import com.tngtech.archunit.lang.ConditionEvents; -import de.tum.cit.aet.artemis.architecture.AbstractArchitectureTest; import de.tum.cit.aet.artemis.communication.domain.notification.NotificationPlaceholderCreator; +import de.tum.cit.aet.artemis.shared.architecture.AbstractArchitectureTest; class NotificationPlaceholderArchitectureTest extends AbstractArchitectureTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/notification/NotificationPlaceholderSignatureTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/domain/notification/NotificationPlaceholderSignatureTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java index dfdc43aaf4e2..6bfbdffadc3b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/notification/NotificationPlaceholderSignatureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationPlaceholderSignatureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain.notification; +package de.tum.cit.aet.artemis.communication.notification; import static org.assertj.core.api.Assertions.assertThat; @@ -15,9 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.notification.NotificationPlaceholderCreator; import de.tum.cit.aet.artemis.core.config.Constants; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import io.github.classgraph.AnnotationEnumValue; import io.github.classgraph.ClassGraph; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationResourceIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/notification/NotificationResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationResourceIntegrationTest.java index d67de4d483d8..07c00a1b9a3a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static org.assertj.core.api.Assertions.assertThat; @@ -12,7 +12,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.GroupNotificationType; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.domain.NotificationType; @@ -20,11 +19,13 @@ import de.tum.cit.aet.artemis.communication.domain.notification.Notification; import de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants; import de.tum.cit.aet.artemis.communication.domain.notification.SingleUserNotification; +import de.tum.cit.aet.artemis.communication.notification.util.NotificationFactory; import de.tum.cit.aet.artemis.communication.repository.NotificationRepository; import de.tum.cit.aet.artemis.communication.repository.NotificationSettingRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class NotificationResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -52,7 +53,7 @@ void initTestCase() { User student1 = userUtilService.getUserByLogin(TEST_PREFIX + "student1"); student1.setLastNotificationRead(ZonedDateTime.now().minusDays(1)); - userRepository.save(student1); + userTestRepository.save(student1); } @AfterEach @@ -63,7 +64,7 @@ void tearDown() { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void testGetNotifications_recipientEvaluation() throws Exception { - User recipient = userRepository.getUser(); + User recipient = userTestRepository.getUser(); SingleUserNotification notification1 = NotificationFactory.generateSingleUserNotification(ZonedDateTime.now(), recipient); notificationRepository.save(notification1); SingleUserNotification notification2 = NotificationFactory.generateSingleUserNotification(ZonedDateTime.now(), userUtilService.getUserByLogin(TEST_PREFIX + "student2")); @@ -203,7 +204,7 @@ void testGetAllNotificationsForCurrentUser_hideUntilDeactivated() throws Excepti User student1 = userUtilService.getUserByLogin(TEST_PREFIX + "student1"); // i.e. the show all notifications regardless of their creation/notification date student1.setHideNotificationsUntil(null); - userRepository.save(student1); + userTestRepository.save(student1); GroupNotification futureNotification = NotificationFactory.generateGroupNotification(timeNow.plusHours(1), course1, GroupNotificationType.STUDENT); notificationRepository.save(futureNotification); @@ -224,7 +225,7 @@ void testGetAllNotificationsForCurrentUser_hideUntilActivated() throws Exception User student1 = userUtilService.getUserByLogin(TEST_PREFIX + "student1"); student1.setHideNotificationsUntil(timeNow); - userRepository.save(student1); + userTestRepository.save(student1); GroupNotification futureNotification = NotificationFactory.generateGroupNotification(timeNow.plusHours(1), course1, GroupNotificationType.STUDENT); notificationRepository.save(futureNotification); diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationScheduleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationScheduleServiceTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/notification/NotificationScheduleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationScheduleServiceTest.java index 96a84d64cb1f..f3dc650315c9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationScheduleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationScheduleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.NOTIFICATION__EXERCISE_NOTIFICATION__EXERCISE_RELEASED; import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.NOTIFICATION__EXERCISE_NOTIFICATION__EXERCISE_SUBMISSION_ASSESSED; @@ -19,23 +19,23 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.repository.NotificationRepository; import de.tum.cit.aet.artemis.communication.repository.NotificationSettingRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.messaging.InstanceMessageReceiveService; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class NotificationScheduleServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -54,7 +54,7 @@ class NotificationScheduleServiceTest extends AbstractSpringIntegrationLocalCILo private NotificationSettingRepository notificationSettingRepository; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationSettingsResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationSettingsResourceIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/notification/NotificationSettingsResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationSettingsResourceIntegrationTest.java index ad83b0464837..8a86a75e3b58 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationSettingsResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationSettingsResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.DEFAULT_NOTIFICATION_SETTINGS; import static org.assertj.core.api.Assertions.assertThat; @@ -12,13 +12,13 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.NotificationSettingRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class NotificationSettingsResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationSettingsServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationSettingsServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/notification/NotificationSettingsServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationSettingsServiceTest.java index df938d4f0208..00ff52161036 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationSettingsServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationSettingsServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.NotificationType.ATTACHMENT_CHANGE; import static de.tum.cit.aet.artemis.communication.domain.NotificationType.COURSE_ARCHIVE_STARTED; @@ -23,7 +23,6 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.domain.NotificationType; import de.tum.cit.aet.artemis.communication.domain.notification.GroupNotification; @@ -34,7 +33,8 @@ import de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class NotificationSettingsServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationTargetFactoryTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationTargetFactoryTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/notification/NotificationTargetFactoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationTargetFactoryTest.java index 12caae8058f9..1d92dbb0daa4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationTargetFactoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/NotificationTargetFactoryTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.FILE_SUBMISSION_SUCCESSFUL_TITLE; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationTargetFactory.COURSES_TEXT; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/PushNotificationResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/PushNotificationResourceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/notification/PushNotificationResourceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/PushNotificationResourceTest.java index db28d70aacfe..2a310e068f7c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/PushNotificationResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/PushNotificationResourceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static org.assertj.core.api.Assertions.assertThat; @@ -13,7 +13,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceConfiguration; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceType; import de.tum.cit.aet.artemis.communication.dto.PushNotificationRegisterBody; @@ -21,14 +20,15 @@ import de.tum.cit.aet.artemis.communication.dto.PushNotificationUnregisterRequest; import de.tum.cit.aet.artemis.communication.repository.PushNotificationDeviceConfigurationRepository; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class PushNotificationResourceTest extends AbstractSpringIntegrationIndependentTest { @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private PushNotificationDeviceConfigurationRepository pushNotificationDeviceConfigurationRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/notification/SingleUserNotificationFactoryTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationFactoryTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/domain/notification/SingleUserNotificationFactoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationFactoryTest.java index 1b5fc1aea585..9f26bc036d12 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/notification/SingleUserNotificationFactoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationFactoryTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.NotificationPriority.HIGH; import static de.tum.cit.aet.artemis.communication.domain.NotificationPriority.MEDIUM; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/SingleUserNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/notification/SingleUserNotificationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java index 11a18d0bbbbd..9faaf7d03bc3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/SingleUserNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SingleUserNotificationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.NotificationType.CONVERSATION_ADD_USER_CHANNEL; import static de.tum.cit.aet.artemis.communication.domain.NotificationType.CONVERSATION_ADD_USER_GROUP_CHAT; @@ -65,10 +65,9 @@ import org.mockito.ArgumentCaptor; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; @@ -87,23 +86,24 @@ import de.tum.cit.aet.artemis.core.domain.DomainObject; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismSubmission; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; import de.tum.cit.aet.artemis.plagiarism.domain.text.TextPlagiarismResult; import de.tum.cit.aet.artemis.plagiarism.domain.text.TextSubmissionElement; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; -import de.tum.cit.aet.artemis.user.UserUtilService; class SingleUserNotificationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -122,7 +122,7 @@ class SingleUserNotificationServiceTest extends AbstractSpringIntegrationIndepen private ExerciseRepository exerciseRepository; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private CourseUtilService courseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/SystemNotificationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SystemNotificationIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/notification/SystemNotificationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/SystemNotificationIntegrationTest.java index b142a17ff108..221762ad555d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/SystemNotificationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/SystemNotificationIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification; import static org.assertj.core.api.Assertions.assertThat; @@ -13,9 +13,10 @@ import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.notification.SystemNotification; +import de.tum.cit.aet.artemis.communication.notification.util.NotificationFactory; import de.tum.cit.aet.artemis.communication.repository.SystemNotificationRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class SystemNotificationIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/notification/TutorialGroupNotificationFactoryTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/TutorialGroupNotificationFactoryTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/domain/notification/TutorialGroupNotificationFactoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/TutorialGroupNotificationFactoryTest.java index 26e264548433..12e6d37fe602 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/notification/TutorialGroupNotificationFactoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/TutorialGroupNotificationFactoryTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain.notification; +package de.tum.cit.aet.artemis.communication.notification; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_DELETED_TEXT; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_DELETED_TITLE; diff --git a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationFactory.java b/src/test/java/de/tum/cit/aet/artemis/communication/notification/util/NotificationFactory.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/notification/NotificationFactory.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notification/util/NotificationFactory.java index bb202ab6d027..c82b79afa2c1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/notification/NotificationFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notification/util/NotificationFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.notification; +package de.tum.cit.aet.artemis.communication.notification.util; import java.time.ZonedDateTime; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/notifications/ConversationNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/ConversationNotificationServiceTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/service/notifications/ConversationNotificationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/ConversationNotificationServiceTest.java index a8b281fccdab..11911a26af6e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/notifications/ConversationNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/ConversationNotificationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.notifications; +package de.tum.cit.aet.artemis.communication.notifications.service; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.NEW_MESSAGE_TITLE; import static org.assertj.core.api.Assertions.assertThat; @@ -14,24 +14,24 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; import de.tum.cit.aet.artemis.communication.domain.Post; import de.tum.cit.aet.artemis.communication.domain.conversation.OneToOneChat; import de.tum.cit.aet.artemis.communication.domain.notification.ConversationNotification; import de.tum.cit.aet.artemis.communication.domain.notification.Notification; import de.tum.cit.aet.artemis.communication.repository.ConversationMessageRepository; -import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; import de.tum.cit.aet.artemis.communication.repository.NotificationRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationNotificationRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; import de.tum.cit.aet.artemis.communication.service.notifications.ConversationNotificationService; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationParticipantTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ConversationNotificationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -47,13 +47,13 @@ class ConversationNotificationServiceTest extends AbstractSpringIntegrationIndep private ConversationMessageRepository conversationMessageRepository; @Autowired - private ConversationRepository conversationRepository; + private ConversationTestRepository conversationRepository; @Autowired - private ConversationParticipantRepository conversationParticipantRepository; + private ConversationParticipantTestRepository conversationParticipantRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/notifications/GeneralInstantNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/GeneralInstantNotificationServiceTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/service/notifications/GeneralInstantNotificationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/GeneralInstantNotificationServiceTest.java index f5dc732d936e..b423f3250b48 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/notifications/GeneralInstantNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/GeneralInstantNotificationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.notifications; +package de.tum.cit.aet.artemis.communication.notifications.service; import static org.mockito.Mockito.any; import static org.mockito.Mockito.never; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/notifications/MailServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/MailServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/notifications/MailServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/MailServiceTest.java index 803fbe1098cc..b29c998d6ee7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/notifications/MailServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/MailServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.notifications; +package de.tum.cit.aet.artemis.communication.notifications.service; import static org.assertj.core.api.Assertions.assertThatNoException; import static org.mockito.Mockito.any; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/notifications/TutorialGroupNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/TutorialGroupNotificationServiceTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/service/notifications/TutorialGroupNotificationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/TutorialGroupNotificationServiceTest.java index fcdc341e42bf..fb484c37a99d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/notifications/TutorialGroupNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/TutorialGroupNotificationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.notifications; +package de.tum.cit.aet.artemis.communication.notifications.service; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_DELETED_TITLE; import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_UPDATED_TITLE; @@ -25,7 +25,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.domain.notification.Notification; import de.tum.cit.aet.artemis.communication.domain.notification.TutorialGroupNotification; @@ -33,15 +32,16 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistration; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistrationType; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupNotificationRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRegistrationRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupRegistrationTestRepository; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupTestRepository; class TutorialGroupNotificationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -55,13 +55,13 @@ class TutorialGroupNotificationServiceTest extends AbstractSpringIntegrationInde private TutorialGroupNotificationRepository tutorialGroupNotificationRepository; @Autowired - private TutorialGroupRepository tutorialGroupRepository; + private TutorialGroupTestRepository tutorialGroupRepository; @Autowired - private TutorialGroupRegistrationRepository tutorialGroupRegistrationRepository; + private TutorialGroupRegistrationTestRepository tutorialGroupRegistrationRepository; @Autowired - UserRepository userRepository; + UserTestRepository userRepository; @Autowired private NotificationSettingRepository notificationSettingRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/notifications/push_notifications/AppleFirebasePushNotificationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/notifications/push_notifications/AppleFirebasePushNotificationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java index 97c9d66f522a..40ec1dd07e09 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/notifications/push_notifications/AppleFirebasePushNotificationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/notifications/service/push_notifications/AppleFirebasePushNotificationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.notifications.push_notifications; +package de.tum.cit.aet.artemis.communication.notifications.service.push_notifications; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/EmailSummaryServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/service/EmailSummaryServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/EmailSummaryServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/service/EmailSummaryServiceTest.java index 2f74b8e34df8..3e83e09a225c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/EmailSummaryServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/service/EmailSummaryServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.communication.service; 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; @@ -21,18 +21,17 @@ import org.mockito.ArgumentCaptor; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.NotificationSetting; import de.tum.cit.aet.artemis.communication.repository.NotificationSettingRepository; -import de.tum.cit.aet.artemis.communication.service.EmailSummaryService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class EmailSummaryServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/scheduled/PushNotificationDeviceConfigurationCleanupServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/service/scheduled/PushNotificationDeviceConfigurationCleanupServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java index 43b14d922d4a..dc59407ff76b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/scheduled/PushNotificationDeviceConfigurationCleanupServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/service/PushNotificationDeviceConfigurationCleanupServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.scheduled; +package de.tum.cit.aet.artemis.communication.service; import static org.springframework.test.util.AssertionErrors.assertEquals; @@ -13,13 +13,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceConfiguration; import de.tum.cit.aet.artemis.communication.domain.push_notification.PushNotificationDeviceType; import de.tum.cit.aet.artemis.communication.repository.PushNotificationDeviceConfigurationRepository; -import de.tum.cit.aet.artemis.communication.service.PushNotificationDeviceConfigurationCleanupService; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class PushNotificationDeviceConfigurationCleanupServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/WeeklyEmailSummaryScheduleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/service/WeeklyEmailSummaryScheduleServiceTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/WeeklyEmailSummaryScheduleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/service/WeeklyEmailSummaryScheduleServiceTest.java index 4bfe611d511d..226546d34c73 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/WeeklyEmailSummaryScheduleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/service/WeeklyEmailSummaryScheduleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.communication.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -24,8 +24,6 @@ import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import de.tum.cit.aet.artemis.communication.service.EmailSummaryService; -import de.tum.cit.aet.artemis.communication.service.WeeklyEmailSummaryScheduleService; import de.tum.cit.aet.artemis.core.service.ProfileService; /** diff --git a/src/test/java/de/tum/cit/aet/artemis/metis/similarity/TitleJaccardSimilarityCompareStrategyTest.java b/src/test/java/de/tum/cit/aet/artemis/communication/similarity/TitleJaccardSimilarityCompareStrategyTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/metis/similarity/TitleJaccardSimilarityCompareStrategyTest.java rename to src/test/java/de/tum/cit/aet/artemis/communication/similarity/TitleJaccardSimilarityCompareStrategyTest.java index 0aa7bc523d61..516f3ee01137 100644 --- a/src/test/java/de/tum/cit/aet/artemis/metis/similarity/TitleJaccardSimilarityCompareStrategyTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/similarity/TitleJaccardSimilarityCompareStrategyTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.metis.similarity; +package de.tum.cit.aet.artemis.communication.similarity; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ConversationParticipantTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ConversationParticipantTestRepository.java new file mode 100644 index 000000000000..ce63c3352cd9 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ConversationParticipantTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.communication.test_repository; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; +import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; + +@Repository +@Primary +public interface ConversationParticipantTestRepository extends ConversationParticipantRepository { + + default ConversationParticipant findConversationParticipantByConversationIdAndUserIdElseThrow(Long conversationId, Long userId) { + return getValueElseThrow(findConversationParticipantByConversationIdAndUserId(conversationId, userId)); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ConversationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ConversationTestRepository.java new file mode 100644 index 000000000000..7beac73ef014 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ConversationTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.communication.test_repository; + +import java.util.List; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.communication.domain.conversation.Conversation; +import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; + +@Repository +@Primary +public interface ConversationTestRepository extends ConversationRepository { + + List findAllByCourseId(long courseId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/OneToOneChatTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/OneToOneChatTestRepository.java new file mode 100644 index 000000000000..ff000fa88fe5 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/OneToOneChatTestRepository.java @@ -0,0 +1,27 @@ +package de.tum.cit.aet.artemis.communication.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.communication.domain.conversation.OneToOneChat; +import de.tum.cit.aet.artemis.communication.repository.conversation.OneToOneChatRepository; +import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; + +@Repository +@Primary +public interface OneToOneChatTestRepository extends OneToOneChatRepository { + + @Query(""" + SELECT DISTINCT oneToOneChat + FROM OneToOneChat oneToOneChat + LEFT JOIN FETCH oneToOneChat.conversationParticipants p + LEFT JOIN FETCH p.user u + LEFT JOIN FETCH u.groups + WHERE oneToOneChat.id = :oneToOneChatId + """) + Optional findByIdWithConversationParticipantsAndUserGroups(@Param("oneToOneChatId") Long oneToOneChatId) throws EntityNotFoundException; +} diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/PostTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/PostTestRepository.java new file mode 100644 index 000000000000..3dedbfeef361 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/PostTestRepository.java @@ -0,0 +1,32 @@ +package de.tum.cit.aet.artemis.communication.test_repository; + +import java.util.List; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.communication.domain.Post; +import de.tum.cit.aet.artemis.communication.repository.PostRepository; + +@Repository +@Primary +public interface PostTestRepository extends PostRepository { + + /** + * find all posts of a user in a course + * currently only used for testing + * + * @param authorId id of the user + * @param courseId id of the course + * @return a list of posts + */ + @Query(""" + SELECT p + FROM Post p + WHERE p.author.id =:authorId + AND p.conversation.course.id = :courseId + """) + List findPostsByAuthorIdAndCourseId(@Param("authorId") long authorId, @Param("courseId") long courseId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ReactionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ReactionTestRepository.java new file mode 100644 index 000000000000..4ed75aa8c4fe --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/communication/test_repository/ReactionTestRepository.java @@ -0,0 +1,18 @@ +package de.tum.cit.aet.artemis.communication.test_repository; + +import java.util.List; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.communication.domain.Reaction; +import de.tum.cit.aet.artemis.communication.repository.ReactionRepository; + +@Repository +@Primary +public interface ReactionTestRepository extends ReactionRepository { + + List findReactionsByAnswerPostId(Long answerPostId); + + List findReactionsByPostId(Long postId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/post/ConversationFactory.java b/src/test/java/de/tum/cit/aet/artemis/communication/util/ConversationFactory.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/post/ConversationFactory.java rename to src/test/java/de/tum/cit/aet/artemis/communication/util/ConversationFactory.java index 62f4d6b09c31..4409086389c2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/post/ConversationFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/util/ConversationFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.post; +package de.tum.cit.aet.artemis.communication.util; import java.time.ZoneId; import java.time.ZonedDateTime; diff --git a/src/test/java/de/tum/cit/aet/artemis/post/ConversationUtilService.java b/src/test/java/de/tum/cit/aet/artemis/communication/util/ConversationUtilService.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/post/ConversationUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/communication/util/ConversationUtilService.java index 081614632e1e..46a2adbe005e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/post/ConversationUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/communication/util/ConversationUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.post; +package de.tum.cit.aet.artemis.communication.util; import static org.assertj.core.api.Assertions.assertThat; @@ -25,28 +25,28 @@ import de.tum.cit.aet.artemis.communication.domain.conversation.GroupChat; import de.tum.cit.aet.artemis.communication.domain.conversation.OneToOneChat; import de.tum.cit.aet.artemis.communication.repository.AnswerPostRepository; -import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; -import de.tum.cit.aet.artemis.communication.repository.ReactionRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.OneToOneChatRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationParticipantTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.OneToOneChatTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ReactionTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.lecture.LectureFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; /** * Service responsible for initializing the database with specific testdata related to conversations for use in integration tests. @@ -61,7 +61,7 @@ public class ConversationUtilService { private static final ZonedDateTime FUTURE_FUTURE_TIMESTAMP = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private ExerciseRepository exerciseRepo; @@ -73,22 +73,22 @@ public class ConversationUtilService { private PlagiarismCaseRepository plagiarismCaseRepository; @Autowired - private OneToOneChatRepository oneToOneChatRepository; + private OneToOneChatTestRepository oneToOneChatRepository; @Autowired - private ConversationParticipantRepository conversationParticipantRepository; + private ConversationParticipantTestRepository conversationParticipantRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired - private ReactionRepository reactionRepository; + private ReactionTestRepository reactionRepository; @Autowired private AnswerPostRepository answerPostRepository; @Autowired - private ConversationRepository conversationRepository; + private ConversationTestRepository conversationRepository; @Autowired private CourseUtilService courseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusBuildScriptGenerationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusBuildScriptGenerationServiceTest.java index 25a06cb9c199..ac4fa9981b02 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusBuildScriptGenerationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusBuildScriptGenerationServiceTest.java @@ -16,8 +16,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; -import de.tum.cit.aet.artemis.connector.AeolusRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.AeolusRequestMockProvider; import de.tum.cit.aet.artemis.programming.domain.AeolusTarget; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig; @@ -28,6 +27,7 @@ import de.tum.cit.aet.artemis.programming.service.aeolus.AeolusTemplateService; import de.tum.cit.aet.artemis.programming.service.aeolus.Windfile; import de.tum.cit.aet.artemis.programming.service.aeolus.WindfileMetadata; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class AeolusBuildScriptGenerationServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusServiceTest.java index 256b4db68dbe..42db3403a195 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusServiceTest.java @@ -23,8 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.connector.AeolusRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.AeolusRequestMockProvider; import de.tum.cit.aet.artemis.programming.domain.AeolusTarget; import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; @@ -40,6 +39,7 @@ import de.tum.cit.aet.artemis.programming.service.aeolus.Windfile; import de.tum.cit.aet.artemis.programming.service.aeolus.WindfileMetadata; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AeolusServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusTemplateResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusTemplateResourceTest.java index e68db42104a3..43db4eb346dd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusTemplateResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/AeolusTemplateResourceTest.java @@ -16,11 +16,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.programming.service.aeolus.ScriptAction; import de.tum.cit.aet.artemis.programming.service.aeolus.Windfile; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.RequestUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class AeolusTemplateResourceTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonConversionServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonConversionServiceTest.java index 1a6c66ba0d1d..4a24b2db3352 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonConversionServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonConversionServiceTest.java @@ -21,9 +21,9 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.RestTemplate; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.connector.apollon.ApollonRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.apollon.ApollonRequestMockProvider; import de.tum.cit.aet.artemis.modeling.service.apollon.ApollonConversionService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ApollonConversionServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonHealthIndicatorTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonHealthIndicatorTest.java index ed504bbf2955..d6775e48fcc2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonHealthIndicatorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/ApollonHealthIndicatorTest.java @@ -9,9 +9,9 @@ import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Status; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.connector.apollon.ApollonRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.apollon.ApollonRequestMockProvider; import de.tum.cit.aet.artemis.modeling.service.apollon.ApollonHealthIndicator; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ApollonHealthIndicatorTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/Lti13ServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/Lti13ServiceTest.java index c774ebfaf0b0..b1c21105fbb9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/Lti13ServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/Lti13ServiceTest.java @@ -45,14 +45,14 @@ import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.ArtemisAuthenticationProvider; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; @@ -62,10 +62,10 @@ import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; import de.tum.cit.aet.artemis.lti.dto.Scopes; import de.tum.cit.aet.artemis.lti.repository.Lti13ResourceLaunchRepository; -import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; import de.tum.cit.aet.artemis.lti.service.Lti13Service; import de.tum.cit.aet.artemis.lti.service.LtiService; import de.tum.cit.aet.artemis.lti.service.OnlineCourseConfigurationService; +import de.tum.cit.aet.artemis.lti.test_repository.LtiPlatformConfigurationTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.text.domain.TextExercise; import uk.ac.ox.ctl.lti13.lti.Claims; @@ -75,13 +75,13 @@ class Lti13ServiceTest { private Lti13Service lti13Service; @Mock - private UserRepository userRepository; + private UserTestRepository userRepository; @Mock private ExerciseRepository exerciseRepository; @Mock - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; @Mock private Lti13ResourceLaunchRepository launchRepository; @@ -90,7 +90,7 @@ class Lti13ServiceTest { private LtiService ltiService; @Mock - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Mock private OnlineCourseConfigurationService onlineCourseConfigurationService; @@ -105,7 +105,7 @@ class Lti13ServiceTest { private ArtemisAuthenticationProvider artemisAuthenticationProvider; @Mock - private LtiPlatformConfigurationRepository ltiPlatformConfigurationRepository; + private LtiPlatformConfigurationTestRepository ltiPlatformConfigurationRepository; private OidcIdToken oidcIdToken; diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/LtiDynamicRegistrationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/LtiDynamicRegistrationServiceTest.java index d219c79d84ce..0fc6914d30d5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/LtiDynamicRegistrationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/LtiDynamicRegistrationServiceTest.java @@ -24,9 +24,9 @@ import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; import de.tum.cit.aet.artemis.lti.dto.Lti13ClientRegistration; import de.tum.cit.aet.artemis.lti.dto.Lti13PlatformConfiguration; -import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; import de.tum.cit.aet.artemis.lti.service.LtiDynamicRegistrationService; import de.tum.cit.aet.artemis.lti.service.OAuth2JWKSService; +import de.tum.cit.aet.artemis.lti.test_repository.LtiPlatformConfigurationTestRepository; class LtiDynamicRegistrationServiceTest { @@ -34,7 +34,7 @@ class LtiDynamicRegistrationServiceTest { private OAuth2JWKSService oAuth2JWKSService; @Mock - private LtiPlatformConfigurationRepository ltiPlatformConfigurationRepository; + private LtiPlatformConfigurationTestRepository ltiPlatformConfigurationRepository; @Mock private RestTemplate restTemplate; diff --git a/src/test/java/de/tum/cit/aet/artemis/connectors/LtiServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/connectors/LtiServiceTest.java index 87f929423bcd..6ee49ad26b07 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connectors/LtiServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/connectors/LtiServiceTest.java @@ -30,11 +30,11 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.ArtemisAuthenticationProvider; import de.tum.cit.aet.artemis.core.security.SecurityUtils; import de.tum.cit.aet.artemis.core.security.jwt.JWTCookieService; import de.tum.cit.aet.artemis.core.service.user.UserCreationService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; import de.tum.cit.aet.artemis.lti.service.LtiService; @@ -48,7 +48,7 @@ class LtiServiceTest { private UserCreationService userCreationService; @Mock - private UserRepository userRepository; + private UserTestRepository userRepository; @Mock private ArtemisAuthenticationProvider artemisAuthenticationProvider; diff --git a/src/test/java/de/tum/cit/aet/artemis/web/rest/AndroidAppSiteAssociationResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/AndroidAppSiteAssociationResourceTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/web/rest/AndroidAppSiteAssociationResourceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/AndroidAppSiteAssociationResourceTest.java index b8787bbae008..54160c37423a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/web/rest/AndroidAppSiteAssociationResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/AndroidAppSiteAssociationResourceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.web.rest; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; @@ -7,8 +7,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.web.AndroidAppSiteAssociationResource; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AndroidAppSiteAssociationResourceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/web/rest/AppleAppSiteAssociationResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/AppleAppSiteAssociationResourceTest.java similarity index 89% rename from src/test/java/de/tum/cit/aet/artemis/web/rest/AppleAppSiteAssociationResourceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/AppleAppSiteAssociationResourceTest.java index f96f795bc20e..e834b30a7a16 100644 --- a/src/test/java/de/tum/cit/aet/artemis/web/rest/AppleAppSiteAssociationResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/AppleAppSiteAssociationResourceTest.java @@ -1,12 +1,12 @@ -package de.tum.cit.aet.artemis.web.rest; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.web.AppleAppSiteAssociationResource; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AppleAppSiteAssociationResourceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/ClientForwardTest.java b/src/test/java/de/tum/cit/aet/artemis/core/ClientForwardTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/ClientForwardTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/ClientForwardTest.java index 9e2b5bbd6324..d845178a7ce7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/ClientForwardTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/ClientForwardTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -17,6 +17,7 @@ import de.tum.cit.aet.artemis.core.security.filter.SpaWebFilter; import de.tum.cit.aet.artemis.core.security.jwt.JWTCookieService; import de.tum.cit.aet.artemis.core.security.jwt.JWTFilter; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * Test class for the ClientForwardController REST controller. diff --git a/src/test/java/de/tum/cit/aet/artemis/ContentVersionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/ContentVersionIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/ContentVersionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/ContentVersionIntegrationTest.java index c277d76bcbb0..d4bdeda9c9a4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/ContentVersionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/ContentVersionIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; @@ -12,6 +12,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import de.tum.cit.aet.artemis.core.security.filter.ApiVersionFilter; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ContentVersionIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/CourseTest.java b/src/test/java/de/tum/cit/aet/artemis/core/CourseTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/domain/CourseTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/CourseTest.java index 4676f537a475..e7d5d778cb77 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/CourseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/CourseTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/src/test/java/de/tum/cit/aet/artemis/DatabaseQueryCountTest.java b/src/test/java/de/tum/cit/aet/artemis/core/DatabaseQueryCountTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/DatabaseQueryCountTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/DatabaseQueryCountTest.java index 6b8172b5a557..8debc7999553 100644 --- a/src/test/java/de/tum/cit/aet/artemis/DatabaseQueryCountTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/DatabaseQueryCountTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import java.util.Set; @@ -13,10 +13,11 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.CoursesForDashboardDTO; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.StudentExam; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class DatabaseQueryCountTest extends AbstractSpringIntegrationIndependentTest { @@ -41,6 +42,7 @@ void setup() { userUtilService.addUsers(TEST_PREFIX, 1, NUMBER_OF_TUTORS, 0, 0); User student = userUtilService.getUserByLogin(TEST_PREFIX + "student1"); student.setGroups(Set.of(TEST_PREFIX + "tumuser")); + userTestRepository.save(student); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/FileIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/FileIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/FileIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/FileIntegrationTest.java index c50e47d2aaf5..97b4923c2aef 100644 --- a/src/test/java/de/tum/cit/aet/artemis/FileIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/FileIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; @@ -26,11 +26,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.dto.ExamUserDTO; -import de.tum.cit.aet.artemis.lecture.LectureFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentType; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; @@ -40,6 +38,9 @@ import de.tum.cit.aet.artemis.lecture.repository.AttachmentUnitRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FileIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/GuidedTourSettingResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/GuidedTourSettingResourceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/GuidedTourSettingResourceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/GuidedTourSettingResourceTest.java index e8a48ed0719e..cc6f792a207c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/GuidedTourSettingResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/GuidedTourSettingResourceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; @@ -13,7 +13,8 @@ import de.tum.cit.aet.artemis.core.domain.GuidedTourSetting; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class GuidedTourSettingResourceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/GuidedTourSettingTest.java b/src/test/java/de/tum/cit/aet/artemis/core/GuidedTourSettingTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/domain/GuidedTourSettingTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/GuidedTourSettingTest.java index 891395893471..e76a495c9b3c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/GuidedTourSettingTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/GuidedTourSettingTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/ImprintResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/ImprintResourceIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/ImprintResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/ImprintResourceIntegrationTest.java index c9caddfc4947..25775a00f635 100644 --- a/src/test/java/de/tum/cit/aet/artemis/ImprintResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/ImprintResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -26,6 +26,7 @@ import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.dto.ImprintDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ImprintResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/InetSocketAddressValidatorTest.java b/src/test/java/de/tum/cit/aet/artemis/core/InetSocketAddressValidatorTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/InetSocketAddressValidatorTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/InetSocketAddressValidatorTest.java index 7ec87bbf6ed5..e43896a67f01 100644 --- a/src/test/java/de/tum/cit/aet/artemis/InetSocketAddressValidatorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/InetSocketAddressValidatorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/JhiMetricsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/JhiMetricsIntegrationTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/JhiMetricsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/JhiMetricsIntegrationTest.java index a5ddcf176a6d..62638dcd5f49 100644 --- a/src/test/java/de/tum/cit/aet/artemis/JhiMetricsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/JhiMetricsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; @@ -10,6 +10,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; + class JhiMetricsIntegrationTest extends AbstractSpringIntegrationIndependentTest { @Autowired diff --git a/src/test/java/de/tum/cit/aet/artemis/LogResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/LogResourceIntegrationTest.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/LogResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/LogResourceIntegrationTest.java index 9fd6141665d1..ac2baefb5e8d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/LogResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/LogResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; @@ -9,6 +9,7 @@ import org.springframework.security.test.context.support.WithMockUser; import de.tum.cit.aet.artemis.core.dto.vm.LoggerVM; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LogResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/MetricsIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/MetricsIntegrationTest.java index be4fcd14a70a..aa126be537b7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/MetricsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/MetricsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static de.tum.cit.aet.artemis.core.util.TimeUtil.toRelativeTime; import static org.assertj.core.api.Assertions.assertThat; @@ -31,6 +31,7 @@ import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.dto.ExerciseInformationDTO; import de.tum.cit.aet.artemis.exercise.repository.ExerciseMetricsRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class MetricsIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/PrivacyStatementResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/PrivacyStatementResourceIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/PrivacyStatementResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/PrivacyStatementResourceIntegrationTest.java index 66e6e818b559..95993ade7459 100644 --- a/src/test/java/de/tum/cit/aet/artemis/PrivacyStatementResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/PrivacyStatementResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -26,6 +26,7 @@ import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.dto.PrivacyStatementDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class PrivacyStatementResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/StatisticsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/StatisticsIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/StatisticsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/StatisticsIntegrationTest.java index 5e98f689fc33..bcd5a8d5c8ae 100644 --- a/src/test/java/de/tum/cit/aet/artemis/StatisticsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/StatisticsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -19,15 +19,15 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import de.tum.cit.aet.artemis.assessment.GradingScaleFactory; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; import de.tum.cit.aet.artemis.assessment.repository.ParticipantScoreRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleFactory; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.Post; import de.tum.cit.aet.artemis.communication.repository.AnswerPostRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.GraphType; import de.tum.cit.aet.artemis.core.domain.SpanType; @@ -35,14 +35,15 @@ import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.CourseManagementStatisticsDTO; import de.tum.cit.aet.artemis.exercise.dto.ExerciseManagementStatisticsDTO; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class StatisticsIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -52,7 +53,7 @@ class StatisticsIntegrationTest extends AbstractSpringIntegrationIndependentTest private TextExerciseRepository textExerciseRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private AnswerPostRepository answerPostRepository; @@ -64,7 +65,7 @@ class StatisticsIntegrationTest extends AbstractSpringIntegrationIndependentTest private GradingScaleRepository gradingScaleRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ModelingExerciseUtilService modelingExerciseUtilService; @@ -198,8 +199,8 @@ void testGetCourseStatistics() throws Exception { var laterTextExerciseId = laterTextExercise.getId(); var earlierTextExerciseId = earlierTextExercise.getId(); - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); - User student2 = userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student2 = userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); // Creating result for student1 and student2 for the later exercise participationUtilService.createParticipationSubmissionAndResult(laterTextExerciseId, student1, 10.0, 0.0, 50, true); @@ -246,8 +247,8 @@ void testGetExerciseStatistics() throws Exception { TextExercise textExercise = textExerciseUtilService.createIndividualTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); var firstTextExerciseId = textExercise.getId(); - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); - User student2 = userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student2 = userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); // Creating result for student1 and student2 for firstExercise participationUtilService.createParticipationSubmissionAndResult(firstTextExerciseId, student1, 10.0, 0.0, 50, true); @@ -279,7 +280,7 @@ void testGetExerciseStatistics() throws Exception { assertThat(result.maxPointsOfExercise()).isEqualTo(10); assertThat(result.numberOfExerciseScores()).isEqualTo(2); assertThat(result.numberOfParticipations()).isEqualTo(2); - assertThat(result.numberOfStudentsOrTeamsInCourse()).isEqualTo(userRepository.countUserInGroup(course.getStudentGroupName())); + assertThat(result.numberOfStudentsOrTeamsInCourse()).isEqualTo(userTestRepository.countUserInGroup(course.getStudentGroupName())); assertThat(result.numberOfPosts()).isEqualTo(1); assertThat(result.numberOfResolvedPosts()).isEqualTo(1); var expectedScoresResult = new int[10]; diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/StatisticsRepositoryTest.java b/src/test/java/de/tum/cit/aet/artemis/core/StatisticsRepositoryTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/core/repository/StatisticsRepositoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/StatisticsRepositoryTest.java index 5d7aa5b1ca23..3e58b7958354 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/StatisticsRepositoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/StatisticsRepositoryTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.core.repository; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -15,14 +15,16 @@ import org.junit.jupiter.params.provider.EnumSource; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.GraphType; import de.tum.cit.aet.artemis.core.domain.PersistentAuditEvent; import de.tum.cit.aet.artemis.core.domain.SpanType; import de.tum.cit.aet.artemis.core.domain.StatisticsView; import de.tum.cit.aet.artemis.core.dto.StatisticsEntry; +import de.tum.cit.aet.artemis.core.repository.PersistenceAuditEventRepository; +import de.tum.cit.aet.artemis.core.repository.StatisticsRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class StatisticsRepositoryTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/learninganalytics/StudentLearningAnalyticsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/StudentLearningAnalyticsIntegrationTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/learninganalytics/StudentLearningAnalyticsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/StudentLearningAnalyticsIntegrationTest.java index 65e411a28b32..65d6f715b289 100644 --- a/src/test/java/de/tum/cit/aet/artemis/learninganalytics/StudentLearningAnalyticsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/StudentLearningAnalyticsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.learninganalytics; +package de.tum.cit.aet.artemis.core; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -11,10 +11,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseTestService; -import de.tum.cit.aet.artemis.util.RequestUtilService; +import de.tum.cit.aet.artemis.core.util.CourseTestService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class StudentLearningAnalyticsIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/aspects/AbstractEnforceRoleInResourceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/aspects/AbstractEnforceRoleInResourceTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/aspects/AbstractEnforceRoleInResourceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/aspects/AbstractEnforceRoleInResourceTest.java index 692668ee76f4..3166e47bd27c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/aspects/AbstractEnforceRoleInResourceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/aspects/AbstractEnforceRoleInResourceTest.java @@ -1,12 +1,12 @@ -package de.tum.cit.aet.artemis.aspects; +package de.tum.cit.aet.artemis.core.aspects; import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * This abstract class is used to test the aspect that enforces the role of the user for a specific resource. diff --git a/src/test/java/de/tum/cit/aet/artemis/aspects/EnforceRoleInCourseTest.java b/src/test/java/de/tum/cit/aet/artemis/core/aspects/EnforceRoleInCourseTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/aspects/EnforceRoleInCourseTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/aspects/EnforceRoleInCourseTest.java index 57cc8349defa..ceb300e1b968 100644 --- a/src/test/java/de/tum/cit/aet/artemis/aspects/EnforceRoleInCourseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/aspects/EnforceRoleInCourseTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.aspects; +package de.tum.cit.aet.artemis.core.aspects; import java.util.stream.Stream; diff --git a/src/test/java/de/tum/cit/aet/artemis/aspects/EnforceRoleInExerciseTest.java b/src/test/java/de/tum/cit/aet/artemis/core/aspects/EnforceRoleInExerciseTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/aspects/EnforceRoleInExerciseTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/aspects/EnforceRoleInExerciseTest.java index 10225958ed9b..13892e0ca8b2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/aspects/EnforceRoleInExerciseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/aspects/EnforceRoleInExerciseTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.aspects; +package de.tum.cit.aet.artemis.core.aspects; import java.util.stream.Stream; @@ -9,8 +9,8 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; class EnforceRoleInExerciseTest extends AbstractEnforceRoleInResourceTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/aspects/resources/EnforceRoleInCourseResource.java b/src/test/java/de/tum/cit/aet/artemis/core/aspects/util/EnforceRoleInCourseResource.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/aspects/resources/EnforceRoleInCourseResource.java rename to src/test/java/de/tum/cit/aet/artemis/core/aspects/util/EnforceRoleInCourseResource.java index 34d58898e448..bd301d5c5ade 100644 --- a/src/test/java/de/tum/cit/aet/artemis/aspects/resources/EnforceRoleInCourseResource.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/aspects/util/EnforceRoleInCourseResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.aspects.resources; +package de.tum.cit.aet.artemis.core.aspects.util; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/test/java/de/tum/cit/aet/artemis/aspects/resources/EnforceRoleInExerciseResource.java b/src/test/java/de/tum/cit/aet/artemis/core/aspects/util/EnforceRoleInExerciseResource.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/aspects/resources/EnforceRoleInExerciseResource.java rename to src/test/java/de/tum/cit/aet/artemis/core/aspects/util/EnforceRoleInExerciseResource.java index 3be7fab107a5..1595dad5afae 100644 --- a/src/test/java/de/tum/cit/aet/artemis/aspects/resources/EnforceRoleInExerciseResource.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/aspects/util/EnforceRoleInExerciseResource.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.aspects.resources; +package de.tum.cit.aet.artemis.core.aspects.util; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; diff --git a/src/test/java/de/tum/cit/aet/artemis/authentication/AuthenticationIntegrationTestHelper.java b/src/test/java/de/tum/cit/aet/artemis/core/authentication/AuthenticationIntegrationTestHelper.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/authentication/AuthenticationIntegrationTestHelper.java rename to src/test/java/de/tum/cit/aet/artemis/core/authentication/AuthenticationIntegrationTestHelper.java index 3e5494420047..bc10fb0d9dce 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authentication/AuthenticationIntegrationTestHelper.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authentication/AuthenticationIntegrationTestHelper.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authentication; +package de.tum.cit.aet.artemis.core.authentication; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/authentication/InternalAuthenticationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authentication/InternalAuthenticationIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/authentication/InternalAuthenticationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authentication/InternalAuthenticationIntegrationTest.java index dfc22c4e0b93..84ba3d693707 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authentication/InternalAuthenticationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authentication/InternalAuthenticationIntegrationTest.java @@ -1,10 +1,10 @@ -package de.tum.cit.aet.artemis.authentication; +package de.tum.cit.aet.artemis.core.authentication; import static de.tum.cit.aet.artemis.core.domain.Authority.EDITOR_AUTHORITY; import static de.tum.cit.aet.artemis.core.domain.Authority.INSTRUCTOR_AUTHORITY; import static de.tum.cit.aet.artemis.core.domain.Authority.TA_AUTHORITY; import static de.tum.cit.aet.artemis.core.domain.Authority.USER_AUTHORITY; -import static de.tum.cit.aet.artemis.user.UserFactory.USER_PASSWORD; +import static de.tum.cit.aet.artemis.core.user.util.UserFactory.USER_PASSWORD; import static org.assertj.core.api.Assertions.assertThat; import java.time.ZonedDateTime; @@ -26,8 +26,7 @@ import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.connector.GitlabRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.GitlabRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; @@ -37,11 +36,12 @@ import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.security.SecurityUtils; import de.tum.cit.aet.artemis.core.service.user.PasswordService; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.tutorialgroups.TutorialGroupUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.tutorialgroups.util.TutorialGroupUtilService; class InternalAuthenticationIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -51,7 +51,7 @@ class InternalAuthenticationIntegrationTest extends AbstractSpringIntegrationJen private PasswordService passwordService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private AuthorityRepository authorityRepository; @@ -99,11 +99,11 @@ void setUp() { final var taAuthority = new Authority(Role.TEACHING_ASSISTANT.getAuthority()); authorityRepository.saveAll(List.of(userAuthority, instructorAuthority, adminAuthority, taAuthority)); - student = userRepository.findOneWithGroupsAndAuthoritiesByLogin(USERNAME).orElseThrow(); + student = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(USERNAME).orElseThrow(); final var encodedPassword = passwordService.hashPassword(USER_PASSWORD); student.setPassword(encodedPassword); student.setInternal(true); - userRepository.save(student); + userTestRepository.save(student); } @AfterEach @@ -139,7 +139,7 @@ void registerForCourse_internalAuth_success() throws Exception { @NotNull private User createUserWithRestApi(Set authorities) throws Exception { - userRepository.findOneByLogin("user1").ifPresent(userRepository::delete); + userTestRepository.findOneByLogin("user1").ifPresent(userTestRepository::delete); gitlabRequestMockProvider.enableMockingOfRequests(); gitlabRequestMockProvider.mockGetUserID(); tutorialGroupUtilService.addTutorialCourse(); @@ -266,7 +266,7 @@ void updateUserWithRemovedGroups_internalAuth_successful() throws Exception { jenkinsRequestMockProvider.mockUpdateUserAndGroups(student.getLogin(), student, newGroups, oldGroups, false); final var response = request.putWithResponseBody("/api/admin/users", managedUserVM, User.class, HttpStatus.OK); - final var updatedUserIndDB = userRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); + final var updatedUserIndDB = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); assertThat(passwordService.checkPasswordMatch(managedUserVM.getPassword(), updatedUserIndDB.getPassword())).isTrue(); diff --git a/src/test/java/de/tum/cit/aet/artemis/authentication/LdapAuthenticationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authentication/LdapAuthenticationIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/authentication/LdapAuthenticationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authentication/LdapAuthenticationIntegrationTest.java index 79cbbbfd3db4..b6e25b4437fa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authentication/LdapAuthenticationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authentication/LdapAuthenticationIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.authentication; +package de.tum.cit.aet.artemis.core.authentication; -import static de.tum.cit.aet.artemis.user.UserFactory.USER_PASSWORD; +import static de.tum.cit.aet.artemis.core.user.util.UserFactory.USER_PASSWORD; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -20,20 +20,20 @@ import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.StudentDTO; import de.tum.cit.aet.artemis.core.dto.vm.LoginVM; import de.tum.cit.aet.artemis.core.repository.AuthorityRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.service.ldap.LdapUserDto; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class LdapAuthenticationIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -42,10 +42,10 @@ class LdapAuthenticationIntegrationTest extends AbstractSpringIntegrationLocalCI private static final String INCORRECT_PASSWORD = "incorrectPassword123"; @Autowired - protected ProgrammingExerciseRepository programmingExerciseRepository; + protected ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - protected UserRepository userRepository; + protected UserTestRepository userRepository; @Autowired protected AuthorityRepository authorityRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/authentication/UserAccountLocalVcsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authentication/UserAccountLocalVcsIntegrationTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/authentication/UserAccountLocalVcsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authentication/UserAccountLocalVcsIntegrationTest.java index 9260ca546072..a3313ce7c592 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authentication/UserAccountLocalVcsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authentication/UserAccountLocalVcsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authentication; +package de.tum.cit.aet.artemis.core.authentication; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; -import de.tum.cit.aet.artemis.user.UserTestService; +import de.tum.cit.aet.artemis.core.user.util.UserTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class UserAccountLocalVcsIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/authentication/UserJenkinsGitlabIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authentication/UserJenkinsGitlabIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/authentication/UserJenkinsGitlabIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authentication/UserJenkinsGitlabIntegrationTest.java index 1a60caa60657..b302e83631f5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authentication/UserJenkinsGitlabIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authentication/UserJenkinsGitlabIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authentication; +package de.tum.cit.aet.artemis.core.authentication; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.anyLong; @@ -17,19 +17,19 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.util.ReflectionTestUtils; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.vm.ManagedUserVM; import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.service.user.PasswordService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.core.user.util.UserTestService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabPersonalAccessTokenManagementService; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabUserManagementService; import de.tum.cit.aet.artemis.programming.service.jenkins.JenkinsUserManagementService; -import de.tum.cit.aet.artemis.user.UserFactory; -import de.tum.cit.aet.artemis.user.UserTestService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class UserJenkinsGitlabIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -396,7 +396,7 @@ void createUserWithGroupsAlreadyFailsInGitlab() throws Exception { @WithMockUser(username = "admin", roles = "ADMIN") void updateUserGroups() throws Exception { userTestService.student.setPassword(passwordService.hashPassword("this is a password")); - userRepository.save(userTestService.student); + userTestRepository.save(userTestService.student); userTestService.updateUserGroups(); } @@ -439,7 +439,7 @@ void shouldFailIfCannotUpdateDeactivatedUserInGitlab() throws Exception { gitlabRequestMockProvider.mockDeactivateUser(user.getLogin(), false); request.postWithoutLocation("/api/public/register", userVM, HttpStatus.CREATED, null); - Optional registeredUser = userTestService.getUserRepository().findOneWithGroupsAndAuthoritiesByLogin(user.getLogin()); + Optional registeredUser = userTestService.getUserTestRepository().findOneWithGroupsAndAuthoritiesByLogin(user.getLogin()); assertThat(registeredUser).isPresent(); // Update user and assert @@ -457,7 +457,7 @@ void shouldFailIfCannotUpdateDeactivatedUserInGitlab() throws Exception { void shouldBlockUserInGitlabIfAccountNotActivated() throws Exception { String password = "this is a password"; userTestService.student.setPassword(passwordService.hashPassword(password)); - userRepository.save(userTestService.student); + userTestRepository.save(userTestService.student); var oldLogin = userTestService.student.getLogin(); User user = userTestService.student; user.setLogin("new-login"); @@ -468,7 +468,7 @@ void shouldBlockUserInGitlabIfAccountNotActivated() throws Exception { request.put("/api/admin/users", new ManagedUserVM(user, password), HttpStatus.OK); - UserRepository userRepository = userTestService.getUserRepository(); + UserRepository userRepository = userTestService.getUserTestRepository(); final var userInDB = userRepository.findById(user.getId()); assertThat(userInDB).isPresent(); assertThat(userInDB.get().getLogin()).isEqualTo(user.getLogin()); diff --git a/src/test/java/de/tum/cit/aet/artemis/authentication/UserSaml2IntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authentication/UserSaml2IntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/authentication/UserSaml2IntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authentication/UserSaml2IntegrationTest.java index b18ca84ff183..2e501bb63881 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authentication/UserSaml2IntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authentication/UserSaml2IntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authentication; +package de.tum.cit.aet.artemis.core.authentication; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -19,12 +19,12 @@ import org.springframework.security.saml2.provider.service.authentication.Saml2Authentication; import org.springframework.security.test.context.TestSecurityContextHolder; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationGitlabCIGitlabSamlTest; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.vm.LoginVM; import de.tum.cit.aet.artemis.core.service.connectors.SAML2Service; import de.tum.cit.aet.artemis.core.service.user.PasswordService; import de.tum.cit.aet.artemis.core.web.open.PublicUserJwtResource; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationGitlabCIGitlabSamlTest; /** * Tests for {@link PublicUserJwtResource} and {@link SAML2Service}. @@ -52,7 +52,7 @@ void tearDown() throws Exception { @AfterEach void clearExistingUser() { - userRepository.findOneByLogin(STUDENT_NAME).ifPresent(userRepository::delete); + userTestRepository.findOneByLogin(STUDENT_NAME).ifPresent(userTestRepository::delete); } @AfterEach @@ -164,9 +164,9 @@ void testPasswordLoginAfterShibbolethRegistration() throws Exception { assertStudentExists(); // Change Password - User student = userRepository.findUserWithGroupsAndAuthoritiesByLogin(STUDENT_NAME).orElseThrow(); + User student = userTestRepository.findUserWithGroupsAndAuthoritiesByLogin(STUDENT_NAME).orElseThrow(); student.setPassword(passwordService.hashPassword(STUDENT_PASSWORD)); - userRepository.saveAndFlush(student); + userTestRepository.saveAndFlush(student); // Try to login .. TestSecurityContextHolder.clearContext(); @@ -226,7 +226,7 @@ private void createUser(String identifyingEmail) { user.setLogin(STUDENT_NAME); user.setActivated(true); user.setEmail(identifyingEmail); - userRepository.save(user); + userTestRepository.save(user); } private Saml2AuthenticatedPrincipal createPrincipal(String registrationNumber) { diff --git a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationArchitectureTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationArchitectureTest.java index 4d9a9482250e..f1bce920c4ef 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationArchitectureTest.java @@ -1,17 +1,15 @@ -package de.tum.cit.aet.artemis.authorization; +package de.tum.cit.aet.artemis.core.authorization; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noMethods; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.RestController; import com.tngtech.archunit.lang.ArchRule; -import de.tum.cit.aet.artemis.architecture.AbstractArchitectureTest; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAdmin; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastEditor; import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastInstructor; @@ -19,6 +17,7 @@ import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastTutor; import de.tum.cit.aet.artemis.core.security.annotations.EnforceNothing; import de.tum.cit.aet.artemis.core.security.annotations.ManualConfig; +import de.tum.cit.aet.artemis.shared.architecture.AbstractArchitectureTest; class AuthorizationArchitectureTest extends AbstractArchitectureTest { @@ -44,7 +43,6 @@ void testNoPreAuthorizeOnRestEndpoints() { rule.check(productionClasses); } - @Disabled // TODO: Enable this test once the restructuring is done @Test void testEnforceAdminAnnotations() { ArchRule rule = methods().that().areAnnotatedWith(EnforceAdmin.class).and().areNotAnnotatedWith(ManualConfig.class).should().beDeclaredInClassesThat() @@ -80,7 +78,6 @@ void testEnforceAtLeastStudentAnnotations() { rule.check(productionClasses); } - @Disabled // TODO: Enable this test once the restructuring is done @Test void testEnforceNothingAnnotations() { ArchRule rule = methods().that().areAnnotatedWith(EnforceNothing.class).and().areNotAnnotatedWith(ManualConfig.class).should().beDeclaredInClassesThat() diff --git a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationGeneralAndIndependentEndpointTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationGeneralAndIndependentEndpointTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationGeneralAndIndependentEndpointTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationGeneralAndIndependentEndpointTest.java index d71f695bc6e0..ff2014db4f47 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationGeneralAndIndependentEndpointTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationGeneralAndIndependentEndpointTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authorization; +package de.tum.cit.aet.artemis.core.authorization; import java.util.Map; import java.util.stream.Collectors; @@ -10,7 +10,7 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * Contains the one automatic test covering all rest endpoints for authorization tests. diff --git a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationGitlabCISamlEndpointTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationGitlabCISamlEndpointTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationGitlabCISamlEndpointTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationGitlabCISamlEndpointTest.java index 5571f39b6438..a6396c9186fb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationGitlabCISamlEndpointTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationGitlabCISamlEndpointTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authorization; +package de.tum.cit.aet.artemis.core.authorization; import java.lang.reflect.InvocationTargetException; @@ -7,7 +7,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationGitlabCIGitlabSamlTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationGitlabCIGitlabSamlTest; /** * Contains the one automatic test covering all rest endpoints for authorization tests. diff --git a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationJenkinsGitlabEndpointTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationJenkinsGitlabEndpointTest.java similarity index 86% rename from src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationJenkinsGitlabEndpointTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationJenkinsGitlabEndpointTest.java index 167d24d1832f..8749b49428d7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationJenkinsGitlabEndpointTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationJenkinsGitlabEndpointTest.java @@ -1,11 +1,11 @@ -package de.tum.cit.aet.artemis.authorization; +package de.tum.cit.aet.artemis.core.authorization; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; /** * Contains the one automatic test covering all rest endpoints for authorization tests. diff --git a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationLocalCILocalVCEndpointTest.java b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationLocalCILocalVCEndpointTest.java similarity index 86% rename from src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationLocalCILocalVCEndpointTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationLocalCILocalVCEndpointTest.java index 4493e44b2e62..196813e7892e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationLocalCILocalVCEndpointTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationLocalCILocalVCEndpointTest.java @@ -1,11 +1,11 @@ -package de.tum.cit.aet.artemis.authorization; +package de.tum.cit.aet.artemis.core.authorization; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; /** * Contains the one automatic test covering all rest endpoints for authorization tests. diff --git a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationTestService.java b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationTestService.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationTestService.java rename to src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationTestService.java index d30d8649c258..473860f5b656 100644 --- a/src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/authorization/AuthorizationTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.authorization; +package de.tum.cit.aet.artemis.core.authorization; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; import static org.assertj.core.api.Fail.fail; diff --git a/src/test/java/de/tum/cit/aet/artemis/config/MetricsBeanTest.java b/src/test/java/de/tum/cit/aet/artemis/core/config/MetricsBeanTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/config/MetricsBeanTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/config/MetricsBeanTest.java index 9381a89aa3d1..969dcba1d7f8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/config/MetricsBeanTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/config/MetricsBeanTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.config; +package de.tum.cit.aet.artemis.core.config; import static org.assertj.core.api.Assertions.assertThat; @@ -12,29 +12,28 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.config.MetricsBean; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.ExerciseType; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; import io.micrometer.core.instrument.MeterRegistry; class MetricsBeanTest extends AbstractSpringIntegrationIndependentTest { @@ -69,7 +68,7 @@ class MetricsBeanTest extends AbstractSpringIntegrationIndependentTest { private TextExerciseUtilService textExerciseUtilService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private ExerciseRepository exerciseRepository; @@ -81,7 +80,7 @@ class MetricsBeanTest extends AbstractSpringIntegrationIndependentTest { private ExamRepository examRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @BeforeEach void resetDatabase() { diff --git a/src/test/java/de/tum/cit/aet/artemis/config/ProgrammingLanguageConfigurationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/config/ProgrammingLanguageConfigurationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/config/ProgrammingLanguageConfigurationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/config/ProgrammingLanguageConfigurationTest.java index 79b31842e033..6bfff32f6093 100644 --- a/src/test/java/de/tum/cit/aet/artemis/config/ProgrammingLanguageConfigurationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/config/ProgrammingLanguageConfigurationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.config; +package de.tum.cit.aet.artemis.core.config; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -13,7 +13,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.core.config.ProgrammingLanguageConfiguration; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.ProjectType; diff --git a/src/test/java/de/tum/cit/aet/artemis/config/TheiaConfigurationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/config/TheiaConfigurationTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/config/TheiaConfigurationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/config/TheiaConfigurationTest.java index 0d375e4189b2..1cdc46cc40b6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/config/TheiaConfigurationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/config/TheiaConfigurationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.config; +package de.tum.cit.aet.artemis.core.config; import static org.assertj.core.api.Assertions.assertThat; @@ -7,9 +7,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.config.TheiaConfiguration; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TheiaConfigurationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/config/TopicSubscriptionInterceptorTest.java b/src/test/java/de/tum/cit/aet/artemis/core/config/TopicSubscriptionInterceptorTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/config/TopicSubscriptionInterceptorTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/config/TopicSubscriptionInterceptorTest.java index 5627fc3d2e6f..22f258ad447a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/config/TopicSubscriptionInterceptorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/config/TopicSubscriptionInterceptorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.config; +package de.tum.cit.aet.artemis.core.config; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -14,11 +14,11 @@ import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.config.websocket.WebsocketConfiguration; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @SuppressWarnings("unchecked") class TopicSubscriptionInterceptorTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/connector/AeolusRequestMockProvider.java b/src/test/java/de/tum/cit/aet/artemis/core/connector/AeolusRequestMockProvider.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/connector/AeolusRequestMockProvider.java rename to src/test/java/de/tum/cit/aet/artemis/core/connector/AeolusRequestMockProvider.java index f7b1aba4682b..12ca6585f6c9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connector/AeolusRequestMockProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/connector/AeolusRequestMockProvider.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.connector; +package de.tum.cit.aet.artemis.core.connector; import static org.springframework.test.web.client.match.MockRestRequestMatchers.header; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; diff --git a/src/test/java/de/tum/cit/aet/artemis/connector/AthenaRequestMockProvider.java b/src/test/java/de/tum/cit/aet/artemis/core/connector/AthenaRequestMockProvider.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/connector/AthenaRequestMockProvider.java rename to src/test/java/de/tum/cit/aet/artemis/core/connector/AthenaRequestMockProvider.java index 6a252828c784..7bd43f43938f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connector/AthenaRequestMockProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/connector/AthenaRequestMockProvider.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.connector; +package de.tum.cit.aet.artemis.core.connector; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ATHENA; import static org.springframework.test.web.client.match.MockRestRequestMatchers.content; diff --git a/src/test/java/de/tum/cit/aet/artemis/connector/GitlabRequestMockProvider.java b/src/test/java/de/tum/cit/aet/artemis/core/connector/GitlabRequestMockProvider.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/connector/GitlabRequestMockProvider.java rename to src/test/java/de/tum/cit/aet/artemis/core/connector/GitlabRequestMockProvider.java index de0c4d7b77e1..8c23c2389c41 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connector/GitlabRequestMockProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/connector/GitlabRequestMockProvider.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.connector; +package de.tum.cit.aet.artemis.core.connector; import static org.gitlab4j.api.models.AccessLevel.DEVELOPER; import static org.gitlab4j.api.models.AccessLevel.GUEST; @@ -91,18 +91,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.UriService; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabException; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabUserDoesNotExistException; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabUserManagementService; import de.tum.cit.aet.artemis.programming.service.gitlab.dto.GitLabPersonalAccessTokenListResponseDTO; import de.tum.cit.aet.artemis.programming.service.gitlab.dto.GitLabPersonalAccessTokenResponseDTO; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; @Component @Profile("gitlab") @@ -156,13 +156,13 @@ public class GitlabRequestMockProvider { private GitLabUserManagementService gitLabUserManagementService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private UriService uriService; diff --git a/src/test/java/de/tum/cit/aet/artemis/connector/IrisRequestMockProvider.java b/src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/connector/IrisRequestMockProvider.java rename to src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java index c1791451de2f..4c7146242014 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connector/IrisRequestMockProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.connector; +package de.tum.cit.aet.artemis.core.connector; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; diff --git a/src/test/java/de/tum/cit/aet/artemis/connector/JenkinsRequestMockProvider.java b/src/test/java/de/tum/cit/aet/artemis/core/connector/JenkinsRequestMockProvider.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/connector/JenkinsRequestMockProvider.java rename to src/test/java/de/tum/cit/aet/artemis/core/connector/JenkinsRequestMockProvider.java index 857d73618eb0..827953bc0b68 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connector/JenkinsRequestMockProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/connector/JenkinsRequestMockProvider.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.connector; +package de.tum.cit.aet.artemis.core.connector; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.loadFileFromResources; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.loadFileFromResources; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.doNothing; @@ -48,9 +48,9 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.jenkins.dto.JenkinsUserDTO; import de.tum.cit.aet.artemis.programming.service.jenkins.jobs.JenkinsJobPermissionsService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; @Component @Profile("jenkins") @@ -82,7 +82,7 @@ public class JenkinsRequestMockProvider { private ObjectMapper mapper; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; private AutoCloseable closeable; diff --git a/src/test/java/de/tum/cit/aet/artemis/connector/apollon/ApollonRequestMockProvider.java b/src/test/java/de/tum/cit/aet/artemis/core/connector/apollon/ApollonRequestMockProvider.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/connector/apollon/ApollonRequestMockProvider.java rename to src/test/java/de/tum/cit/aet/artemis/core/connector/apollon/ApollonRequestMockProvider.java index e78953752827..6aadfedd8ecf 100644 --- a/src/test/java/de/tum/cit/aet/artemis/connector/apollon/ApollonRequestMockProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/connector/apollon/ApollonRequestMockProvider.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.connector.apollon; +package de.tum.cit.aet.artemis.core.connector.apollon; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_APOLLON; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; diff --git a/src/test/java/de/tum/cit/aet/artemis/dataexport/DataExportResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/dataexport/DataExportResourceIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/dataexport/DataExportResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/dataexport/DataExportResourceIntegrationTest.java index 6867828905d4..4b096cbba8ed 100644 --- a/src/test/java/de/tum/cit/aet/artemis/dataexport/DataExportResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/dataexport/DataExportResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.dataexport; +package de.tum.cit.aet.artemis.core.dataexport; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -26,13 +26,13 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.DataExport; import de.tum.cit.aet.artemis.core.domain.DataExportState; import de.tum.cit.aet.artemis.core.dto.DataExportDTO; import de.tum.cit.aet.artemis.core.dto.RequestDataExportDTO; -import de.tum.cit.aet.artemis.core.repository.DataExportRepository; import de.tum.cit.aet.artemis.core.service.export.DataExportService; +import de.tum.cit.aet.artemis.core.test_repository.DataExportTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @ExtendWith(MockitoExtension.class) class DataExportResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -42,7 +42,7 @@ class DataExportResourceIntegrationTest extends AbstractSpringIntegrationIndepen private static final String TEST_DATA_EXPORT_BASE_FILE_PATH = "src/test/resources/test-data/data-export/data-export.zip"; @Autowired - private DataExportRepository dataExportRepository; + private DataExportTestRepository dataExportRepository; @Autowired private DataExportService dataExportService; diff --git a/src/test/java/de/tum/cit/aet/artemis/ManagementResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/management/ManagementResourceIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/ManagementResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/management/ManagementResourceIntegrationTest.java index dea3d80e425b..af2b1996a62f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/ManagementResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/management/ManagementResourceIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core.management; -import static de.tum.cit.aet.artemis.util.RequestUtilService.deleteProgrammingExerciseParamsFalse; +import static de.tum.cit.aet.artemis.core.util.RequestUtilService.deleteProgrammingExerciseParamsFalse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doNothing; @@ -25,13 +25,14 @@ import de.tum.cit.aet.artemis.core.repository.PersistenceAuditEventRepository; import de.tum.cit.aet.artemis.core.service.feature.Feature; import de.tum.cit.aet.artemis.core.service.feature.FeatureToggleService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class ManagementResourceIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -41,7 +42,7 @@ class ManagementResourceIntegrationTest extends AbstractSpringIntegrationLocalCI private PersistenceAuditEventRepository persistenceAuditEventRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private FeatureToggleService featureToggleService; diff --git a/src/test/java/de/tum/cit/aet/artemis/management/SecurityMetersServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/management/SecurityMetersServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/management/SecurityMetersServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/management/SecurityMetersServiceTest.java index 7c12149cce8a..4706d74a8d8e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/management/SecurityMetersServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/management/SecurityMetersServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.management; +package de.tum.cit.aet.artemis.core.management; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.core.management.SecurityMetersService; import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; diff --git a/src/test/java/de/tum/cit/aet/artemis/migration/MigrationIntegrityTest.java b/src/test/java/de/tum/cit/aet/artemis/core/migration/MigrationIntegrityTest.java similarity index 89% rename from src/test/java/de/tum/cit/aet/artemis/migration/MigrationIntegrityTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/migration/MigrationIntegrityTest.java index 12b424e384f4..3c166028af7d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/migration/MigrationIntegrityTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/migration/MigrationIntegrityTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.migration; +package de.tum.cit.aet.artemis.core.migration; import static org.assertj.core.api.Assertions.assertThat; @@ -7,10 +7,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry; import de.tum.cit.aet.artemis.core.config.migration.MigrationRegistry; import de.tum.cit.aet.artemis.core.config.migration.MigrationService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class MigrationIntegrityTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/migration/MigrationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/migration/MigrationServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/migration/MigrationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/migration/MigrationServiceTest.java index cbba2e5333a8..3bcd37642d60 100644 --- a/src/test/java/de/tum/cit/aet/artemis/migration/MigrationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/migration/MigrationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.migration; +package de.tum.cit.aet.artemis.core.migration; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -22,16 +22,16 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Profiles; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry; import de.tum.cit.aet.artemis.core.config.migration.MigrationIntegrityException; import de.tum.cit.aet.artemis.core.config.migration.MigrationRegistry; import de.tum.cit.aet.artemis.core.config.migration.MigrationService; import de.tum.cit.aet.artemis.core.domain.MigrationChangelog; +import de.tum.cit.aet.artemis.core.migration.entries.TestChangeEntry20211214_231800; +import de.tum.cit.aet.artemis.core.migration.entries.TestChangeEntry20211215_231800; +import de.tum.cit.aet.artemis.core.migration.entries.TestChangeEntry20211216_231800; import de.tum.cit.aet.artemis.core.repository.MigrationChangeRepository; -import de.tum.cit.aet.artemis.migration.entries.TestChangeEntry20211214_231800; -import de.tum.cit.aet.artemis.migration.entries.TestChangeEntry20211215_231800; -import de.tum.cit.aet.artemis.migration.entries.TestChangeEntry20211216_231800; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class MigrationServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211214_231800.java b/src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211214_231800.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211214_231800.java rename to src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211214_231800.java index 0f9ab6a3e2ef..6088fb31fc61 100644 --- a/src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211214_231800.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211214_231800.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.migration.entries; +package de.tum.cit.aet.artemis.core.migration.entries; import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry; diff --git a/src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211215_231800.java b/src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211215_231800.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211215_231800.java rename to src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211215_231800.java index 86e875fc0a48..d83f1252815a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211215_231800.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211215_231800.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.migration.entries; +package de.tum.cit.aet.artemis.core.migration.entries; import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry; diff --git a/src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211216_231800.java b/src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211216_231800.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211216_231800.java rename to src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211216_231800.java index 69c3071a7a96..e017bdf4daf3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/migration/entries/TestChangeEntry20211216_231800.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/migration/entries/TestChangeEntry20211216_231800.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.migration.entries; +package de.tum.cit.aet.artemis.core.migration.entries; import de.tum.cit.aet.artemis.core.config.migration.MigrationEntry; diff --git a/src/test/java/de/tum/cit/aet/artemis/organization/OrganizationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/organization/OrganizationIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/organization/OrganizationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/organization/OrganizationIntegrationTest.java index 21afb3fd3288..dad160c47970 100644 --- a/src/test/java/de/tum/cit/aet/artemis/organization/OrganizationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/organization/OrganizationIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.organization; +package de.tum.cit.aet.artemis.core.organization; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -13,14 +13,15 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Organization; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.OrganizationCountDTO; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; +import de.tum.cit.aet.artemis.core.organization.util.OrganizationUtilService; import de.tum.cit.aet.artemis.core.repository.OrganizationRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class OrganizationIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -46,7 +47,7 @@ void testGetCoursesToEnrollWithOrganizationsEnabled() throws Exception { User student = userUtilService.createAndSaveUser(TEST_PREFIX + "login2"); student.setOrganizations(organizations); - userRepository.save(student); + userTestRepository.save(student); ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(5); ZonedDateTime futureTimestamp = ZonedDateTime.now().plusDays(5); @@ -81,7 +82,7 @@ void testEnrollForCourseWithOrganizationsEnabled() throws Exception { User student = userUtilService.createAndSaveUser(TEST_PREFIX + "login1"); student.setOrganizations(organizations); - userRepository.save(student); + userTestRepository.save(student); ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(5); ZonedDateTime futureTimestamp = ZonedDateTime.now().plusDays(5); @@ -297,7 +298,7 @@ void testGetNumberOfUsersAndCoursesOfAllOrganizations() throws Exception { courseRepository.addOrganizationToCourse(course1.getId(), organization); User student = userUtilService.createAndSaveUser(TEST_PREFIX + "testGetNumberOfUsersOfAll_"); - userRepository.addOrganizationToUser(student.getId(), organization); + userTestRepository.addOrganizationToUser(student.getId(), organization); List result = request.getList("/api/admin/organizations/count-all", HttpStatus.OK, OrganizationCountDTO.class); @@ -322,7 +323,7 @@ void testGetNumberOfUsersAndCoursesOfOrganization() throws Exception { courseRepository.addOrganizationToCourse(course1.getId(), organization); User student = userUtilService.createAndSaveUser(TEST_PREFIX + "testGetNumberOfUsers_"); - userRepository.addOrganizationToUser(student.getId(), organization); + userTestRepository.addOrganizationToUser(student.getId(), organization); OrganizationCountDTO result = request.get("/api/admin/organizations/" + organization.getId() + "/count", HttpStatus.OK, OrganizationCountDTO.class); @@ -345,10 +346,10 @@ void testGetOrganizationById() throws Exception { User student = userUtilService.createAndSaveUser(TEST_PREFIX + "testGetOrganizationById"); - userRepository.addOrganizationToUser(student.getId(), organization); + userTestRepository.addOrganizationToUser(student.getId(), organization); // invoked remove to make sure it works correctly - userRepository.removeOrganizationFromUser(student.getId(), organization); - userRepository.addOrganizationToUser(student.getId(), organization); + userTestRepository.removeOrganizationFromUser(student.getId(), organization); + userTestRepository.addOrganizationToUser(student.getId(), organization); Organization result = request.get("/api/admin/organizations/" + organization.getId(), HttpStatus.OK, Organization.class); Organization resultWithCoursesAndUsers = request.get("/api/admin/organizations/" + organization.getId() + "/full", HttpStatus.OK, Organization.class); @@ -389,7 +390,7 @@ void testGetAllOrganizationByUser() throws Exception { organization = organizationRepo.save(organization); User student = userUtilService.createAndSaveUser(TEST_PREFIX + "testGetAllOrganizationByUser"); - userRepository.addOrganizationToUser(student.getId(), organization); + userTestRepository.addOrganizationToUser(student.getId(), organization); List result = request.getList("/api/admin/organizations/users/" + student.getId(), HttpStatus.OK, Organization.class); diff --git a/src/test/java/de/tum/cit/aet/artemis/organization/OrganizationFactory.java b/src/test/java/de/tum/cit/aet/artemis/core/organization/util/OrganizationFactory.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/organization/OrganizationFactory.java rename to src/test/java/de/tum/cit/aet/artemis/core/organization/util/OrganizationFactory.java index c6a653ef11e5..55f79839a12f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/organization/OrganizationFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/organization/util/OrganizationFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.organization; +package de.tum.cit.aet.artemis.core.organization.util; import de.tum.cit.aet.artemis.core.domain.Organization; diff --git a/src/test/java/de/tum/cit/aet/artemis/organization/OrganizationUtilService.java b/src/test/java/de/tum/cit/aet/artemis/core/organization/util/OrganizationUtilService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/organization/OrganizationUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/core/organization/util/OrganizationUtilService.java index 7054de6fa823..b2a3bb7c0318 100644 --- a/src/test/java/de/tum/cit/aet/artemis/organization/OrganizationUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/organization/util/OrganizationUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.organization; +package de.tum.cit.aet.artemis.core.organization.util; import java.util.UUID; diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/ParticipationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/core/repository/ParticipationTestRepository.java deleted file mode 100644 index a178f9203186..000000000000 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/ParticipationTestRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.tum.cit.aet.artemis.core.repository; - -import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; - -import java.util.List; - -import org.springframework.data.jpa.repository.EntityGraph; -import org.springframework.stereotype.Repository; - -import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; -import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; - -@Repository -public interface ParticipationTestRepository extends ArtemisJpaRepository { - - @EntityGraph(type = LOAD, attributePaths = { "submissions" }) - List findByExercise_ExerciseGroup_Exam_Id(long examId); -} diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/UserTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/core/repository/UserTestRepository.java deleted file mode 100644 index 4e733c14d095..000000000000 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/UserTestRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.tum.cit.aet.artemis.core.repository; - -import java.util.Set; - -import org.springframework.stereotype.Repository; - -import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; - -@Repository -public interface UserTestRepository extends ArtemisJpaRepository { - - Set findAllByGroupsNotEmpty(); -} diff --git a/src/test/java/de/tum/cit/aet/artemis/security/Lti13LaunchFilterTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/Lti13LaunchFilterTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/security/Lti13LaunchFilterTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/Lti13LaunchFilterTest.java index ede5772ee666..4bc65daa9a32 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/Lti13LaunchFilterTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/Lti13LaunchFilterTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security; +package de.tum.cit.aet.artemis.core.security; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -48,8 +48,8 @@ import de.tum.cit.aet.artemis.lti.config.CustomLti13Configurer; import de.tum.cit.aet.artemis.lti.config.Lti13LaunchFilter; import de.tum.cit.aet.artemis.lti.domain.LtiPlatformConfiguration; -import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; import de.tum.cit.aet.artemis.lti.service.Lti13Service; +import de.tum.cit.aet.artemis.lti.test_repository.LtiPlatformConfigurationTestRepository; import uk.ac.ox.ctl.lti13.lti.Claims; import uk.ac.ox.ctl.lti13.security.oauth2.client.lti.authentication.OidcAuthenticationToken; import uk.ac.ox.ctl.lti13.security.oauth2.client.lti.web.OAuth2LoginAuthenticationFilter; @@ -84,7 +84,7 @@ class Lti13LaunchFilterTest { private OidcIdToken idToken; @Mock - private LtiPlatformConfigurationRepository ltiPlatformConfigurationRepository; + private LtiPlatformConfigurationTestRepository ltiPlatformConfigurationRepository; private Lti13LaunchFilter launchFilter; diff --git a/src/test/java/de/tum/cit/aet/artemis/security/OAuth2JWKSServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/OAuth2JWKSServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/security/OAuth2JWKSServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/OAuth2JWKSServiceTest.java index 9b195b99b013..23107fc2e6c6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/OAuth2JWKSServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/OAuth2JWKSServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security; +package de.tum.cit.aet.artemis.core.security; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/src/test/java/de/tum/cit/aet/artemis/security/SecurityUtilsUnitTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/SecurityUtilsUnitTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/security/SecurityUtilsUnitTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/SecurityUtilsUnitTest.java index 0eaa3688a2f5..285fe52f0505 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/SecurityUtilsUnitTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/SecurityUtilsUnitTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security; +package de.tum.cit.aet.artemis.core.security; import static org.assertj.core.api.Assertions.assertThat; @@ -15,9 +15,6 @@ import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; -import de.tum.cit.aet.artemis.core.security.Role; -import de.tum.cit.aet.artemis.core.security.SecurityUtils; - /** * Test class for the {@link SecurityUtils} utility class. */ diff --git a/src/test/java/de/tum/cit/aet/artemis/security/jwt/JWTFilterTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/jwt/JWTFilterTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/security/jwt/JWTFilterTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/jwt/JWTFilterTest.java index 7a8affac1840..59392188c127 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/jwt/JWTFilterTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/jwt/JWTFilterTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security.jwt; +package de.tum.cit.aet.artemis.core.security.jwt; import static org.assertj.core.api.Assertions.assertThat; @@ -19,8 +19,6 @@ import de.tum.cit.aet.artemis.core.management.SecurityMetersService; import de.tum.cit.aet.artemis.core.security.Role; -import de.tum.cit.aet.artemis.core.security.jwt.JWTFilter; -import de.tum.cit.aet.artemis.core.security.jwt.TokenProvider; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; import io.micrometer.core.instrument.simple.SimpleMeterRegistry; diff --git a/src/test/java/de/tum/cit/aet/artemis/security/jwt/TokenProviderSecurityMetersTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/jwt/TokenProviderSecurityMetersTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/security/jwt/TokenProviderSecurityMetersTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/jwt/TokenProviderSecurityMetersTest.java index d4e405ddb07b..40e8abfc01f8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/jwt/TokenProviderSecurityMetersTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/jwt/TokenProviderSecurityMetersTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security.jwt; +package de.tum.cit.aet.artemis.core.security.jwt; import static org.assertj.core.api.Assertions.assertThat; @@ -19,7 +19,6 @@ import de.tum.cit.aet.artemis.core.management.SecurityMetersService; import de.tum.cit.aet.artemis.core.security.Role; -import de.tum.cit.aet.artemis.core.security.jwt.TokenProvider; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; diff --git a/src/test/java/de/tum/cit/aet/artemis/security/jwt/TokenProviderTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/jwt/TokenProviderTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/security/jwt/TokenProviderTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/jwt/TokenProviderTest.java index 4f7dd1278831..11001e768351 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/jwt/TokenProviderTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/jwt/TokenProviderTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security.jwt; +package de.tum.cit.aet.artemis.core.security.jwt; import static org.assertj.core.api.Assertions.assertThat; @@ -20,7 +20,6 @@ import de.tum.cit.aet.artemis.core.management.SecurityMetersService; import de.tum.cit.aet.artemis.core.security.Role; -import de.tum.cit.aet.artemis.core.security.jwt.TokenProvider; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; diff --git a/src/test/java/de/tum/cit/aet/artemis/security/lti/Lti13TokenRetrieverTest.java b/src/test/java/de/tum/cit/aet/artemis/core/security/lti/Lti13TokenRetrieverTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/security/lti/Lti13TokenRetrieverTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/security/lti/Lti13TokenRetrieverTest.java index fbe80b802552..764824a74fe1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/security/lti/Lti13TokenRetrieverTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/security/lti/Lti13TokenRetrieverTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.security.lti; +package de.tum.cit.aet.artemis.core.security.lti; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/AssessmentServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/AssessmentServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/AssessmentServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/AssessmentServiceTest.java index 6381739b4e96..673f3c13f07c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/AssessmentServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/AssessmentServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; @@ -15,35 +15,35 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.AssessmentService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseFactory; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class AssessmentServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -53,10 +53,10 @@ class AssessmentServiceTest extends AbstractSpringIntegrationIndependentTest { private ExerciseRepository exerciseRepository; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired private AssessmentService assessmentService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/AuthorizationCheckServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/AuthorizationCheckServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/AuthorizationCheckServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/AuthorizationCheckServiceTest.java index ad12373c554e..555baf1d0284 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/AuthorizationCheckServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/AuthorizationCheckServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -13,19 +13,18 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.stereotype.Component; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class AuthorizationCheckServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -108,10 +107,10 @@ class IsUserAllowedToEnrollForCourseTest { // We need our own courseService here that overshadows the one from the CourseServiceTest, so that the new property is applied to it. @Autowired - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; private User student1; @@ -209,7 +208,7 @@ class IsUserAllowedToUnenrollFromCourseTest { private AuthorizationCheckService authCheckService; @Autowired - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; private User student; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ConductAgreementServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/ConductAgreementServiceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/service/ConductAgreementServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/ConductAgreementServiceTest.java index fa9b00991456..af5a850b5127 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ConductAgreementServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/ConductAgreementServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; @@ -9,10 +9,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.service.ConductAgreementService; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ConductAgreementServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/export/CourseExamExportServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/CourseExamExportServiceTest.java similarity index 89% rename from src/test/java/de/tum/cit/aet/artemis/service/export/CourseExamExportServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/CourseExamExportServiceTest.java index 7b4f43fcf28e..719f1b47a0d9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/export/CourseExamExportServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/CourseExamExportServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.export; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; @@ -14,14 +14,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.service.export.CourseExamExportService; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class CourseExamExportServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -43,7 +43,7 @@ class CourseExamExportServiceTest extends AbstractSpringIntegrationIndependentTe private ExerciseRepository exerciseRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @BeforeEach void setup() { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/CourseServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/CourseServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/CourseServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/CourseServiceTest.java index 680d96836fec..b6483580a761 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/CourseServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/CourseServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -20,22 +20,21 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.dto.StudentDTO; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.core.service.CourseService; import de.tum.cit.aet.artemis.core.service.ldap.LdapUserDto; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class CourseServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -45,13 +44,13 @@ class CourseServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { private CourseService courseService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired private ExerciseRepository exerciseRepo; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/DataExportCreationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/DataExportCreationServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/DataExportCreationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/DataExportCreationServiceTest.java index fc0a0b948021..d4f16c93604a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/DataExportCreationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/DataExportCreationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -40,44 +40,44 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.web.client.RestTemplate; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEventType; +import de.tum.cit.aet.artemis.atlas.science.util.ScienceUtilService; import de.tum.cit.aet.artemis.communication.repository.AnswerPostRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; -import de.tum.cit.aet.artemis.connector.apollon.ApollonRequestMockProvider; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; +import de.tum.cit.aet.artemis.core.connector.apollon.ApollonRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DataExport; import de.tum.cit.aet.artemis.core.domain.DataExportState; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.DataExportRepository; import de.tum.cit.aet.artemis.core.service.export.DataExportCreationService; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.DataExportTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; +import de.tum.cit.aet.artemis.fileupload.util.ZipFileTestUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.service.apollon.ApollonConversionService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; -import de.tum.cit.aet.artemis.post.ConversationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.science.ScienceUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; -import de.tum.cit.aet.artemis.util.ZipFileTestUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class DataExportCreationServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -116,13 +116,13 @@ class DataExportCreationServiceTest extends AbstractSpringIntegrationJenkinsGitl private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private ExerciseRepository exerciseRepository; @Autowired - private DataExportRepository dataExportRepository; + private DataExportTestRepository dataExportRepository; @Autowired private DataExportCreationService dataExportCreationService; @@ -153,7 +153,7 @@ class DataExportCreationServiceTest extends AbstractSpringIntegrationJenkinsGitl private QuizExerciseUtilService quizExerciseUtilService; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private AnswerPostRepository answerPostRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/scheduled/DataExportScheduleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/DataExportScheduleServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/scheduled/DataExportScheduleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/DataExportScheduleServiceTest.java index 1e4ea8f17ac3..aac8fe17f6ec 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/scheduled/DataExportScheduleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/DataExportScheduleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.scheduled; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -26,13 +26,12 @@ import org.springframework.scheduling.config.ScheduledTask; import org.springframework.scheduling.config.ScheduledTaskHolder; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.DataExport; import de.tum.cit.aet.artemis.core.domain.DataExportState; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.DataExportRepository; -import de.tum.cit.aet.artemis.core.service.DataExportScheduleService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.test_repository.DataExportTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @ExtendWith(MockitoExtension.class) class DataExportScheduleServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -40,7 +39,7 @@ class DataExportScheduleServiceTest extends AbstractSpringIntegrationIndependent private static final String TEST_PREFIX = "dataexportscheduleservice"; @Autowired - private DataExportRepository dataExportRepository; + private DataExportTestRepository dataExportRepository; @Autowired private DataExportScheduleService dataExportScheduleService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/FeatureToggleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/FeatureToggleServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/FeatureToggleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/FeatureToggleServiceTest.java index fa61f4845bf7..78bc35e2cdad 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/FeatureToggleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/FeatureToggleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; @@ -9,9 +9,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.service.feature.Feature; import de.tum.cit.aet.artemis.core.service.feature.FeatureToggleService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FeatureToggleServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/FilePathServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/FilePathServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/FilePathServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/FilePathServiceTest.java index 4d27ceaf1a38..2f51c9677b9d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/FilePathServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/FilePathServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -8,10 +8,8 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.exception.FilePathParsingException; -import de.tum.cit.aet.artemis.core.service.FilePathService; -import de.tum.cit.aet.artemis.core.service.FileService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FilePathServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/FileServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/FileServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/FileServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/FileServiceTest.java index a0987c14405d..74b85b6bf9f6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/FileServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/FileServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -42,10 +42,7 @@ import org.springframework.util.ResourceUtils; import org.springframework.web.multipart.MultipartFile; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.service.FilePathService; -import de.tum.cit.aet.artemis.core.service.FileService; -import de.tum.cit.aet.artemis.core.service.ResourceLoaderService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FileServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ResourceLoaderServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/ResourceLoaderServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/service/ResourceLoaderServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/ResourceLoaderServiceTest.java index 8c6a4c36d0dc..845c645030c9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ResourceLoaderServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/ResourceLoaderServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -27,8 +27,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.service.ResourceLoaderService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ResourceLoaderServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/telemetry/TelemetryServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/TelemetryServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/telemetry/TelemetryServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/TelemetryServiceTest.java index 715456049f53..c820f3fb0bb0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/telemetry/TelemetryServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/TelemetryServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.telemetry; +package de.tum.cit.aet.artemis.core.service; import static java.util.concurrent.TimeUnit.SECONDS; import static org.mockito.Mockito.spy; @@ -25,8 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.service.TelemetryService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @ExtendWith(MockitoExtension.class) class TelemetryServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/TitleCacheEvictionServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/TitleCacheEvictionServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/TitleCacheEvictionServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/TitleCacheEvictionServiceTest.java index ad05b894c856..f9991fa36fc4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/TitleCacheEvictionServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/TitleCacheEvictionServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; @@ -9,24 +9,23 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.CacheManager; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.core.organization.util.OrganizationUtilService; import de.tum.cit.aet.artemis.core.repository.OrganizationRepository; -import de.tum.cit.aet.artemis.core.service.TitleCacheEvictionService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.core.util.Tuple; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.repository.ApollonDiagramRepository; -import de.tum.cit.aet.artemis.organization.OrganizationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.repository.hestia.ExerciseHintRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; /** * Test for {@link TitleCacheEvictionService} that should evict entity titles from the title caches if the titles are diff --git a/src/test/java/de/tum/cit/aet/artemis/service/UriServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/UriServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/UriServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/UriServiceTest.java index 2b2cfeb104c2..024ae81df398 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/UriServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/UriServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -8,12 +8,12 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.exception.VersionControlException; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.SolutionProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.TemplateProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class UriServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ZipFileServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/ZipFileServiceTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/ZipFileServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/ZipFileServiceTest.java index cbbeea2e1fe3..045035ad138c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ZipFileServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/ZipFileServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.core.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; @@ -12,8 +12,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.service.ZipFileService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ZipFileServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/util/HttpRequestUtilsTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/util/HttpRequestUtilsTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/util/HttpRequestUtilsTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/util/HttpRequestUtilsTest.java index 32e85699d42e..13602e7a3f03 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/util/HttpRequestUtilsTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/util/HttpRequestUtilsTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.util; +package de.tum.cit.aet.artemis.core.service.util; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.anyString; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/util/TimeUtilTest.java b/src/test/java/de/tum/cit/aet/artemis/core/service/util/TimeUtilTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/util/TimeUtilTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/service/util/TimeUtilTest.java index fd7ff2fe7bdf..f8a1af0cd59b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/util/TimeUtilTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/service/util/TimeUtilTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.util; +package de.tum.cit.aet.artemis.core.service.util; import static de.tum.cit.aet.artemis.core.util.TimeUtil.toRelativeTime; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/core/test_repository/CourseTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/core/test_repository/CourseTestRepository.java new file mode 100644 index 000000000000..df35e0c91aa1 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/core/test_repository/CourseTestRepository.java @@ -0,0 +1,27 @@ +package de.tum.cit.aet.artemis.core.test_repository; + +import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; + +import java.util.Optional; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.repository.CourseRepository; + +@Repository +@Primary +public interface CourseTestRepository extends CourseRepository { + + @EntityGraph(type = LOAD, attributePaths = { "competencies", "prerequisites", "learningPaths", "learningPaths.competencies" }) + Optional findWithEagerLearningPathsAndCompetenciesAndPrerequisitesById(long courseId); + + @NotNull + default Course findWithEagerLearningPathsAndCompetenciesAndPrerequisitesByIdElseThrow(long courseId) { + return getValueElseThrow(findWithEagerLearningPathsAndCompetenciesAndPrerequisitesById(courseId), courseId); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/core/test_repository/DataExportTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/core/test_repository/DataExportTestRepository.java new file mode 100644 index 000000000000..cbd4a5fbd501 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/core/test_repository/DataExportTestRepository.java @@ -0,0 +1,22 @@ +package de.tum.cit.aet.artemis.core.test_repository; + +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.core.domain.DataExport; +import de.tum.cit.aet.artemis.core.repository.DataExportRepository; + +@Repository +@Primary +public interface DataExportTestRepository extends DataExportRepository { + + @Query(""" + SELECT dataExport + FROM DataExport dataExport + WHERE dataExport.dataExportState = 2 + """) + Set findAllSuccessfullyCreatedDataExports(); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/core/test_repository/UserTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/core/test_repository/UserTestRepository.java new file mode 100644 index 000000000000..2e3623ba1e55 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/core/test_repository/UserTestRepository.java @@ -0,0 +1,78 @@ +package de.tum.cit.aet.artemis.core.test_repository; + +import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.core.repository.UserRepository; + +@Repository +@Primary +public interface UserTestRepository extends UserRepository { + + Set findAllByGroupsNotEmpty(); + + @EntityGraph(type = LOAD, attributePaths = { "groups", "authorities" }) + Set findAllWithGroupsAndAuthoritiesByIsDeletedIsFalse(); + + @Query(""" + SELECT user.id + FROM User user + WHERE user.isDeleted = FALSE + """) + List findUserIdsByIsDeletedIsFalse(Pageable pageable); + + @Query(""" + SELECT COUNT(user) + FROM User user + WHERE user.isDeleted = FALSE + """) + long countUsersByIsDeletedIsFalse(); + + /** + * Retrieves a paginated list of {@link User} entities that are not marked as deleted, + * with their associated groups. + * + * @param pageable the pagination information. + * @return a paginated list of {@link User} entities that are not marked as deleted. If no entities are found, returns an empty page. + */ + default Page findAllWithGroupsByIsDeletedIsFalse(Pageable pageable) { + List ids = findUserIdsByIsDeletedIsFalse(pageable); + if (ids.isEmpty()) { + return Page.empty(pageable); + } + List users = findUsersWithGroupsByIdIn(ids); + long total = countUsersByIsDeletedIsFalse(); + return new PageImpl<>(users, pageable, total); + } + + @EntityGraph(type = LOAD, attributePaths = { "learningPaths" }) + Optional findOneWithLearningPathsByLogin(String login); + + @EntityGraph(type = LOAD, attributePaths = { "learningPaths" }) + Optional findWithLearningPathsById(long userId); + + /** + * Find user with eagerly loaded learning paths by its id + * + * @param userId the id of the user to find + * @return the user with learning paths if it exists, else throw exception + */ + @NotNull + default User findWithLearningPathsByIdElseThrow(long userId) { + return getValueElseThrow(findWithLearningPathsById(userId), userId); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/user/AccountResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/user/AccountResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceIntegrationTest.java index 86054d9adeba..63843e7bee8f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/user/AccountResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.user; +package de.tum.cit.aet.artemis.core.user; import static org.assertj.core.api.Assertions.assertThat; @@ -13,7 +13,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.PasswordChangeDTO; @@ -22,9 +21,11 @@ import de.tum.cit.aet.artemis.core.dto.vm.ManagedUserVM; import de.tum.cit.aet.artemis.core.service.AccountService; import de.tum.cit.aet.artemis.core.service.user.PasswordService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.core.util.ConfigUtil; import de.tum.cit.aet.artemis.core.web.AccountResource; import de.tum.cit.aet.artemis.core.web.open.PublicAccountResource; -import de.tum.cit.aet.artemis.util.ConfigUtil; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * Tests {@link AccountResource}. Several Tests rely on overwriting AccountResource.registrationEnabled and other attributes with reflections. Any changes to the internal @@ -170,7 +171,7 @@ void activateAccount() throws Exception { User user = UserFactory.generateActivatedUser("ab123cdm"); user.setActivated(false); user.setActivationKey(testActivationKey); - user = userRepository.save(user); + user = userTestRepository.save(user); // make request LinkedMultiValueMap params = new LinkedMultiValueMap<>(); @@ -178,7 +179,7 @@ void activateAccount() throws Exception { request.get("/api/public/activate", HttpStatus.OK, String.class, params); // check result - Optional updatedUser = userRepository.findById(user.getId()); + Optional updatedUser = userTestRepository.findById(user.getId()); assertThat(updatedUser).isPresent(); assertThat(updatedUser.get()).isNotNull(); assertThat(updatedUser.get().getActivated()).isTrue(); @@ -247,7 +248,7 @@ void saveAccount() throws Exception { request.put("/api/account", new UserDTO(user), HttpStatus.OK); // check if update successful - Optional updatedUser = userRepository.findOneByLogin(AUTHENTICATEDUSER); + Optional updatedUser = userTestRepository.findOneByLogin(AUTHENTICATEDUSER); assertThat(updatedUser).isPresent(); assertThat(updatedUser.get().getFirstName()).isEqualTo(updatedFirstName); } @@ -293,7 +294,7 @@ void changePassword() throws Exception { request.postWithoutLocation("/api/account/change-password", pwChange, HttpStatus.OK, null); // check if update successful - Optional updatedUser = userRepository.findOneByLogin(AUTHENTICATEDUSER); + Optional updatedUser = userTestRepository.findOneByLogin(AUTHENTICATEDUSER); assertThat(updatedUser).isPresent(); assertThat(passwordService.checkPasswordMatch(updatedPassword, updatedUser.get().getPassword())).isTrue(); } @@ -305,7 +306,7 @@ void changePasswordExternalUser() throws Throwable { // create user in repo User user = userUtilService.createAndSaveUser(AUTHENTICATEDUSER); user.setInternal(false); - userRepository.save(user); + userTestRepository.save(user); // Password Data String updatedPassword = "12345678"; @@ -340,14 +341,14 @@ void changeLanguageKey() throws Exception { // create user in repo User user = userUtilService.createAndSaveUser(AUTHENTICATEDUSER); user.setLangKey("en"); - User storedUser = userRepository.save(user); + User storedUser = userTestRepository.save(user); assertThat(storedUser.getLangKey()).isEqualTo("en"); // make request request.postStringWithoutLocation("/api/public/account/change-language", "de", HttpStatus.OK, null); // check result - Optional updatedUser = userRepository.findOneByLogin(AUTHENTICATEDUSER); + Optional updatedUser = userTestRepository.findOneByLogin(AUTHENTICATEDUSER); assertThat(updatedUser).isPresent(); assertThat(updatedUser.get().getLangKey()).isEqualTo("de"); } @@ -358,7 +359,7 @@ void changeLanguageKeyNotSupported() throws Exception { // create user in repo User user = userUtilService.createAndSaveUser(AUTHENTICATEDUSER); user.setLangKey("en"); - User storedUser = userRepository.save(user); + User storedUser = userTestRepository.save(user); assertThat(storedUser.getLangKey()).isEqualTo("en"); // make request @@ -371,7 +372,7 @@ void passwordResetByEmail() throws Exception { // create user in repo User createdUser = userUtilService.createAndSaveUser(AUTHENTICATEDUSER); - Optional userBefore = userRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); + Optional userBefore = userTestRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); assertThat(userBefore).isPresent(); String resetKeyBefore = userBefore.get().getResetKey(); @@ -386,7 +387,7 @@ void passwordResetByUsername() throws Exception { // create user in repo User createdUser = userUtilService.createAndSaveUser(AUTHENTICATEDUSER); - Optional userBefore = userRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); + Optional userBefore = userTestRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); assertThat(userBefore).isPresent(); String resetKeyBefore = userBefore.get().getResetKey(); @@ -396,7 +397,7 @@ void passwordResetByUsername() throws Exception { private void verifyPasswordReset(User createdUser, String resetKeyBefore) throws Exception { // check user data - Optional userPasswordResetInit = userRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); + Optional userPasswordResetInit = userTestRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); assertThat(userPasswordResetInit).isPresent(); String resetKey = userPasswordResetInit.get().getResetKey(); @@ -413,7 +414,7 @@ private void verifyPasswordReset(User createdUser, String resetKeyBefore) throws request.postWithoutLocation("/api/public/account/reset-password/finish", finishResetData, HttpStatus.OK, null); // get updated user - Optional userPasswordResetFinished = userRepository.findOneByLogin(AUTHENTICATEDUSER); + Optional userPasswordResetFinished = userTestRepository.findOneByLogin(AUTHENTICATEDUSER); assertThat(userPasswordResetFinished).isPresent(); assertThat(passwordService.checkPasswordMatch(newPassword, userPasswordResetFinished.get().getPassword())).isTrue(); } @@ -423,7 +424,7 @@ void passwordResetInvalidEmail() throws Exception { // create user in repo User createdUser = userUtilService.createAndSaveUser(AUTHENTICATEDUSER); - Optional userBefore = userRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); + Optional userBefore = userTestRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); assertThat(userBefore).isPresent(); String resetKeyBefore = userBefore.get().getResetKey(); @@ -431,7 +432,7 @@ void passwordResetInvalidEmail() throws Exception { request.postStringWithoutLocation("/api/public/account/reset-password/init", "invalidemail", HttpStatus.OK, null); // check user data - Optional userPasswordResetInit = userRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); + Optional userPasswordResetInit = userTestRepository.findOneByEmailIgnoreCase(createdUser.getEmail()); assertThat(userPasswordResetInit).isPresent(); String resetKey = userPasswordResetInit.get().getResetKey(); @@ -447,7 +448,7 @@ void passwordResetInitUserExternal() throws Throwable { user.setLogin(login); user.setEmail(email); user.setInternal(false); - userRepository.saveAndFlush(user); + userTestRepository.saveAndFlush(user); request.postStringWithoutLocation("/api/public/account/reset-password/init", email, HttpStatus.BAD_REQUEST, null); } diff --git a/src/test/java/de/tum/cit/aet/artemis/user/AccountResourceWithGitLabIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceWithGitLabIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/user/AccountResourceWithGitLabIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceWithGitLabIntegrationTest.java index 92bd3fd41630..ea8267af3d4e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/user/AccountResourceWithGitLabIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/user/AccountResourceWithGitLabIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.user; +package de.tum.cit.aet.artemis.core.user; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.anyLong; @@ -18,10 +18,11 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.connector.GitlabRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.GitlabRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.vm.ManagedUserVM; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class AccountResourceWithGitLabIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -70,7 +71,7 @@ void testUnactivatedUserIsDeletedDespiteUnableToDeleteInGitlab() throws Exceptio user.setActivated(false); user.setFirstName("Old Firstname"); user.setActivationKey(testActivationKey); - user = userRepository.save(user); + user = userTestRepository.save(user); // setup user to register user.setFirstName("New Firstname"); @@ -88,7 +89,7 @@ void testUnactivatedUserIsDeletedDespiteUnableToDeleteInGitlab() throws Exceptio request.postWithoutLocation("/api/public/register", userVM, HttpStatus.CREATED, null); // Assert that old user data was deleted and user was written to db - Optional updatedUser = userRepository.findOneByLogin(user.getLogin()); + Optional updatedUser = userTestRepository.findOneByLogin(user.getLogin()); assertThat(updatedUser).isPresent(); assertThat(updatedUser.get().getFirstName()).isEqualTo("New Firstname"); assertThat(updatedUser.get().getActivated()).isFalse(); @@ -104,7 +105,7 @@ void testFailureWhenTryingToDeleteActivatedUser() throws Exception { // create activated user in repo User user = UserFactory.generateActivatedUser("ab123cde"); user.setFirstName("Old Firstname"); - user = userRepository.save(user); + user = userTestRepository.save(user); // setup user to register user.setFirstName("New Firstname"); @@ -120,7 +121,7 @@ void testFailureWhenTryingToDeleteActivatedUser() throws Exception { request.postWithoutLocation("/api/public/register", userVM, HttpStatus.BAD_REQUEST, null); // Assert that old user data is still there - Optional updatedUser = userRepository.findOneByLogin(user.getLogin()); + Optional updatedUser = userTestRepository.findOneByLogin(user.getLogin()); assertThat(updatedUser).isPresent(); assertThat(updatedUser.get().getFirstName()).isEqualTo("Old Firstname"); assertThat(updatedUser.get().getActivated()).isTrue(); @@ -143,7 +144,7 @@ void testShouldNotRegisterUserIfCannotCreateInGitlab() throws Exception { request.postWithoutLocation("/api/public/register", userVM, HttpStatus.INTERNAL_SERVER_ERROR, null); // The account shouldn't be saved - assertThat(userRepository.findOneByLogin(user.getLogin())).isEmpty(); + assertThat(userTestRepository.findOneByLogin(user.getLogin())).isEmpty(); // make another request doReturn(new org.gitlab4j.api.models.User().withId(1L)).when(mock(UserApi.class)).getUser(user.getLogin()); @@ -151,7 +152,7 @@ void testShouldNotRegisterUserIfCannotCreateInGitlab() throws Exception { request.postWithoutLocation("/api/public/register", userVM, HttpStatus.INTERNAL_SERVER_ERROR, null); // The account shouldn't be saved - assertThat(userRepository.findOneByLogin(user.getLogin())).isEmpty(); + assertThat(userTestRepository.findOneByLogin(user.getLogin())).isEmpty(); } @Test @@ -170,7 +171,7 @@ void testShouldRegisterUserIfCanCreateAndDeactivateAccountInGitlab() throws Exce gitlabRequestMockProvider.mockDeactivateUser(user.getLogin(), false); request.postWithoutLocation("/api/public/register", userVM, HttpStatus.CREATED, null); - assertThat(userRepository.findOneByLogin(user.getLogin())).isPresent(); + assertThat(userTestRepository.findOneByLogin(user.getLogin())).isPresent(); } @Test @@ -189,7 +190,7 @@ void testShouldAbortRegistrationAndFailIfCannotDeactivateAccountInGitlab() throw gitlabRequestMockProvider.mockDeactivateUser(user.getLogin(), true); request.postWithoutLocation("/api/public/register", userVM, HttpStatus.INTERNAL_SERVER_ERROR, null); - assertThat(userRepository.findOneByLogin(user.getLogin())).isEmpty(); + assertThat(userTestRepository.findOneByLogin(user.getLogin())).isEmpty(); } @Test @@ -208,7 +209,7 @@ void testShouldActivateUserInGitlab() throws Exception { gitlabRequestMockProvider.mockDeactivateUser(user.getLogin(), false); request.postWithoutLocation("/api/public/register", userVM, HttpStatus.CREATED, null); - Optional registeredUser = userRepository.findOneByLogin(user.getLogin()); + Optional registeredUser = userTestRepository.findOneByLogin(user.getLogin()); assertThat(registeredUser).isPresent(); // Activate the user @@ -233,7 +234,7 @@ void testShouldThrowErrorIfCannotActivateUserInGitlab() throws Exception { gitlabRequestMockProvider.mockDeactivateUser(user.getLogin(), false); request.postWithoutLocation("/api/public/register", userVM, HttpStatus.CREATED, null); - Optional registeredUser = userRepository.findOneByLogin(user.getLogin()); + Optional registeredUser = userTestRepository.findOneByLogin(user.getLogin()); assertThat(registeredUser).isPresent(); // Activate the user @@ -288,7 +289,7 @@ private void createAndSaveUser(String login, String email) { User user = UserFactory.generateActivatedUser(login); user.setEmail(email); user.setActivated(false); - userRepository.save(user); + userTestRepository.save(user); } } diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/UserRepositoryTest.java b/src/test/java/de/tum/cit/aet/artemis/core/user/UserRepositoryTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/core/repository/UserRepositoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/user/UserRepositoryTest.java index dea055b72e4a..3db679b7adf8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/UserRepositoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/user/UserRepositoryTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.core.repository; +package de.tum.cit.aet.artemis.core.user; -import static de.tum.cit.aet.artemis.user.UserFactory.USER_PASSWORD; +import static de.tum.cit.aet.artemis.core.user.util.UserFactory.USER_PASSWORD; import static org.assertj.core.api.Assertions.assertThat; import java.time.ZonedDateTime; @@ -11,18 +11,19 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.user.PasswordService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class UserRepositoryTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "userrepotest"; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/user/UserFactory.java b/src/test/java/de/tum/cit/aet/artemis/core/user/util/UserFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/user/UserFactory.java rename to src/test/java/de/tum/cit/aet/artemis/core/user/util/UserFactory.java index 72cf4dd48f05..4d7e8e5557b7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/user/UserFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/user/util/UserFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.user; +package de.tum.cit.aet.artemis.core.user.util; import java.time.ZonedDateTime; import java.util.ArrayList; diff --git a/src/test/java/de/tum/cit/aet/artemis/user/UserTestService.java b/src/test/java/de/tum/cit/aet/artemis/core/user/util/UserTestService.java similarity index 84% rename from src/test/java/de/tum/cit/aet/artemis/user/UserTestService.java rename to src/test/java/de/tum/cit/aet/artemis/core/user/util/UserTestService.java index 158cbd6ffa79..527230b8c446 100644 --- a/src/test/java/de/tum/cit/aet/artemis/user/UserTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/user/util/UserTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.user; +package de.tum.cit.aet.artemis.core.user.util; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -29,7 +29,7 @@ import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEvent; import de.tum.cit.aet.artemis.atlas.domain.science.ScienceEventType; -import de.tum.cit.aet.artemis.atlas.repository.ScienceEventRepository; +import de.tum.cit.aet.artemis.atlas.test_repository.ScienceEventTestRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.Course; @@ -39,22 +39,23 @@ import de.tum.cit.aet.artemis.core.dto.vm.ManagedUserVM; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.core.repository.AuthorityRepository; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.service.user.PasswordService; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; -import de.tum.cit.aet.artemis.exercise.programming.MockDelegate; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.lti.service.LtiService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.repository.ParticipationVCSAccessTokenRepository; import de.tum.cit.aet.artemis.programming.service.ci.CIUserManagementService; import de.tum.cit.aet.artemis.programming.service.vcs.VcsUserManagementService; -import de.tum.cit.aet.artemis.util.RequestUtilService; +import de.tum.cit.aet.artemis.programming.util.MockDelegate; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; /** * Note: this class should be independent of the actual VCS and CIS and contains common test logic for scenarios: @@ -67,7 +68,7 @@ public class UserTestService { private AuthorityRepository authorityRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userTestRepository; @Autowired private PasswordService passwordService; @@ -76,7 +77,7 @@ public class UserTestService { private CacheManager cacheManager; @Autowired - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; @Autowired protected RequestUtilService request; @@ -97,7 +98,7 @@ public class UserTestService { private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private ScienceEventRepository scienceEventRepository; + private ScienceEventTestRepository scienceEventRepository; @Autowired private MockMvc mockMvc; @@ -122,20 +123,20 @@ public class UserTestService { private ParticipationVCSAccessTokenRepository participationVCSAccessTokenRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; public void setup(String testPrefix, MockDelegate mockDelegate) throws Exception { this.TEST_PREFIX = testPrefix; this.mockDelegate = mockDelegate; List users = userUtilService.addUsers(testPrefix, NUMBER_OF_STUDENTS, NUMBER_OF_TUTORS, NUMBER_OF_EDITORS, NUMBER_OF_INSTRUCTORS); - student = userRepository.getUserByLoginElseThrow(testPrefix + "student1"); + student = userTestRepository.getUserByLoginElseThrow(testPrefix + "student1"); student.setInternal(true); - student = userRepository.save(student); - student = userRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); + student = userTestRepository.save(student); + student = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); users.forEach(user -> cacheManager.getCache(UserRepository.USERS_CACHE).evict(user.getLogin())); @@ -147,7 +148,7 @@ public void setup(String testPrefix, MockDelegate mockDelegate) throws Exception } public void tearDown() throws IOException { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); } public User getStudent() { @@ -193,24 +194,24 @@ private void assertThatUserWasNotSoftDeleted(User originalUser, User deletedUser public void deleteUser_isSuccessful() throws Exception { student.setRegistrationNumber("123"); student.setImageUrl("https://www.somewebsite.com/image.jpg"); - userRepository.save(student); + userTestRepository.save(student); request.delete("/api/admin/users/" + student.getLogin(), HttpStatus.OK); - final var deletedUser = userRepository.findById(student.getId()).orElseThrow(); + final var deletedUser = userTestRepository.findById(student.getId()).orElseThrow(); assertThatUserWasSoftDeleted(student, deletedUser); } // Test public void deleteSelf_isNotSuccessful(String currentUserLogin) throws Exception { request.delete("/api/admin/users/" + currentUserLogin, HttpStatus.BAD_REQUEST); - final var deletedUser = userRepository.findById(student.getId()).orElseThrow(); + final var deletedUser = userTestRepository.findById(student.getId()).orElseThrow(); assertThatUserWasNotSoftDeleted(student, deletedUser); } // Test public void deleteUsers(String currentUserLogin) throws Exception { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, 1, 1, 1, 1); var users = Set.of(userUtilService.getUserByLogin(TEST_PREFIX + "student1"), userUtilService.getUserByLogin(TEST_PREFIX + "tutor1"), @@ -222,7 +223,7 @@ public void deleteUsers(String currentUserLogin) throws Exception { request.delete("/api/admin/users", HttpStatus.OK, params); for (var user : users) { - final var deletedUser = userRepository.findById(user.getId()).orElseThrow(); + final var deletedUser = userTestRepository.findById(user.getId()).orElseThrow(); if (deletedUser.getLogin().equals(currentUserLogin)) { assertThatUserWasNotSoftDeleted(user, deletedUser); @@ -236,7 +237,7 @@ public void deleteUsers(String currentUserLogin) throws Exception { // Test public void updateUser_asAdmin_isSuccessful() throws Exception { student.setInternal(true); - student = userRepository.save(student); + student = userTestRepository.save(student); final var newPassword = "bonobo42"; final var newEmail = "bonobo42@tum.com"; final var newFirstName = "Bruce"; @@ -261,7 +262,7 @@ public void updateUser_asAdmin_isSuccessful() throws Exception { var managedUserVM = new ManagedUserVM(student, newPassword); managedUserVM.setPassword(newPassword); final var response = request.putWithResponseBody("/api/admin/users", managedUserVM, User.class, HttpStatus.OK); - final var updatedUserIndDB = userRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); + final var updatedUserIndDB = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); assertThat(response).isNotNull(); assertThat(passwordService.checkPasswordMatch(newPassword, updatedUserIndDB.getPassword())).isTrue(); @@ -287,18 +288,18 @@ public void updateUserWithEmptyRoles() throws Exception { assertThat(response).isNotNull(); // do not allow empty authorities - final var updatedUserInDB = userRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); + final var updatedUserInDB = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(student.getLogin()).orElseThrow(); assertThat(updatedUserInDB.getAuthorities()).containsExactly(new Authority(Role.STUDENT.getAuthority())); } // Test public void updateUser_withNullPassword_oldPasswordNotChanged() throws Exception { student.setPassword(null); - final var oldPassword = userRepository.findById(student.getId()).orElseThrow().getPassword(); + final var oldPassword = userTestRepository.findById(student.getId()).orElseThrow().getPassword(); mockDelegate.mockUpdateUserInUserManagement(student.getLogin(), student, null, student.getGroups()); request.put("/api/admin/users", new ManagedUserVM(student), HttpStatus.OK); - final var userInDB = userRepository.findById(student.getId()).orElseThrow(); + final var userInDB = userTestRepository.findById(student.getId()).orElseThrow(); assertThat(oldPassword).as("Password did not change").isEqualTo(userInDB.getPassword()); } @@ -310,7 +311,7 @@ public void updateUserLogin() throws Exception { mockDelegate.mockUpdateUserInUserManagement(oldLogin, student, null, student.getGroups()); request.put("/api/admin/users", new ManagedUserVM(student), HttpStatus.OK); - final var userInDB = userRepository.findById(student.getId()).orElseThrow(); + final var userInDB = userTestRepository.findById(student.getId()).orElseThrow(); assertThat(userInDB.getLogin()).isEqualTo(student.getLogin()); assertThat(userInDB.getId()).isEqualTo(student.getId()); @@ -323,9 +324,9 @@ public void updateUserInvalidId() throws Exception { mockDelegate.mockUpdateUserInUserManagement(student.getLogin(), student, null, student.getGroups()); request.put("/api/admin/users", new ManagedUserVM(student, student.getPassword()), HttpStatus.BAD_REQUEST); - final var userInDB = userRepository.findById(oldId).orElseThrow(); + final var userInDB = userTestRepository.findById(oldId).orElseThrow(); assertThat(userInDB).isNotEqualTo(student); - assertThat(userRepository.findById(oldId + 1)).isNotEqualTo(student); + assertThat(userTestRepository.findById(oldId + 1)).isNotEqualTo(student); } // Test @@ -336,9 +337,9 @@ public void updateUserExistingEmail() throws Exception { mockDelegate.mockUpdateUserInUserManagement(student.getLogin(), student, null, student.getGroups()); request.put("/api/admin/users", new ManagedUserVM(student, student.getPassword()), HttpStatus.BAD_REQUEST); - final var userInDB = userRepository.findById(oldId).orElseThrow(); + final var userInDB = userTestRepository.findById(oldId).orElseThrow(); assertThat(userInDB).isNotEqualTo(student); - assertThat(userRepository.findById(oldId + 1)).isNotEqualTo(student); + assertThat(userTestRepository.findById(oldId + 1)).isNotEqualTo(student); } // Test @@ -348,7 +349,7 @@ public void updateUser_withExternalUserManagement() throws Exception { request.put("/api/admin/users", new ManagedUserVM(student), HttpStatus.OK); - var updatedUser = userRepository.findById(student.getId()); + var updatedUser = userTestRepository.findById(student.getId()); assertThat(updatedUser).isPresent(); assertThat(updatedUser.get().getFirstName()).isEqualTo("changed"); } @@ -361,7 +362,7 @@ public void updateUserGroups() throws Exception { // First we create a new user with group student.setGroups(Set.of("instructor")); - student = userRepository.save(student); + student = userTestRepository.save(student); // We will then update the user by modifying the groups var updatedUser = student; @@ -369,7 +370,7 @@ public void updateUserGroups() throws Exception { mockDelegate.mockUpdateUserInUserManagement(student.getLogin(), updatedUser, null, student.getGroups()); request.put("/api/admin/users", new ManagedUserVM(updatedUser, "this is a password"), HttpStatus.OK); - var updatedUserOrEmpty = userRepository.findOneWithGroupsAndAuthoritiesByLogin(updatedUser.getLogin()); + var updatedUserOrEmpty = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(updatedUser.getLogin()); assertThat(updatedUserOrEmpty).isPresent(); updatedUser = updatedUserOrEmpty.get(); @@ -389,7 +390,7 @@ public User createExternalUser_asAdmin_isSuccessful() throws Exception { final var response = request.postWithResponseBody("/api/admin/users", new ManagedUserVM(student, password), User.class, HttpStatus.CREATED); assertThat(response).isNotNull(); - final var userInDB = userRepository.findById(response.getId()).orElseThrow(); + final var userInDB = userTestRepository.findById(response.getId()).orElseThrow(); assertThat(passwordService.checkPasswordMatch(password, userInDB.getPassword())).isTrue(); student.setId(response.getId()); @@ -434,7 +435,7 @@ private void createInternalUserIsSuccessful(final Set roles) throws Except final var response = request.postWithResponseBody("/api/admin/users", new ManagedUserVM(student, student.getPassword()), User.class, HttpStatus.CREATED); assertThat(response).isNotNull(); - final var userInDB = userRepository.findById(response.getId()).orElseThrow(); + final var userInDB = userTestRepository.findById(response.getId()).orElseThrow(); userInDB.setPassword(password); student.setId(response.getId()); response.setPassword(password); @@ -445,13 +446,13 @@ private void createInternalUserIsSuccessful(final Set roles) throws Except // Test public void createUser_asAdmin_hasId() throws Exception { - userRepository.findOneByLogin("batman").ifPresent(userRepository::delete); + userTestRepository.findOneByLogin("batman").ifPresent(userTestRepository::delete); student.setId((long) 1337); student.setLogin("batman"); student.setPassword("foobar"); student.setEmail("batman@secret.invalid"); - student = userRepository.save(student); + student = userTestRepository.save(student); mockDelegate.mockCreateUserInUserManagement(student, false); @@ -547,7 +548,7 @@ public void createUser_asAdmin_failInExternalCiUserManagement_cannotGetCiUser_in // Test public void createUser_asAdmin_failInExternalVcsUserManagement_internalError() throws Exception { - userRepository.findOneByLogin("batman").ifPresent(userRepository::delete); + userTestRepository.findOneByLogin("batman").ifPresent(userTestRepository::delete); student.setId(null); student.setLogin("batman"); @@ -562,7 +563,7 @@ public void createUser_asAdmin_failInExternalVcsUserManagement_internalError() t // Test public void createUser_withNullAsPassword_generatesRandomPassword() throws Exception { - userRepository.findOneByLogin("batman").ifPresent(userRepository::delete); + userTestRepository.findOneByLogin("batman").ifPresent(userTestRepository::delete); student.setId(null); student.setEmail("batman@invalid.tum"); @@ -573,14 +574,14 @@ public void createUser_withNullAsPassword_generatesRandomPassword() throws Excep final var response = request.postWithResponseBody("/api/admin/users", new ManagedUserVM(student), User.class, HttpStatus.CREATED); assertThat(response).isNotNull(); - final var userInDB = userRepository.findById(response.getId()).orElseThrow(); + final var userInDB = userTestRepository.findById(response.getId()).orElseThrow(); assertThat(userInDB.getPassword()).isNotBlank(); } // Test public void createUser_withExternalUserManagement() throws Exception { - userRepository.findOneByLogin("batman").ifPresent(userRepository::delete); + userTestRepository.findOneByLogin("batman").ifPresent(userTestRepository::delete); var newUser = student; newUser.setId(null); @@ -591,16 +592,16 @@ public void createUser_withExternalUserManagement() throws Exception { request.post("/api/admin/users", new ManagedUserVM(newUser), HttpStatus.CREATED); - var createdUser = userRepository.findOneByEmailIgnoreCase(newUser.getEmail()); + var createdUser = userTestRepository.findOneByEmailIgnoreCase(newUser.getEmail()); assertThat(createdUser).isPresent(); assertThat(createdUser.get().getId()).isNotNull(); } // Test public void createUserWithGroups() throws Exception { - assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> userRepository.findByIdWithGroupsAndAuthoritiesElseThrow(Long.MAX_VALUE)); + assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> userTestRepository.findByIdWithGroupsAndAuthoritiesElseThrow(Long.MAX_VALUE)); - assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> userRepository.findByIdWithGroupsAndAuthoritiesAndOrganizationsElseThrow(Long.MAX_VALUE)); + assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> userTestRepository.findByIdWithGroupsAndAuthoritiesAndOrganizationsElseThrow(Long.MAX_VALUE)); var course = courseUtilService.addEmptyCourse(); programmingExerciseUtilService.addProgrammingExerciseToCourse(course); @@ -608,7 +609,7 @@ public void createUserWithGroups() throws Exception { course.setInstructorGroupName("instructor2"); courseRepository.save(course); - userRepository.findOneByLogin("batman").ifPresent(userRepository::delete); + userTestRepository.findOneByLogin("batman").ifPresent(userTestRepository::delete); var newUser = student; newUser.setId(null); @@ -620,7 +621,7 @@ public void createUserWithGroups() throws Exception { request.post("/api/admin/users", new ManagedUserVM(newUser), HttpStatus.CREATED); - var createdUserOrEmpty = userRepository.findOneWithGroupsAndAuthoritiesByLogin(newUser.getLogin()); + var createdUserOrEmpty = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(newUser.getLogin()); assertThat(createdUserOrEmpty).isPresent(); var createdUser = createdUserOrEmpty.get(); @@ -630,8 +631,8 @@ public void createUserWithGroups() throws Exception { // Test public void getUsers_asAdmin_isSuccessful() throws Exception { - var usersDb = userRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalse().stream().peek(user -> user.setGroups(Collections.emptySet())).toList(); - userRepository.saveAll(usersDb); + var usersDb = userTestRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalse().stream().peek(user -> user.setGroups(Collections.emptySet())).toList(); + userTestRepository.saveAll(usersDb); final var params = new LinkedMultiValueMap(); params.add("page", "0"); params.add("pageSize", "100"); @@ -669,7 +670,7 @@ public void searchUsers_asTutor_forbidden() throws Exception { // Test public void getUserViaFilter_asAdmin_isSuccessful() throws Exception { student.setGroups(Collections.emptySet()); - userRepository.save(student); + userTestRepository.save(student); final var params = new LinkedMultiValueMap(); params.add("page", "0"); params.add("pageSize", "100"); @@ -784,7 +785,7 @@ public void initializeUser(boolean mock) throws Exception { repoUser.setInternal(true); repoUser.setActivated(false); repoUser.setGroups(Set.of(LtiService.LTI_GROUP_NAME)); - final User user = userRepository.save(repoUser); + final User user = userTestRepository.save(repoUser); if (mock) { // Mock user creation and update calls to prevent issues in GitLab/Jenkins tests @@ -815,7 +816,7 @@ public void initializeUserWithoutFlag() throws Exception { user.setInternal(true); user.setActivated(true); user.setGroups(Set.of(LtiService.LTI_GROUP_NAME)); - userRepository.save(user); + userTestRepository.save(user); UserInitializationDTO dto = request.putWithResponseBody("/api/users/initialize", false, UserInitializationDTO.class, HttpStatus.OK); @@ -835,7 +836,7 @@ public void initializeUserNonLTI() throws Exception { user.setPassword(password); user.setInternal(true); user.setActivated(false); - userRepository.save(user); + userTestRepository.save(user); UserInitializationDTO dto = request.putWithResponseBody("/api/users/initialize", false, UserInitializationDTO.class, HttpStatus.OK); assertThat(dto.password()).isNull(); @@ -853,7 +854,7 @@ public void initializeUserExternal() throws Exception { user.setPassword(password); user.setInternal(false); user.setActivated(false); - userRepository.save(user); + userTestRepository.save(user); UserInitializationDTO dto = request.putWithResponseBody("/api/users/initialize", false, UserInitializationDTO.class, HttpStatus.OK); @@ -878,11 +879,11 @@ public void addAndDeleteSshPublicKey() throws Exception { // adding valid key should work correctly String validSshKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEbgjoSpKnry5yuMiWh/uwhMG2Jq5Sh8Uw9vz+39or2i email@abc.de"; request.putWithResponseBody("/api/account/ssh-public-key", validSshKey, String.class, HttpStatus.OK, true); - assertThat(userRepository.getUser().getSshPublicKey()).isEqualTo(validSshKey); + assertThat(userTestRepository.getUser().getSshPublicKey()).isEqualTo(validSshKey); // deleting the key shoul work correctly request.delete("/api/account/ssh-public-key", HttpStatus.OK); - assertThat(userRepository.getUser().getSshPublicKey()).isEqualTo(null); + assertThat(userTestRepository.getUser().getSshPublicKey()).isEqualTo(null); } // Test @@ -940,8 +941,8 @@ public void createAndDeleteUserVcsAccessToken() throws Exception { assertThat(user.getVcsAccessTokenExpiryDate()).isNull(); } - public UserRepository getUserRepository() { - return userRepository; + public UserRepository getUserTestRepository() { + return userTestRepository; } /** @@ -998,14 +999,14 @@ public void testUser() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 }, }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setGroups(Collections.emptySet()); user2.setGroups(Set.of("tumuser")); - userRepository.saveAll(List.of(user1, user2)); + userTestRepository.saveAll(List.of(user1, user2)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(user1).contains(user2); } @@ -1022,14 +1023,14 @@ public void testUserWithoutGroups() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setGroups(Collections.emptySet()); user2.setGroups(Set.of("tumuser")); - userRepository.saveAll(List.of(user1, user2)); + userTestRepository.saveAll(List.of(user1, user2)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(user1).doesNotContain(user2); } @@ -1043,15 +1044,15 @@ public void testUserWithActivatedStatus() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); - User admin = userRepository.getUserByLoginElseThrow("admin"); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User admin = userTestRepository.getUserByLoginElseThrow("admin"); user1.setActivated(true); user2.setActivated(false); - userRepository.saveAll(List.of(user1, user2, admin)); + userTestRepository.saveAll(List.of(user1, user2, admin)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(user1, admin).doesNotContain(user2); } @@ -1067,14 +1068,14 @@ public void testUserWithDeactivatedStatus() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setActivated(true); user2.setActivated(false); - userRepository.saveAll(List.of(user1, user2)); + userTestRepository.saveAll(List.of(user1, user2)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(user2).doesNotContain(user1); } @@ -1090,15 +1091,15 @@ public void testUserWithInternalStatus() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); - User admin = userRepository.getUserByLoginElseThrow("admin"); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User admin = userTestRepository.getUserByLoginElseThrow("admin"); user1.setInternal(true); user2.setInternal(false); - userRepository.saveAll(List.of(user1, user2, admin)); + userTestRepository.saveAll(List.of(user1, user2, admin)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(user1, admin).doesNotContain(user2); } @@ -1114,14 +1115,14 @@ public void testUserWithExternalStatus() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setInternal(true); user2.setInternal(false); - userRepository.saveAll(List.of(user1, user2)); + userTestRepository.saveAll(List.of(user1, user2)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(user2).doesNotContain(user1); } @@ -1137,14 +1138,14 @@ public void testUserWithExternalAndInternalStatus() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setInternal(true); user2.setInternal(false); - userRepository.saveAll(List.of(user1, user2)); + userTestRepository.saveAll(List.of(user1, user2)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).isEqualTo(Collections.emptyList()); } @@ -1164,14 +1165,14 @@ public void testUserWithRegistrationNumber() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setRegistrationNumber(null); user2.setRegistrationNumber(null); - userRepository.saveAll(List.of(user1, user2)); + userTestRepository.saveAll(List.of(user1, user2)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).isEqualTo(Collections.emptyList()); } @@ -1191,15 +1192,15 @@ public void testUserWithoutRegistrationNumber() throws Exception { Integer[][] numbers = { { 2, 0, 0, 0 }, { 0, 2, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 0, 2 } }; for (Integer[] number : numbers) { - userRepository.deleteAll(userRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); + userTestRepository.deleteAll(userTestRepository.searchAllByLoginOrName(Pageable.unpaged(), TEST_PREFIX)); userUtilService.addUsers(TEST_PREFIX, number[0], number[1], number[2], number[3]); final var mainUserAuthority = getMainUserAuthority(number); - User user1 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); - User user2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); + User user1 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 1); + User user2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + mainUserAuthority + 2); user1.setRegistrationNumber("5461351"); user2.setRegistrationNumber(""); - User admin = userRepository.getUserByLoginElseThrow("admin"); - userRepository.saveAll(List.of(user1, user2, admin)); + User admin = userTestRepository.getUserByLoginElseThrow("admin"); + userTestRepository.saveAll(List.of(user1, user2, admin)); result = request.getList("/api/admin/users", HttpStatus.OK, User.class, params); assertThat(result).contains(admin).doesNotContain(user1, user2); } diff --git a/src/test/java/de/tum/cit/aet/artemis/user/UserUtilService.java b/src/test/java/de/tum/cit/aet/artemis/core/user/util/UserUtilService.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/user/UserUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/core/user/util/UserUtilService.java index 7add515fd2fe..2aa5ea3cd5f0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/user/UserUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/user/util/UserUtilService.java @@ -1,6 +1,5 @@ -package de.tum.cit.aet.artemis.user; +package de.tum.cit.aet.artemis.core.user.util; -import static de.tum.cit.aet.artemis.user.UserFactory.USER_PASSWORD; import static org.assertj.core.api.Assertions.assertThat; import java.time.ZonedDateTime; @@ -23,10 +22,9 @@ import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.repository.AuthorityRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.core.repository.UserTestRepository; import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.service.user.PasswordService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; /** * Service responsible for initializing the database with specific testdata related to Users for use in integration tests. @@ -56,9 +54,6 @@ public class UserUtilService { private static final Set adminAuthorities = Set.of(userAuthority, tutorAuthority, editorAuthority, instructorAuthority, adminAuthority); - @Autowired - private UserRepository userRepo; - @Autowired private AuthorityRepository authorityRepository; @@ -115,7 +110,7 @@ public List generateActivatedUsersWithRegistrationNumber(String loginPrefi * @return The List of generated Users */ public List generateAndSaveActivatedUsers(String loginPrefix, String[] groups, Set authorities, int amount) { - return generateAndSaveActivatedUsers(loginPrefix, USER_PASSWORD, groups, authorities, amount); + return generateAndSaveActivatedUsers(loginPrefix, UserFactory.USER_PASSWORD, groups, authorities, amount); } /** @@ -138,7 +133,7 @@ public List generateAndSaveActivatedUsers(String loginPrefix, String commo user.setGroups(Set.of(groups)); user.setAuthorities(authorities); } - user = userRepo.save(user); + user = userTestRepository.save(user); generatedUsers.add(user); } return generatedUsers; @@ -182,7 +177,7 @@ public User setRegistrationNumberOfUserAndSave(String login, String registration */ public User setRegistrationNumberOfUserAndSave(User user, String registrationNumber) { user.setRegistrationNumber(registrationNumber); - return userRepo.save(user); + return userTestRepository.save(user); } /** @@ -196,7 +191,7 @@ public User setRegistrationNumberOfUserAndSave(User user, String registrationNum public User setUserVcsAccessTokenAndExpiryDateAndSave(User user, String vcsAccessToken, ZonedDateTime expiryDate) { user.setVcsAccessToken(vcsAccessToken); user.setVcsAccessTokenExpiryDate(expiryDate); - return userRepo.save(user); + return userTestRepository.save(user); } /** @@ -207,7 +202,7 @@ public User setUserVcsAccessTokenAndExpiryDateAndSave(User user, String vcsAcces public void deleteUserVcsAccessToken(User userWithUserToken) { userWithUserToken.setVcsAccessTokenExpiryDate(null); userWithUserToken.setVcsAccessToken(null); - userRepo.save(userWithUserToken); + userTestRepository.save(userWithUserToken); } /** @@ -263,7 +258,7 @@ public User createAndSaveUser(String login, String hashedPassword) { // save the user with the newly created values (to override previous changes) with the same ID user.setId(getUserByLogin(login).getId()); } - return userRepo.save(user); + return userTestRepository.save(user); } /** @@ -294,7 +289,7 @@ public User createAndSaveUser(String login) { // save the user with the newly created values (to override previous changes) with the same ID user.setId(getUserByLogin(login).getId()); } - return userRepo.save(user); + return userTestRepository.save(user); } /** @@ -327,16 +322,16 @@ public List addUsers(String prefix, int numberOfStudents, int numberOfTuto authorityRepository.saveAll(adminAuthorities); } log.debug("Generate {} students...", numberOfStudents); - var students = generateActivatedUsers(prefix + "student", passwordService.hashPassword(USER_PASSWORD), new String[] { "tumuser", "testgroup", prefix + "tumuser" }, - studentAuthorities, numberOfStudents); + var students = generateActivatedUsers(prefix + "student", passwordService.hashPassword(UserFactory.USER_PASSWORD), + new String[] { "tumuser", "testgroup", prefix + "tumuser" }, studentAuthorities, numberOfStudents); log.debug("{} students generated. Generate {} tutors...", numberOfStudents, numberOfTutors); - var tutors = generateActivatedUsers(prefix + "tutor", passwordService.hashPassword(USER_PASSWORD), new String[] { "tutor", "testgroup", prefix + "tutor" }, + var tutors = generateActivatedUsers(prefix + "tutor", passwordService.hashPassword(UserFactory.USER_PASSWORD), new String[] { "tutor", "testgroup", prefix + "tutor" }, tutorAuthorities, numberOfTutors); log.debug("{} tutors generated. Generate {} editors...", numberOfTutors, numberOfEditors); - var editors = generateActivatedUsers(prefix + "editor", passwordService.hashPassword(USER_PASSWORD), new String[] { "editor", "testgroup", prefix + "editor" }, + var editors = generateActivatedUsers(prefix + "editor", passwordService.hashPassword(UserFactory.USER_PASSWORD), new String[] { "editor", "testgroup", prefix + "editor" }, editorAuthorities, numberOfEditors); log.debug("{} editors generated. Generate {} instructors...", numberOfEditors, numberOfInstructors); - var instructors = generateActivatedUsers(prefix + "instructor", passwordService.hashPassword(USER_PASSWORD), + var instructors = generateActivatedUsers(prefix + "instructor", passwordService.hashPassword(UserFactory.USER_PASSWORD), new String[] { "instructor", "testgroup", prefix + "instructor" }, instructorAuthorities, numberOfInstructors); log.debug("{} instructors generated", numberOfInstructors); @@ -348,7 +343,7 @@ public List addUsers(String prefix, int numberOfStudents, int numberOfTuto if (!userExistsWithLogin("admin")) { log.debug("Generate admin"); - User admin = UserFactory.generateActivatedUser("admin", passwordService.hashPassword(USER_PASSWORD)); + User admin = UserFactory.generateActivatedUser("admin", passwordService.hashPassword(UserFactory.USER_PASSWORD)); admin.setGroups(Set.of("admin")); admin.setAuthorities(adminAuthorities); usersToAdd.add(admin); @@ -362,10 +357,10 @@ public List addUsers(String prefix, int numberOfStudents, int numberOfTuto Set currentUsers = userTestRepository.findAllByGroupsNotEmpty(); log.debug("Removing {} users from all courses...", currentUsers.size()); currentUsers.forEach(user -> user.setGroups(Set.of())); - userRepo.saveAll(currentUsers); + userTestRepository.saveAll(currentUsers); log.debug("Removing {} users from all courses. Done", currentUsers.size()); log.debug("Save {} users to database...", usersToAdd.size()); - usersToAdd = userRepo.saveAll(usersToAdd); + usersToAdd = userTestRepository.saveAll(usersToAdd); log.debug("Save {} users to database. Done", usersToAdd.size()); } @@ -380,9 +375,9 @@ public List addUsers(String prefix, int numberOfStudents, int numberOfTuto * @param to The last number to append to the loginPrefix */ public void addStudents(String prefix, int from, int to) { - var students = generateActivatedUsers(prefix + "student", passwordService.hashPassword(USER_PASSWORD), new String[] { "tumuser", "testgroup", prefix + "tumuser" }, - studentAuthorities, from, to); - userRepo.saveAll(students); + var students = generateActivatedUsers(prefix + "student", passwordService.hashPassword(UserFactory.USER_PASSWORD), + new String[] { "tumuser", "testgroup", prefix + "tumuser" }, studentAuthorities, from, to); + userTestRepository.saveAll(students); } /** @@ -395,10 +390,10 @@ public void cleanUpRegistrationNumberForUser(User user) { return; } - var existingUserWithRegistrationNumber = userRepo.findOneWithGroupsAndAuthoritiesByRegistrationNumber(user.getRegistrationNumber()); + var existingUserWithRegistrationNumber = userTestRepository.findOneWithGroupsAndAuthoritiesByRegistrationNumber(user.getRegistrationNumber()); if (existingUserWithRegistrationNumber.isPresent()) { existingUserWithRegistrationNumber.get().setRegistrationNumber(null); - userRepo.save(existingUserWithRegistrationNumber.get()); + userTestRepository.save(existingUserWithRegistrationNumber.get()); } } @@ -412,7 +407,7 @@ public void addInstructor(final String instructorGroup, final String instructorN if (!userExistsWithLogin(instructorName)) { var newUsers = generateAndSaveActivatedUsers(instructorName, new String[] { instructorGroup, "testgroup" }, instructorAuthorities, 1); if (!newUsers.isEmpty()) { - var instructor = userRepo.save(newUsers.getFirst()); + var instructor = userTestRepository.save(newUsers.getFirst()); assertThat(instructor.getId()).as("Instructor has been created").isNotNull(); } } @@ -428,7 +423,7 @@ public void addEditor(final String editorGroup, final String editorName) { if (!userExistsWithLogin(editorName)) { var newUsers = generateAndSaveActivatedUsers(editorName, new String[] { editorGroup, "testgroup" }, editorAuthorities, 1); if (!newUsers.isEmpty()) { - var editor = userRepo.save(newUsers.getFirst()); + var editor = userTestRepository.save(newUsers.getFirst()); assertThat(editor.getId()).as("Editor has been created").isNotNull(); } } @@ -444,7 +439,7 @@ public void addTeachingAssistant(final String taGroup, final String taName) { if (!userExistsWithLogin(taName)) { var newUsers = generateAndSaveActivatedUsers(taName, new String[] { taGroup, "testgroup" }, tutorAuthorities, 1); if (!newUsers.isEmpty()) { - var ta = userRepo.save(newUsers.getFirst()); + var ta = userTestRepository.save(newUsers.getFirst()); assertThat(ta.getId()).as("Teaching assistant has been created").isNotNull(); } } @@ -460,7 +455,7 @@ public void addStudent(final String studentGroup, final String studentName) { if (!userExistsWithLogin(studentName)) { var newUsers = generateAndSaveActivatedUsers(studentName, new String[] { studentGroup, "testgroup" }, studentAuthorities, 1); if (!newUsers.isEmpty()) { - var student = userRepo.save(newUsers.getFirst()); + var student = userTestRepository.save(newUsers.getFirst()); assertThat(student.getId()).as("Student has been created").isNotNull(); } } @@ -476,7 +471,7 @@ public void addStudent(final String studentGroup, final String studentName) { * @return user with the provided logih */ public User getUserByLoginWithoutAuthorities(String login) { - return userRepo.findOneByLogin(login).orElseThrow(() -> new IllegalArgumentException("Provided login " + login + " does not exist in database")); + return userTestRepository.findOneByLogin(login).orElseThrow(() -> new IllegalArgumentException("Provided login " + login + " does not exist in database")); } /** @@ -487,7 +482,7 @@ public User getUserByLoginWithoutAuthorities(String login) { */ public User getUserByLogin(String login) { // we convert to lowercase for convenience, because logins have to be lower case - return userRepo.findOneWithGroupsAndAuthoritiesByLogin(login.toLowerCase()) + return userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(login.toLowerCase()) .orElseThrow(() -> new IllegalArgumentException("Provided login " + login + " does not exist in database")); } @@ -498,7 +493,7 @@ public User getUserByLogin(String login) { * @return True, if a User with the given login exists, false otherwise */ public boolean userExistsWithLogin(String login) { - return userRepo.findOneByLogin(login).isPresent(); + return userTestRepository.findOneByLogin(login).isPresent(); } /** @@ -509,7 +504,7 @@ public boolean userExistsWithLogin(String login) { public void removeUserFromAllCourses(String login) { User user = getUserByLogin(login); user.setGroups(Set.of()); - userRepo.save(user); + userTestRepository.save(user); } /** @@ -526,22 +521,22 @@ public void adjustUserGroupsToCustomGroups(String userPrefix, String userSuffix, for (int i = 1; i <= numberOfStudents; i++) { var user = getUserByLogin(userPrefix + "student" + i); user.setGroups(Set.of(userPrefix + "student" + userSuffix)); - userRepo.save(user); + userTestRepository.save(user); } for (int i = 1; i <= numberOfTutors; i++) { var user = getUserByLogin(userPrefix + "tutor" + i); user.setGroups(Set.of(userPrefix + "tutor" + userSuffix)); - userRepo.save(user); + userTestRepository.save(user); } for (int i = 1; i <= numberOfEditors; i++) { var user = getUserByLogin(userPrefix + "editor" + i); user.setGroups(Set.of(userPrefix + "editor" + userSuffix)); - userRepo.save(user); + userTestRepository.save(user); } for (int i = 1; i <= numberOfInstructors; i++) { var user = getUserByLogin(userPrefix + "instructor" + i); user.setGroups(Set.of(userPrefix + "instructor" + userSuffix)); - userRepo.save(user); + userTestRepository.save(user); } } } diff --git a/src/test/java/de/tum/cit/aet/artemis/util/ConfigUtil.java b/src/test/java/de/tum/cit/aet/artemis/core/util/ConfigUtil.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/util/ConfigUtil.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/ConfigUtil.java index d7482faf4925..1bca9058f03c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/ConfigUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/ConfigUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import org.junit.jupiter.api.function.Executable; import org.springframework.test.util.ReflectionTestUtils; diff --git a/src/test/java/de/tum/cit/aet/artemis/course/CourseFactory.java b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/course/CourseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/CourseFactory.java index 3ef03f95a68c..7fde00dd48bd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/course/CourseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.course; +package de.tum.cit.aet.artemis.core.util; import java.time.ZonedDateTime; import java.util.Set; diff --git a/src/test/java/de/tum/cit/aet/artemis/course/CourseTestService.java b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/course/CourseTestService.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java index 9bc46ee31d1e..a66e6d5adc6a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/course/CourseTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.course; +package de.tum.cit.aet.artemis.core.util; import static de.tum.cit.aet.artemis.core.config.Constants.ARTEMIS_GROUP_DEFAULT_PREFIX; import static java.util.Collections.emptyList; @@ -60,7 +60,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; @@ -71,20 +70,21 @@ import de.tum.cit.aet.artemis.assessment.dto.UserNameAndLoginDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; import de.tum.cit.aet.artemis.assessment.repository.ParticipantScoreRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.PrerequisiteUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.atlas.domain.competency.Prerequisite; -import de.tum.cit.aet.artemis.atlas.repository.LearningPathRepository; +import de.tum.cit.aet.artemis.atlas.test_repository.LearningPathTestRepository; import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; import de.tum.cit.aet.artemis.communication.domain.DefaultChannelType; import de.tum.cit.aet.artemis.communication.dto.ChannelDTO; -import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; -import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationService; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; -import de.tum.cit.aet.artemis.competency.PrerequisiteUtilService; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationParticipantTestRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationTestRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; @@ -103,70 +103,67 @@ import de.tum.cit.aet.artemis.core.dto.UserDTO; import de.tum.cit.aet.artemis.core.dto.UserPublicInfoDTO; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; import de.tum.cit.aet.artemis.core.repository.CustomAuditEventRepository; -import de.tum.cit.aet.artemis.core.repository.OnlineCourseConfigurationRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.export.CourseExamExportService; import de.tum.cit.aet.artemis.core.service.export.DataExportUtil; -import de.tum.cit.aet.artemis.exam.ExamFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseType; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.MockDelegate; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadExerciseRepository; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.fileupload.util.ZipFileTestUtilService; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.lti.domain.LtiPlatformConfiguration; import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; -import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; +import de.tum.cit.aet.artemis.lti.test_repository.LtiPlatformConfigurationTestRepository; +import de.tum.cit.aet.artemis.lti.test_repository.OnlineCourseConfigurationTestRepository; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.RepositoryType; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.MockDelegate; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.dto.TextAssessmentUpdateDTO; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorParticipationStatus; -import de.tum.cit.aet.artemis.user.UserFactory; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; -import de.tum.cit.aet.artemis.util.RequestUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; -import de.tum.cit.aet.artemis.util.ZipFileTestUtilService; @Service public class CourseTestService { @@ -175,7 +172,7 @@ public class CourseTestService { private Path courseArchivesDirPath; @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private ExerciseRepository exerciseRepo; @@ -184,19 +181,19 @@ public class CourseTestService { private LectureRepository lectureRepo; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired private CustomAuditEventRepository auditEventRepo; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; @Autowired private ExamRepository examRepo; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private RequestUtilService request; @@ -205,7 +202,7 @@ public class CourseTestService { private ZipFileTestUtilService zipFileTestUtilService; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ComplaintRepository complaintRepo; @@ -235,10 +232,10 @@ public class CourseTestService { private ParticipantScoreRepository participantScoreRepository; @Autowired - private OnlineCourseConfigurationRepository onlineCourseConfigurationRepository; + private OnlineCourseConfigurationTestRepository onlineCourseConfigurationRepository; @Autowired - private LtiPlatformConfigurationRepository ltiPlatformConfigurationRepository; + private LtiPlatformConfigurationTestRepository ltiPlatformConfigurationRepository; @Autowired private ObjectMapper objectMapper; @@ -250,13 +247,13 @@ public class CourseTestService { private ChannelRepository channelRepository; @Autowired - private ConversationRepository conversationRepository; + private ConversationTestRepository conversationRepository; @Autowired - private ConversationParticipantRepository conversationParticipantRepository; + private ConversationParticipantTestRepository conversationParticipantRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired private UserUtilService userUtilService; @@ -295,7 +292,7 @@ public class CourseTestService { private TeamUtilService teamUtilService; @Autowired - private LearningPathRepository learningPathRepository; + private LearningPathTestRepository learningPathRepository; @Autowired private ParticipantScoreScheduleService participantScoreScheduleService; diff --git a/src/test/java/de/tum/cit/aet/artemis/course/CourseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseUtilService.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/course/CourseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/CourseUtilService.java index 80360509c72f..02d8d55a6231 100644 --- a/src/test/java/de/tum/cit/aet/artemis/course/CourseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseUtilService.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.course; +package de.tum.cit.aet.artemis.core.util; -import static de.tum.cit.aet.artemis.participation.ParticipationFactory.generateResult; +import static de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory.generateResult; import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; @@ -18,76 +18,75 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; -import de.tum.cit.aet.artemis.assessment.GradingScaleUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; -import de.tum.cit.aet.artemis.assessment.repository.TutorParticipationRepository; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.TutorParticipationTestRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.Organization; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; +import de.tum.cit.aet.artemis.core.organization.util.OrganizationUtilService; import de.tum.cit.aet.artemis.core.service.FilePathService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExerciseGroupRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseFactory; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadSubmissionRepository; -import de.tum.cit.aet.artemis.lecture.LectureFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; import de.tum.cit.aet.artemis.modeling.service.ModelingSubmissionService; -import de.tum.cit.aet.artemis.organization.OrganizationUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.test_repository.ModelingSubmissionTestRepository; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorParticipationStatus; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; /** * Service responsible for initializing the database with specific testdata related to courses for use in integration tests. @@ -102,7 +101,7 @@ public class CourseUtilService { private static final ZonedDateTime FUTURE_FUTURE_TIMESTAMP = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private LectureRepository lectureRepo; @@ -114,34 +113,34 @@ public class CourseUtilService { private ExerciseRepository exerciseRepo; @Autowired - private TutorParticipationRepository tutorParticipationRepo; + private TutorParticipationTestRepository tutorParticipationRepo; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepo; + private ExampleSubmissionTestRepository exampleSubmissionRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @Autowired - private ModelingSubmissionRepository modelingSubmissionRepo; + private ModelingSubmissionTestRepository modelingSubmissionRepo; @Autowired - private TextSubmissionRepository textSubmissionRepo; + private TextSubmissionTestRepository textSubmissionRepo; @Autowired private FileUploadSubmissionRepository fileUploadSubmissionRepo; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/FixMissingServletPathProcessor.java b/src/test/java/de/tum/cit/aet/artemis/core/util/FixMissingServletPathProcessor.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/util/FixMissingServletPathProcessor.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/FixMissingServletPathProcessor.java index d5b9521e7467..e50266412846 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/FixMissingServletPathProcessor.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/FixMissingServletPathProcessor.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import jakarta.servlet.http.HttpServletMapping; import jakarta.servlet.http.MappingMatch; @@ -8,7 +8,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.web.servlet.request.RequestPostProcessor; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; /** * The {@link WebEnvironment} set for example in {@link AbstractSpringIntegrationLocalCILocalVCTest} causes the MockMvc to not set the servlet path correctly. diff --git a/src/test/java/de/tum/cit/aet/artemis/util/HibernateQueryInterceptor.java b/src/test/java/de/tum/cit/aet/artemis/core/util/HibernateQueryInterceptor.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/util/HibernateQueryInterceptor.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/HibernateQueryInterceptor.java index 786af7bc04e7..f817c4efd4fc 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/HibernateQueryInterceptor.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/HibernateQueryInterceptor.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import org.hibernate.resource.jdbc.spi.StatementInspector; import org.springframework.stereotype.Component; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/PageableSearchUtilService.java b/src/test/java/de/tum/cit/aet/artemis/core/util/PageableSearchUtilService.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/util/PageableSearchUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/PageableSearchUtilService.java index 4079cfceec33..3fc15ef19ded 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/PageableSearchUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/PageableSearchUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import java.util.Map; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/QueryCountAssert.java b/src/test/java/de/tum/cit/aet/artemis/core/util/QueryCountAssert.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/util/QueryCountAssert.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/QueryCountAssert.java index 7d76859cf1f5..916b73fb57d5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/QueryCountAssert.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/QueryCountAssert.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import org.assertj.core.api.AbstractAssert; import org.slf4j.Logger; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/RequestUtilService.java b/src/test/java/de/tum/cit/aet/artemis/core/util/RequestUtilService.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/util/RequestUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/RequestUtilService.java index d6252a53e3d8..3d992677b553 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/RequestUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/RequestUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/SensitiveInformationUtil.java b/src/test/java/de/tum/cit/aet/artemis/core/util/SensitiveInformationUtil.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/util/SensitiveInformationUtil.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/SensitiveInformationUtil.java index 0afa33a52a2c..9e39a3a39f2c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/SensitiveInformationUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/SensitiveInformationUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/StringUtilTest.java b/src/test/java/de/tum/cit/aet/artemis/core/util/StringUtilTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/StringUtilTest.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/StringUtilTest.java index 484e194d0f6f..69f5299a3b46 100644 --- a/src/test/java/de/tum/cit/aet/artemis/StringUtilTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/StringUtilTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.core.util; import static de.tum.cit.aet.artemis.core.util.StringUtil.ILLEGAL_CHARACTERS; import static de.tum.cit.aet.artemis.core.util.StringUtil.stripIllegalCharacters; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/TestConstants.java b/src/test/java/de/tum/cit/aet/artemis/core/util/TestConstants.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/util/TestConstants.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/TestConstants.java index 33d7d025df9d..91333f0fd1aa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/TestConstants.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/TestConstants.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import org.eclipse.jgit.lib.ObjectId; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/TestResourceUtils.java b/src/test/java/de/tum/cit/aet/artemis/core/util/TestResourceUtils.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/util/TestResourceUtils.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/TestResourceUtils.java index 96b55bdb54c1..9f315c9a4e27 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/TestResourceUtils.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/TestResourceUtils.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/TestUriParamsUtil.java b/src/test/java/de/tum/cit/aet/artemis/core/util/TestUriParamsUtil.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/util/TestUriParamsUtil.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/TestUriParamsUtil.java index ae5a416b28f7..5968dd3e74dc 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/TestUriParamsUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/TestUriParamsUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/ThrowingProducer.java b/src/test/java/de/tum/cit/aet/artemis/core/util/ThrowingProducer.java similarity index 72% rename from src/test/java/de/tum/cit/aet/artemis/util/ThrowingProducer.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/ThrowingProducer.java index 5441a0afbc72..6bcb78e5f3a7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/ThrowingProducer.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/ThrowingProducer.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; @FunctionalInterface public interface ThrowingProducer { diff --git a/src/test/java/de/tum/cit/aet/artemis/util/Verifiable.java b/src/test/java/de/tum/cit/aet/artemis/core/util/Verifiable.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/util/Verifiable.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/Verifiable.java index 284aae3c34fa..7dabe5fa7e5c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/Verifiable.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/Verifiable.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.core.util; /** * Wrapper interface for bundling multiple {@link org.mockito.Mockito} verifications for execution after all tests ran. diff --git a/src/test/java/de/tum/cit/aet/artemis/util/junit_extensions/AwaitilityExtension.java b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_extensions/AwaitilityExtension.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/util/junit_extensions/AwaitilityExtension.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/junit_extensions/AwaitilityExtension.java index 980aa598c260..4fa0117f37fa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/junit_extensions/AwaitilityExtension.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_extensions/AwaitilityExtension.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.junit_extensions; +package de.tum.cit.aet.artemis.core.util.junit_extensions; import java.time.Duration; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/junit_extensions/ParallelLoggingExtension.java b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_extensions/ParallelLoggingExtension.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/util/junit_extensions/ParallelLoggingExtension.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/junit_extensions/ParallelLoggingExtension.java index 05675571e49d..603986c6f62f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/junit_extensions/ParallelLoggingExtension.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_extensions/ParallelLoggingExtension.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.junit_extensions; +package de.tum.cit.aet.artemis.core.util.junit_extensions; import static org.awaitility.Awaitility.await; @@ -9,7 +9,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.tum.cit.aet.artemis.util.junit_parallel_logging.ParallelConsoleAppender; +import de.tum.cit.aet.artemis.core.util.junit_parallel_logging.ParallelConsoleAppender; /** * A JUnit 5 extension that uses {@link ParallelConsoleAppender} to collect logs from parallel test execution. diff --git a/src/test/java/de/tum/cit/aet/artemis/util/junit_parallel_logging/ParallelConsoleAppender.java b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_parallel_logging/ParallelConsoleAppender.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/util/junit_parallel_logging/ParallelConsoleAppender.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/junit_parallel_logging/ParallelConsoleAppender.java index b92375705526..9390a5a039b9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/junit_parallel_logging/ParallelConsoleAppender.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_parallel_logging/ParallelConsoleAppender.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.junit_parallel_logging; +package de.tum.cit.aet.artemis.core.util.junit_parallel_logging; import static org.assertj.core.api.Assertions.fail; @@ -10,11 +10,11 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; -import de.tum.cit.aet.artemis.AbstractArtemisIntegrationTest; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationGitlabCIGitlabSamlTest; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; +import de.tum.cit.aet.artemis.shared.base.AbstractArtemisIntegrationTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationGitlabCIGitlabSamlTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; /** * This custom appender is used to capture the logs of multiple tests running in parallel. diff --git a/src/test/java/de/tum/cit/aet/artemis/util/junit_parallel_logging/ThreadIdConverter.java b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_parallel_logging/ThreadIdConverter.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/util/junit_parallel_logging/ThreadIdConverter.java rename to src/test/java/de/tum/cit/aet/artemis/core/util/junit_parallel_logging/ThreadIdConverter.java index 2aeb13b52d7c..bc2f02c5b5b3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/junit_parallel_logging/ThreadIdConverter.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/junit_parallel_logging/ThreadIdConverter.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.junit_parallel_logging; +package de.tum.cit.aet.artemis.core.util.junit_parallel_logging; import ch.qos.logback.classic.pattern.ClassicConverter; import ch.qos.logback.classic.spi.ILoggingEvent; diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExamIntegrationTest.java index 47c7231129a3..99e6b153def6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExamIntegrationTest.java @@ -40,7 +40,6 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; @@ -51,6 +50,8 @@ import de.tum.cit.aet.artemis.core.dto.pageablesearch.SearchTermPageableSearchDTO; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.core.service.user.PasswordService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; @@ -62,39 +63,40 @@ import de.tum.cit.aet.artemis.exam.dto.ExamSessionDTO; import de.tum.cit.aet.artemis.exam.dto.ExamWithIdAndCourseDTO; import de.tum.cit.aet.artemis.exam.dto.SuspiciousExamSessionsDTO; -import de.tum.cit.aet.artemis.exam.repository.ExamLiveEventRepository; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; import de.tum.cit.aet.artemis.exam.service.ExamDateService; import de.tum.cit.aet.artemis.exam.service.ExamService; +import de.tum.cit.aet.artemis.exam.test_repository.ExamLiveEventTestRepository; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseType; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.ExerciseForPlagiarismCasesOverviewDTO; import de.tum.cit.aet.artemis.exercise.dto.ExerciseGroupWithIdAndExamDTO; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; +import de.tum.cit.aet.artemis.fileupload.util.ZipFileTestUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizGroup; import de.tum.cit.aet.artemis.quiz.domain.QuizPool; import de.tum.cit.aet.artemis.quiz.domain.QuizQuestion; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; import de.tum.cit.aet.artemis.quiz.repository.QuizPoolRepository; import de.tum.cit.aet.artemis.quiz.service.QuizPoolService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserFactory; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; -import de.tum.cit.aet.artemis.util.ZipFileTestUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class ExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -102,7 +104,7 @@ class ExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "examint"; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseRepository; @Autowired private ExamRepository examRepository; @@ -111,19 +113,19 @@ class ExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { private ExamService examService; @Autowired - private ExamLiveEventRepository examLiveEventRepository; + private ExamLiveEventTestRepository examLiveEventRepository; @Autowired private ExamDateService examDateService; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private PasswordService passwordService; @@ -198,7 +200,7 @@ void setup() { User instructor10 = userUtilService.getUserByLogin(TEST_PREFIX + "instructor10"); instructor10.setGroups(Set.of(course10.getInstructorGroupName())); - userRepository.save(instructor10); + userTestRepository.save(instructor10); ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 200; participantScoreScheduleService.activate(); diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamParticipationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExamParticipationIntegrationTest.java index 46fdd45c4728..41cc9016ccac 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamParticipationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExamParticipationIntegrationTest.java @@ -32,8 +32,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.BonusStrategy; import de.tum.cit.aet.artemis.assessment.domain.GradeType; @@ -43,13 +41,13 @@ import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; import de.tum.cit.aet.artemis.assessment.repository.ParticipantScoreRepository; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; -import de.tum.cit.aet.artemis.bonus.BonusFactory; +import de.tum.cit.aet.artemis.assessment.util.BonusFactory; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.DueDateStat; import de.tum.cit.aet.artemis.core.dto.StatsForDashboardDTO; -import de.tum.cit.aet.artemis.core.repository.ParticipationTestRepository; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; @@ -58,36 +56,39 @@ import de.tum.cit.aet.artemis.exam.dto.ExamScoresDTO; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; import de.tum.cit.aet.artemis.exam.service.ExamService; import de.tum.cit.aet.artemis.exam.service.StudentExamService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; -import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; import de.tum.cit.aet.artemis.quiz.service.QuizSubmissionService; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizSubmissionTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.util.ExamPrepareExercisesTestUtil; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ExamParticipationIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -96,10 +97,10 @@ class ExamParticipationIntegrationTest extends AbstractSpringIntegrationJenkinsG private static final Logger log = LoggerFactory.getLogger(ExamParticipationIntegrationTest.class); @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseRepository; @Autowired - private QuizSubmissionRepository quizSubmissionRepository; + private QuizSubmissionTestRepository quizSubmissionRepository; @Autowired private QuizSubmissionService quizSubmissionService; @@ -117,13 +118,13 @@ class ExamParticipationIntegrationTest extends AbstractSpringIntegrationJenkinsG private StudentExamService studentExamService; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ParticipationTestRepository participationTestRepository; @@ -459,8 +460,8 @@ void testGetStatsForExamAssessmentDashboard(int numberOfCorrectionRounds) throws log.debug("testGetStatsForExamAssessmentDashboard: step 1 done"); doNothing().when(gitService).combineAllCommitsOfRepositoryIntoOne(any()); - User examTutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); - User examTutor2 = userRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); + User examTutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User examTutor2 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); var examVisibleDate = ZonedDateTime.now().minusMinutes(5); var examStartDate = ZonedDateTime.now().plusMinutes(5); @@ -667,8 +668,8 @@ void testGetStatsForExamAssessmentDashboard(int numberOfCorrectionRounds) throws private void lockAndAssessForSecondCorrection(Exam exam, Course course, List studentExams, List exercisesInExam, int numberOfCorrectionRounds) throws Exception { // Lock all submissions - User examInstructor = userRepository.findOneByLogin(TEST_PREFIX + "instructor1").orElseThrow(); - User examTutor2 = userRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); + User examInstructor = userTestRepository.findOneByLogin(TEST_PREFIX + "instructor1").orElseThrow(); + User examTutor2 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); for (var exercise : exercisesInExam) { for (var participation : exercise.getStudentParticipations()) { @@ -966,7 +967,7 @@ void testGetExamScore(boolean withCourseBonus, boolean withSecondCorrectionAndSt // Compare StudentResult with the generated results for (var studentResult : examScores.studentResults()) { // Find the original user using the id in StudentResult - User originalUser = userRepository.findByIdElseThrow(studentResult.userId()); + User originalUser = userTestRepository.findByIdElseThrow(studentResult.userId()); StudentExam studentExamOfUser = studentExams.stream().filter(studentExam -> studentExam.getUser().equals(originalUser)).findFirst().orElseThrow(); assertThat(studentResult.name()).isEqualTo(originalUser.getName()); @@ -1108,12 +1109,12 @@ private void configureCourseAsBonusWithIndividualAndTeamResults(Course course, G textExerciseUtilService.createIndividualTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); Exercise teamExercise = textExerciseUtilService.createTeamTextExercise(course, pastTimestamp, pastTimestamp, pastTimestamp); - User tutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + User tutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); Long teamTextExerciseId = teamExercise.getId(); Long team1Id = teamUtilService.createTeam(Set.of(student1), tutor1, teamExercise, TEST_PREFIX + "team1").getId(); - User student2 = userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); - User student3 = userRepository.findOneByLogin(TEST_PREFIX + "student3").orElseThrow(); - User tutor2 = userRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); + User student2 = userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); + User student3 = userTestRepository.findOneByLogin(TEST_PREFIX + "student3").orElseThrow(); + User tutor2 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow(); Long team2Id = teamUtilService.createTeam(Set.of(student2, student3), tutor2, teamExercise, TEST_PREFIX + "team2").getId(); participationUtilService.createParticipationSubmissionAndResult(individualTextExerciseId, student1, 10.0, 10.0, 50, true); diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamRegistrationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExamRegistrationIntegrationTest.java index 961efcba6bf5..016803accf6b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamRegistrationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExamRegistrationIntegrationTest.java @@ -18,7 +18,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; @@ -28,12 +27,15 @@ import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.service.ldap.LdapUserDto; import de.tum.cit.aet.artemis.core.service.user.PasswordService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; import de.tum.cit.aet.artemis.exam.service.ExamRegistrationService; -import de.tum.cit.aet.artemis.user.UserFactory; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class ExamRegistrationIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -100,9 +102,9 @@ void tearDown() { void testRegisterUserInExam_addedToCourseStudentsGroup() throws Exception { User student42 = userUtilService.getUserByLogin(TEST_PREFIX + "student42"); - Set studentsInCourseBefore = userRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalseAndGroupsContains(course1.getStudentGroupName()); + Set studentsInCourseBefore = userTestRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalseAndGroupsContains(course1.getStudentGroupName()); request.postWithoutLocation("/api/courses/" + course1.getId() + "/exams/" + exam1.getId() + "/students/" + TEST_PREFIX + "student42", null, HttpStatus.OK, null); - Set studentsInCourseAfter = userRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalseAndGroupsContains(course1.getStudentGroupName()); + Set studentsInCourseAfter = userTestRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalseAndGroupsContains(course1.getStudentGroupName()); studentsInCourseBefore.add(student42); assertThat(studentsInCourseBefore).containsExactlyInAnyOrderElementsOf(studentsInCourseAfter); } @@ -150,7 +152,7 @@ void testRegisterUsersInExam() throws Exception { userUtilService.createAndSaveUser("student99"); // not registered for the course userUtilService.setRegistrationNumberOfUserAndSave("student99", registrationNumber99); - User student99 = userRepository.findOneWithGroupsAndAuthoritiesByLogin("student99").orElseThrow(); + User student99 = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin("student99").orElseThrow(); assertThat(student99.getGroups()).doesNotContain(course1.getStudentGroupName()); // Note: student111 is not yet a user of Artemis and should be retrieved from the LDAP @@ -201,7 +203,7 @@ void testRegisterUsersInExam() throws Exception { for (var examUser : storedExam.getExamUsers()) { // all registered users must have access to the course - var user = userRepository.findOneWithGroupsAndAuthoritiesByLogin(examUser.getUser().getLogin()).orElseThrow(); + var user = userTestRepository.findOneWithGroupsAndAuthoritiesByLogin(examUser.getUser().getLogin()).orElseThrow(); assertThat(user.getGroups()).contains(course1.getStudentGroupName()); } @@ -269,7 +271,7 @@ void testDeleteStudentThatDoesNotExist() throws Exception { void testAddAllRegisteredUsersToExam() throws Exception { Exam exam = examUtilService.addExam(course1); Channel channel = examUtilService.addExamChannel(exam, "testchannel"); - int numberOfStudentsInCourse = userRepository.findAllByIsDeletedIsFalseAndGroupsContains(course1.getStudentGroupName()).size(); + int numberOfStudentsInCourse = userTestRepository.findAllByIsDeletedIsFalseAndGroupsContains(course1.getStudentGroupName()).size(); User student99 = userUtilService.createAndSaveUser(TEST_PREFIX + "student99"); // not registered for the course student99.setGroups(Collections.singleton("tumuser")); diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamSessionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExamSessionIntegrationTest.java index 309509526ddc..6e9f3e29a6a2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamSessionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExamSessionIntegrationTest.java @@ -7,13 +7,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamSessionRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; import de.tum.cit.aet.artemis.exam.service.ExamSessionService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import inet.ipaddr.IPAddressString; class ExamSessionIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -21,7 +22,7 @@ class ExamSessionIntegrationTest extends AbstractSpringIntegrationIndependentTes private static final String TEST_PREFIX = "examsessionintegration"; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private ExamSessionRepository examSessionRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamStartTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExamStartTest.java index af6ad0bc8697..60aad76d09b3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamStartTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExamStartTest.java @@ -26,38 +26,39 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.ParticipationTestRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExerciseGroupRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlRepositoryPermission; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; // TODO IMPORTANT test more complex exam configurations (mixed exercise type, more variants and more registered students) class ExamStartTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -74,7 +75,7 @@ class ExamStartTest extends AbstractSpringIntegrationLocalCILocalVCTest { private ExerciseGroupRepository exerciseGroupRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private ParticipationTestRepository participationTestRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamUserIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExamUserIntegrationTest.java index 4c5d61e95770..783146cedfcd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamUserIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExamUserIntegrationTest.java @@ -31,7 +31,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exam.domain.Exam; @@ -41,9 +40,11 @@ import de.tum.cit.aet.artemis.exam.dto.ExamUserDTO; import de.tum.cit.aet.artemis.exam.dto.ExamUsersNotFoundDTO; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ExamUserIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -56,7 +57,7 @@ class ExamUserIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest private ObjectMapper mapper; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private ProgrammingExerciseTestService programmingExerciseTestService; @@ -89,16 +90,16 @@ void initTestCase() throws Exception { // same registration number as in test pdf file student1.setRegistrationNumber("03756882"); - userRepository.save(student1); + userTestRepository.save(student1); student2.setRegistrationNumber("03756883"); - userRepository.save(student2); + userTestRepository.save(student2); student3.setRegistrationNumber("03756884"); - userRepository.save(student3); + userTestRepository.save(student3); student4.setRegistrationNumber("03756885"); - userRepository.save(student4); + userTestRepository.save(student4); exam1 = examUtilService.addActiveExamWithRegisteredUser(course1, student2); exam1 = examUtilService.addExerciseGroupsAndExercisesToExam(exam1, false); diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExerciseGroupIntegrationJenkinsGitlabTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ExerciseGroupIntegrationJenkinsGitlabTest.java index f4a09ad2eede..f9cfcdff20e1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExerciseGroupIntegrationJenkinsGitlabTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ExerciseGroupIntegrationJenkinsGitlabTest.java @@ -19,24 +19,26 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.security.Role; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ExerciseGroupIntegrationJenkinsGitlabTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ProgrammingExamIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/ProgrammingExamIntegrationTest.java index 603fddf9ff29..ef813745a412 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ProgrammingExamIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/ProgrammingExamIntegrationTest.java @@ -27,7 +27,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; @@ -35,16 +34,19 @@ import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -54,10 +56,10 @@ class ProgrammingExamIntegrationTest extends AbstractSpringIntegrationJenkinsGit private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/QuizPoolIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/QuizPoolIntegrationTest.java index 6f3c6da3507d..75169e82c107 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/QuizPoolIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/QuizPoolIntegrationTest.java @@ -12,11 +12,10 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exam.domain.Exam; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; import de.tum.cit.aet.artemis.quiz.domain.MultipleChoiceQuestion; import de.tum.cit.aet.artemis.quiz.domain.QuizGroup; @@ -24,6 +23,8 @@ import de.tum.cit.aet.artemis.quiz.domain.QuizQuestion; import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerQuestion; import de.tum.cit.aet.artemis.quiz.service.QuizPoolService; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class QuizPoolIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/StudentExamIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/StudentExamIntegrationTest.java index f2620706e1f0..6fc165d0aeeb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/StudentExamIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/StudentExamIntegrationTest.java @@ -1,11 +1,11 @@ package de.tum.cit.aet.artemis.exam; -import static de.tum.cit.aet.artemis.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredFileUploadExercise; -import static de.tum.cit.aet.artemis.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredModelingExercise; -import static de.tum.cit.aet.artemis.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredProgrammingExercise; -import static de.tum.cit.aet.artemis.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredTextExercise; -import static de.tum.cit.aet.artemis.util.TestConstants.COMMIT_HASH_OBJECT_ID; -import static de.tum.cit.aet.artemis.util.TestConstants.COMMIT_HASH_STRING; +import static de.tum.cit.aet.artemis.core.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredFileUploadExercise; +import static de.tum.cit.aet.artemis.core.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredModelingExercise; +import static de.tum.cit.aet.artemis.core.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredProgrammingExercise; +import static de.tum.cit.aet.artemis.core.util.SensitiveInformationUtil.assertSensitiveInformationWasFilteredTextExercise; +import static de.tum.cit.aet.artemis.core.util.TestConstants.COMMIT_HASH_OBJECT_ID; +import static de.tum.cit.aet.artemis.core.util.TestConstants.COMMIT_HASH_STRING; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.fail; @@ -58,8 +58,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.BonusStrategy; import de.tum.cit.aet.artemis.assessment.domain.GradeType; @@ -67,12 +65,12 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.BonusRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingScaleRepository; -import de.tum.cit.aet.artemis.bonus.BonusFactory; +import de.tum.cit.aet.artemis.assessment.util.BonusFactory; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; import de.tum.cit.aet.artemis.core.util.RoundingUtil; import de.tum.cit.aet.artemis.exam.domain.Exam; @@ -87,26 +85,27 @@ import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamSessionRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; import de.tum.cit.aet.artemis.exam.service.ExamQuizService; import de.tum.cit.aet.artemis.exam.service.StudentExamService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.SubmissionVersionRepository; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; @@ -115,6 +114,10 @@ import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.LockRepositoryPolicy; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.SubmissionPolicy; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.AnswerOption; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropMapping; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; @@ -128,11 +131,10 @@ import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSubmittedAnswer; import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSubmittedText; import de.tum.cit.aet.artemis.quiz.domain.SubmittedAnswer; -import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizSubmissionTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.util.ExamPrepareExercisesTestUtil; -import de.tum.cit.aet.artemis.util.LocalRepository; class StudentExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -150,10 +152,10 @@ class StudentExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabT private ExamUserRepository examUserRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private ExamSessionRepository examSessionRepository; @@ -162,7 +164,7 @@ class StudentExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabT private ProgrammingSubmissionTestRepository programmingSubmissionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private SubmissionVersionRepository submissionVersionRepository; @@ -171,7 +173,7 @@ class StudentExamIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabT private ExamQuizService examQuizService; @Autowired - private QuizSubmissionRepository quizSubmissionRepository; + private QuizSubmissionTestRepository quizSubmissionTestRepository; @Autowired private ParticipationService participationService; @@ -2484,7 +2486,7 @@ void testTestRunGradeSummaryDoesNotReturn404() throws Exception { private void checkQuizSubmission(long quizExerciseId, long quizSubmissionId) { - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExerciseId)).hasSize(1); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExerciseId)).hasSize(1); List results = resultRepository.findByParticipationExerciseIdOrderByCompletionDateAsc(quizExerciseId); assertThat(results).hasSize(1); @@ -2493,7 +2495,7 @@ private void checkQuizSubmission(long quizExerciseId, long quizSubmissionId) { assertThat(result.getScore()).isEqualTo(44.4); var resultQuizSubmission = (QuizSubmission) result.getSubmission(); - resultQuizSubmission = quizSubmissionRepository.findWithEagerResultAndFeedbackById(resultQuizSubmission.getId()).orElseThrow(); + resultQuizSubmission = quizSubmissionTestRepository.findWithEagerResultAndFeedbackById(resultQuizSubmission.getId()).orElseThrow(); assertThat(resultQuizSubmission.getScoreInPoints()).isEqualTo(4D); var submittedAnswers = resultQuizSubmission.getSubmittedAnswers(); for (SubmittedAnswer submittedAnswer : submittedAnswers) { diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/TestExamIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/TestExamIntegrationTest.java index 71153f6dc025..159866350e68 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/TestExamIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/TestExamIntegrationTest.java @@ -13,19 +13,21 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.user.PasswordService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.user.UserFactory; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TestExamIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamAccessServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamAccessServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/service/exam/ExamAccessServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exam/service/ExamAccessServiceTest.java index 9450f201ad75..e7cce14f7eb0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamAccessServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamAccessServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.exam; +package de.tum.cit.aet.artemis.exam.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; @@ -22,18 +21,19 @@ import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; import de.tum.cit.aet.artemis.core.exception.ConflictException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.Role; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ExamAccessServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -46,10 +46,10 @@ class ExamAccessServiceTest extends AbstractSpringIntegrationIndependentTest { private ExamUserRepository examUserRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamQuizServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/exam/ExamQuizServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java index 6f9dbee655cf..83152e0c94f7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamQuizServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamQuizServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.exam; +package de.tum.cit.aet.artemis.exam.service; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -14,30 +14,29 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExerciseGroupRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exam.service.StudentExamService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; import de.tum.cit.aet.artemis.quiz.domain.MultipleChoiceQuestion; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizQuestion; import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; -import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; import de.tum.cit.aet.artemis.quiz.service.QuizExerciseService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizSubmissionTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ExamQuizServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -50,10 +49,10 @@ class ExamQuizServiceTest extends AbstractSpringIntegrationIndependentTest { private ExamRepository examRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private QuizSubmissionRepository quizSubmissionRepository; + private QuizSubmissionTestRepository quizSubmissionRepository; @Autowired private ExerciseGroupRepository exerciseGroupRepository; @@ -62,10 +61,10 @@ class ExamQuizServiceTest extends AbstractSpringIntegrationIndependentTest { private QuizExerciseService quizExerciseService; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseTestRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private UserUtilService userUtilService; @@ -358,7 +357,7 @@ void evaluateQuiz_twice() throws Exception { } private void checkStatistics(QuizExercise quizExercise) { - QuizExercise quizExerciseWithStatistic = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + QuizExercise quizExerciseWithStatistic = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(quizExerciseWithStatistic.getQuizPointStatistic().getParticipantsUnrated()).isZero(); assertThat(quizExerciseWithStatistic.getQuizPointStatistic().getParticipantsRated()).isEqualTo(NUMBER_OF_STUDENTS); diff --git a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/exam/ExamServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exam/service/ExamServiceTest.java index 548e2b4ef779..140deeae34c1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.exam; +package de.tum.cit.aet.artemis.exam.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -14,26 +14,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.dto.ExamChecklistDTO; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.service.ExamService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; class ExamServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -46,7 +45,7 @@ class ExamServiceTest extends AbstractSpringIntegrationIndependentTest { private ExamRepository examRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ExerciseRepository exerciseRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamSubmissionServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamSubmissionServiceTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/service/exam/ExamSubmissionServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exam/service/ExamSubmissionServiceTest.java index 4402b3489eb2..ef1504d9b94a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/exam/ExamSubmissionServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/service/ExamSubmissionServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.exam; +package de.tum.cit.aet.artemis.exam.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -10,28 +10,27 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exam.service.ExamSubmissionService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ExamSubmissionServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -44,10 +43,10 @@ class ExamSubmissionServiceTest extends AbstractSpringIntegrationIndependentTest private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/exam/StudentExamAccessServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exam/service/StudentExamAccessServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/exam/StudentExamAccessServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exam/service/StudentExamAccessServiceTest.java index a5e76f5f98af..b10ce16e4c06 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/exam/StudentExamAccessServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/service/StudentExamAccessServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.exam; +package de.tum.cit.aet.artemis.exam.service; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatNoException; @@ -10,19 +10,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; import de.tum.cit.aet.artemis.core.exception.ConflictException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.StudentExam; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exam.service.StudentExamAccessService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class StudentExamAccessServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -32,7 +31,7 @@ class StudentExamAccessServiceTest extends AbstractSpringIntegrationIndependentT private StudentExamAccessService studentExamAccessService; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/test_repository/ExamLiveEventTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/exam/test_repository/ExamLiveEventTestRepository.java new file mode 100644 index 000000000000..9770300fc3b2 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/exam/test_repository/ExamLiveEventTestRepository.java @@ -0,0 +1,30 @@ +package de.tum.cit.aet.artemis.exam.test_repository; + +import java.util.List; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.exam.domain.event.ExamLiveEvent; +import de.tum.cit.aet.artemis.exam.repository.ExamLiveEventRepository; + +@Repository +@Primary +public interface ExamLiveEventTestRepository extends ExamLiveEventRepository { + + /** + * Find all events for the given student exam in reverse creation order. + * + * @param studentExamId the id of the student exam + * @return a list of events + */ + @Query(""" + SELECT event + FROM ExamLiveEvent event + WHERE event.studentExamId = :studentExamId + ORDER BY event.id DESC + """) + List findAllByStudentExamId(@Param("studentExamId") Long studentExamId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/test_repository/StudentExamTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/exam/test_repository/StudentExamTestRepository.java new file mode 100644 index 000000000000..280780c350b2 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/exam/test_repository/StudentExamTestRepository.java @@ -0,0 +1,86 @@ +package de.tum.cit.aet.artemis.exam.test_repository; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; +import de.tum.cit.aet.artemis.exam.domain.StudentExam; +import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; + +@Repository +@Primary +public interface StudentExamTestRepository extends StudentExamRepository { + + List findAllByExamId_AndTestRunIsTrue(Long examId); + + @Query(""" + SELECT DISTINCT se + FROM StudentExam se + LEFT JOIN FETCH se.exercises e + LEFT JOIN FETCH e.studentParticipations sp + LEFT JOIN FETCH sp.submissions s + LEFT JOIN FETCH s.results r + LEFT JOIN FETCH r.assessor a + WHERE se.exam.id = :examId + AND se.testRun = TRUE + AND se.user.id = sp.student.id + """) + List findAllTestRunsWithExercisesParticipationsSubmissionsResultsByExamId(@Param("examId") Long examId); + + /** + * Get all student exams for the given exam id with exercises. + * + * @param ids the ids of the student exams + * @return the list of student exams with exercises + */ + @Query(""" + SELECT DISTINCT se + FROM StudentExam se + LEFT JOIN FETCH se.exercises e + WHERE se.id IN :ids + """) + List findAllWithEagerExercisesById(@Param("ids") List ids); + + /** + * Get all student exams for the given exam id with quiz questions. + * + * @param ids the ids of the student exams + * @return the list of student exams with quiz questions + */ + @Query(""" + SELECT DISTINCT se + FROM StudentExam se + LEFT JOIN FETCH se.quizQuestions qq + WHERE se.id IN :ids + """) + List findAllWithEagerQuizQuestionsById(@Param("ids") List ids); + + // Normally, there should only be one student exam for the same user/exam pair (except test runs for instructors) + @Query(""" + SELECT DISTINCT se + FROM StudentExam se + LEFT JOIN FETCH se.exercises e + WHERE se.testRun = FALSE + AND se.exam.id = :examId + AND se.user.id = :userId + """) + List findAllWithExercisesByUserIdAndExamId(@Param("userId") long userId, @Param("examId") long examId); + + /** + * Get the maximal working time of all student exams for the exam with the given id. + * + * @param examId the id of the exam + * @return the maximum of all student exam working times for the given exam + * @throws EntityNotFoundException if no student exams could be found + */ + @NotNull + default Integer findMaxWorkingTimeByExamIdElseThrow(Long examId) { + return getArbitraryValueElseThrow(findMaxWorkingTimeByExamId(examId), Long.toString(examId)); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamFactory.java b/src/test/java/de/tum/cit/aet/artemis/exam/util/ExamFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exam/ExamFactory.java rename to src/test/java/de/tum/cit/aet/artemis/exam/util/ExamFactory.java index 735195d87177..0c7103a63d8e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/util/ExamFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exam; +package de.tum.cit.aet.artemis.exam.util; import static java.time.ZonedDateTime.now; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/ExamPrepareExercisesTestUtil.java b/src/test/java/de/tum/cit/aet/artemis/exam/util/ExamPrepareExercisesTestUtil.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/util/ExamPrepareExercisesTestUtil.java rename to src/test/java/de/tum/cit/aet/artemis/exam/util/ExamPrepareExercisesTestUtil.java index 9f262d88b9fd..241731914215 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/ExamPrepareExercisesTestUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/util/ExamPrepareExercisesTestUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.exam.util; import static org.assertj.core.api.Assertions.fail; @@ -8,6 +8,7 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.util.ExamExerciseStartPreparationStatus; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; public class ExamPrepareExercisesTestUtil { diff --git a/src/test/java/de/tum/cit/aet/artemis/exam/ExamUtilService.java b/src/test/java/de/tum/cit/aet/artemis/exam/util/ExamUtilService.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exam/ExamUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/exam/util/ExamUtilService.java index f6d9caba65d3..ba1fe0c84b8f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exam/ExamUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/util/ExamUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exam; +package de.tum.cit.aet.artemis.exam.util; import static java.time.ZonedDateTime.now; import static org.assertj.core.api.Assertions.assertThat; @@ -16,14 +16,16 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; -import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationFactory; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamSession; import de.tum.cit.aet.artemis.exam.domain.ExamUser; @@ -33,40 +35,38 @@ import de.tum.cit.aet.artemis.exam.repository.ExamSessionRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; import de.tum.cit.aet.artemis.exam.repository.ExerciseGroupRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseFactory; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.post.ConversationFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizPool; import de.tum.cit.aet.artemis.quiz.service.QuizPoolService; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; /** * Service responsible for initializing the database with specific testdata related to exams for use in integration tests. @@ -79,16 +79,16 @@ public class ExamUtilService { private static final ZonedDateTime FUTURE_FUTURE_TIMESTAMP = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired private ExamRepository examRepository; @@ -103,7 +103,7 @@ public class ExamUtilService { private ExamUserRepository examUserRepository; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; @Autowired private ExerciseGroupRepository exerciseGroupRepository; @@ -130,7 +130,7 @@ public class ExamUtilService { private UserUtilService userUtilService; @Autowired - private ConversationRepository conversationRepository; + private ConversationTestRepository conversationRepository; @Autowired private ParticipationUtilService participationUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/InvalidExamExerciseDatesArgumentProvider.java b/src/test/java/de/tum/cit/aet/artemis/exam/util/InvalidExamExerciseDatesArgumentProvider.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/util/InvalidExamExerciseDatesArgumentProvider.java rename to src/test/java/de/tum/cit/aet/artemis/exam/util/InvalidExamExerciseDatesArgumentProvider.java index e28bc84dad4f..90c60ad1d1fb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/InvalidExamExerciseDatesArgumentProvider.java +++ b/src/test/java/de/tum/cit/aet/artemis/exam/util/InvalidExamExerciseDatesArgumentProvider.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.exam.util; import java.time.ZonedDateTime; import java.util.stream.Stream; @@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.ArgumentsProvider; import de.tum.cit.aet.artemis.exercise.domain.Exercise; +import de.tum.cit.aet.artemis.exercise.util.InvalidExerciseConfiguration; /** * Provides arguments in form of a for parameterized JUnit 5 tests (see {@link ParameterizedTest}) that are not a valid date configuration for exam exercises. diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseIntegrationTest.java index 8fa60195e1c7..c974ed6519e3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseIntegrationTest.java @@ -21,42 +21,42 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; -import de.tum.cit.aet.artemis.assessment.repository.TutorParticipationRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.TutorParticipationTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.StatsForDashboardDTO; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.ExerciseDetailsDTO; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.service.ExerciseService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizPointStatistic; import de.tum.cit.aet.artemis.quiz.domain.QuizQuestion; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorParticipationStatus; -import de.tum.cit.aet.artemis.util.TestResourceUtils; class ExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -66,10 +66,10 @@ class ExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTest { private ExamRepository examRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired - private TutorParticipationRepository tutorParticipationRepo; + private TutorParticipationTestRepository tutorParticipationRepo; @Autowired private ExerciseService exerciseService; @@ -164,7 +164,7 @@ void testFilterOutExercisesThatUserShouldNotSee() throws Exception { .isThrownBy(() -> exerciseService.findOneWithDetailsForStudents(Long.MAX_VALUE, userUtilService.getUserByLogin(TEST_PREFIX + "student1"))); var course = courseUtilService.createCoursesWithExercisesAndLectures(TEST_PREFIX, false, NUMBER_OF_TUTORS).getFirst(); // the course with exercises var exercises = exerciseRepository.findByCourseIdWithCategories(course.getId()); - var student = userRepository.getUserWithGroupsAndAuthorities(TEST_PREFIX + "student1"); + var student = userTestRepository.getUserWithGroupsAndAuthorities(TEST_PREFIX + "student1"); assertThat(exerciseService.filterOutExercisesThatUserShouldNotSee(Set.of(), student)).isEmpty(); var exercise = exercises.iterator().next(); exercise.setReleaseDate(ZonedDateTime.now().plusDays(1)); @@ -172,7 +172,7 @@ void testFilterOutExercisesThatUserShouldNotSee() throws Exception { exercises = exerciseRepository.findByCourseIdWithCategories(course.getId()); assertThat(exerciseService.filterOutExercisesThatUserShouldNotSee(new HashSet<>(exercises), student)).hasSize(exercises.size() - 1); - var tutor = userRepository.getUserWithGroupsAndAuthorities(TEST_PREFIX + "tutor1"); + var tutor = userTestRepository.getUserWithGroupsAndAuthorities(TEST_PREFIX + "tutor1"); assertThat(exerciseService.filterOutExercisesThatUserShouldNotSee(new HashSet<>(exercises), tutor)).hasSize(exercises.size()); course.setOnlineCourse(true); @@ -618,7 +618,7 @@ void testGetExerciseForAssessmentDashboard_exerciseWithTutorParticipation() thro private List findTutors(Course course) { List tutors = new ArrayList<>(); - Page allUsers = userRepository.findAllWithGroupsByIsDeletedIsFalse(Pageable.unpaged()); + Page allUsers = userTestRepository.findAllWithGroupsByIsDeletedIsFalse(Pageable.unpaged()); for (User user : allUsers) { if (user.getGroups().contains(course.getTeachingAssistantGroupName())) { tutors.add(user); diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/ExerciseTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/domain/ExerciseTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseTest.java index 1656002f1a3d..a7906e1ed20b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/ExerciseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.exercise; import static org.assertj.core.api.Assertions.assertThat; @@ -11,27 +11,27 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; import de.tum.cit.aet.artemis.exercise.service.ExerciseService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class ExerciseTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/enumeration/ExerciseTypeTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseTypeTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/domain/enumeration/ExerciseTypeTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseTypeTest.java index a5d15c209b28..bdad98b8ecc7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/enumeration/ExerciseTypeTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseTypeTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain.enumeration; +package de.tum.cit.aet.artemis.exercise; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; diff --git a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/participation/ParticipationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java index da6d265d2616..03beb447adad 100644 --- a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationIntegrationTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.participation; +package de.tum.cit.aet.artemis.exercise.participation; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_PROGRAMMING_TEST; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.any; @@ -40,20 +40,20 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractAthenaTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.service.GradingScaleService; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleUtilService; +import de.tum.cit.aet.artemis.athena.AbstractAthenaTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.feature.Feature; import de.tum.cit.aet.artemis.core.service.feature.FeatureToggleService; -import de.tum.cit.aet.artemis.exam.ExamFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; @@ -61,24 +61,23 @@ import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.quiz.domain.QuizBatch; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; @@ -90,19 +89,22 @@ import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSubmittedText; import de.tum.cit.aet.artemis.quiz.dto.QuizBatchJoinDTO; import de.tum.cit.aet.artemis.quiz.service.QuizBatchService; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ParticipationIntegrationTest extends AbstractAthenaTest { private static final String TEST_PREFIX = "participationintegration"; @Autowired - private StudentParticipationRepository participationRepo; + private StudentParticipationTestRepository participationRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private FeatureToggleService featureToggleService; diff --git a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationSubmissionIntegrationTest.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/participation/ParticipationSubmissionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationSubmissionIntegrationTest.java index f1bcf54b89b1..8d1906abc6a4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/ParticipationSubmissionIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.participation; +package de.tum.cit.aet.artemis.exercise.participation; import static org.assertj.core.api.Assertions.assertThat; @@ -10,20 +10,21 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.exercise.domain.Submission; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ParticipationSubmissionIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "psitest"; // only lower case is supported @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private TextExerciseUtilService textExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/participation/SubmissionExportIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/SubmissionExportIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/participation/SubmissionExportIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/participation/SubmissionExportIntegrationTest.java index 03c87ecef4f8..2597506236d8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/participation/SubmissionExportIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/SubmissionExportIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.participation; +package de.tum.cit.aet.artemis.exercise.participation; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -18,22 +18,24 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.SubmissionExportOptionsDTO; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class SubmissionExportIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/participation/SubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/SubmissionIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/participation/SubmissionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/participation/SubmissionIntegrationTest.java index 90ac3144a96b..ea1c38f3a44e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/participation/SubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/SubmissionIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.participation; +package de.tum.cit.aet.artemis.exercise.participation; import static org.assertj.core.api.Assertions.assertThat; @@ -11,29 +11,31 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.pageablesearch.SearchTermPageableSearchDTO; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionVersion; import de.tum.cit.aet.artemis.exercise.dto.SubmissionVersionDTO; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.SubmissionVersionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class SubmissionIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "submissionintegration"; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private TextExerciseUtilService textExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationFactory.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/util/ParticipationFactory.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/participation/ParticipationFactory.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/participation/util/ParticipationFactory.java index 9b27083b8dcd..c8d36c32eb9a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/util/ParticipationFactory.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.participation; +package de.tum.cit.aet.artemis.exercise.participation.util; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory.DEFAULT_BRANCH; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory.DEFAULT_BRANCH; import static java.time.ZonedDateTime.now; import java.time.ZonedDateTime; @@ -14,10 +14,10 @@ import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.GradingInstruction; import de.tum.cit.aet.artemis.assessment.domain.Result; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; @@ -30,10 +30,10 @@ import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.util.GitUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; /** * Factory for creating Participations and related objects. diff --git a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationUtilService.java b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/util/ParticipationUtilService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/participation/ParticipationUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/participation/util/ParticipationUtilService.java index f9c92503c35b..13f049125c0a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/participation/ParticipationUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/participation/util/ParticipationUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.participation; +package de.tum.cit.aet.artemis.exercise.participation.util; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -29,15 +29,16 @@ import de.tum.cit.aet.artemis.assessment.domain.Rating; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.assessment.repository.RatingRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; @@ -47,31 +48,30 @@ import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; +import de.tum.cit.aet.artemis.modeling.test_repository.ModelingSubmissionTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; import de.tum.cit.aet.artemis.programming.service.ParticipationVcsAccessTokenService; import de.tum.cit.aet.artemis.programming.service.UriService; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; /** * Service responsible for initializing the database with specific testdata related to participations, submissions and results. @@ -82,10 +82,10 @@ public class ParticipationUtilService { private static final ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(1); @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepo; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired private ParticipationVcsAccessTokenService participationVCSAccessTokenService; @@ -94,13 +94,13 @@ public class ParticipationUtilService { private ExerciseRepository exerciseRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private TeamRepository teamRepo; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired private FeedbackRepository feedbackRepo; @@ -109,16 +109,16 @@ public class ParticipationUtilService { private RatingRepository ratingRepo; @Autowired - private ModelingSubmissionRepository modelingSubmissionRepo; + private ModelingSubmissionTestRepository modelingSubmissionRepo; @Autowired - private TextSubmissionRepository textSubmissionRepo; + private TextSubmissionTestRepository textSubmissionRepo; @Autowired private ProgrammingSubmissionTestRepository programmingSubmissionRepo; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepo; + private ExampleSubmissionTestRepository exampleSubmissionRepo; @Autowired private ParticipationService participationService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ExerciseDateServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDateServiceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/service/ExerciseDateServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDateServiceTest.java index fcf85b4f4925..85f4b8aeb6c8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ExerciseDateServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ExerciseDateServiceTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import java.time.ZonedDateTime; @@ -12,26 +12,25 @@ import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.service.ExerciseDateService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ExerciseDateServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -44,13 +43,13 @@ class ExerciseDateServiceTest extends AbstractSpringIntegrationIndependentTest { private ModelingExerciseRepository exerciseRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ExerciseLifecycleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ExerciseLifecycleServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/ExerciseLifecycleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/ExerciseLifecycleServiceTest.java index 7f53c0962bab..477f37d00034 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ExerciseLifecycleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ExerciseLifecycleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -12,10 +12,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseLifecycle; -import de.tum.cit.aet.artemis.exercise.service.ExerciseLifecycleService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; class ExerciseLifecycleServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationAuthorizationCheckServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationAuthorizationCheckServiceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/service/ParticipationAuthorizationCheckServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationAuthorizationCheckServiceTest.java index e3db26d3f6f1..ff593fb3e250 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationAuthorizationCheckServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationAuthorizationCheckServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -11,29 +11,28 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.ParticipationInterface; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.service.ParticipationAuthorizationCheckService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; class ParticipationAuthorizationCheckServiceTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "participationauthservice"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ParticipationAuthorizationCheckService participationAuthCheckService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationLifecycleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationLifecycleServiceTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/service/ParticipationLifecycleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationLifecycleServiceTest.java index 7f82dedd1a85..29685dd555a4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationLifecycleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationLifecycleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; @@ -12,17 +12,16 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.service.ParticipationLifecycleService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ParticipationLifecycle; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ParticipationLifecycleServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationServiceTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/ParticipationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationServiceTest.java index 89965b5a87e1..216c38d8e088 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; @@ -17,32 +17,31 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.ResultService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.assessment.web.ResultResource; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.service.ParticipationService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.build.BuildLogEntry; import de.tum.cit.aet.artemis.programming.repository.BuildLogEntryRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.BuildLogEntryService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ParticipationServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -52,10 +51,10 @@ class ParticipationServiceTest extends AbstractSpringIntegrationJenkinsGitlabTes private ParticipationService participationService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private BuildLogEntryService buildLogEntryService; @@ -73,7 +72,7 @@ class ParticipationServiceTest extends AbstractSpringIntegrationJenkinsGitlabTes private ResultService resultService; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationTeamWebsocketServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationTeamWebsocketServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/ParticipationTeamWebsocketServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationTeamWebsocketServiceTest.java index 4b62026849ac..37bf559d6b73 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ParticipationTeamWebsocketServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationTeamWebsocketServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.RETURNS_MOCKS; @@ -19,21 +19,21 @@ import org.springframework.messaging.simp.stomp.StompHeaderAccessor; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.SubmissionPatch; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.exercise.web.ParticipationTeamWebsocketService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ParticipationTeamWebsocketServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/PresentationPointsCalculationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/PresentationPointsCalculationServiceTest.java similarity index 89% rename from src/test/java/de/tum/cit/aet/artemis/service/PresentationPointsCalculationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/PresentationPointsCalculationServiceTest.java index a710b4ba5cf9..0592824c6ad7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/PresentationPointsCalculationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/PresentationPointsCalculationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; @@ -7,21 +7,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.GradingScaleFactory; import de.tum.cit.aet.artemis.assessment.domain.GradingScale; import de.tum.cit.aet.artemis.assessment.service.PresentationPointsCalculationService; +import de.tum.cit.aet.artemis.assessment.util.GradingScaleFactory; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class PresentationPointsCalculationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -31,7 +31,7 @@ class PresentationPointsCalculationServiceTest extends AbstractSpringIntegration private ExerciseRepository exerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private PresentationPointsCalculationService presentationPointsCalculationService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/SubmissionServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/SubmissionServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/service/SubmissionServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/SubmissionServiceTest.java index e4e0bfd309fc..40579ab88801 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/SubmissionServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/SubmissionServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -15,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintType; @@ -24,30 +22,31 @@ import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.dto.SubmissionWithComplaintDTO; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.service.SubmissionService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; class SubmissionServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -57,13 +56,13 @@ class SubmissionServiceTest extends AbstractSpringIntegrationIndependentTest { private ExamRepository examRepository; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private SubmissionService submissionService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private ComplaintRepository complaintRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/TeamWebsocketServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/service/TeamWebsocketServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/service/TeamWebsocketServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/service/TeamWebsocketServiceTest.java index 842953c308b1..b73dc55fe396 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/TeamWebsocketServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/service/TeamWebsocketServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.exercise.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.timeout; @@ -14,11 +14,11 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.Team; @@ -26,17 +26,17 @@ import de.tum.cit.aet.artemis.exercise.dto.TeamImportStrategyType; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; class TeamWebsocketServiceTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "teamwebsocketservice"; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; @Autowired private ExerciseRepository exerciseRepo; diff --git a/src/test/java/de/tum/cit/aet/artemis/team/TeamFactory.java b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamFactory.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/team/TeamFactory.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamFactory.java index 14f8c44e39c7..b1fb4f8591a1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/team/TeamFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.team; +package de.tum.cit.aet.artemis.exercise.team; import java.util.HashSet; import java.util.List; @@ -7,9 +7,9 @@ import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.security.Role; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Team; -import de.tum.cit.aet.artemis.user.UserFactory; /** * Factory for creating Teams and related objects. diff --git a/src/test/java/de/tum/cit/aet/artemis/team/TeamImportIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamImportIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/team/TeamImportIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamImportIntegrationTest.java index c87025736992..fc098a2b622f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/team/TeamImportIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamImportIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.team; +package de.tum.cit.aet.artemis.exercise.team; import static org.assertj.core.api.Assertions.assertThat; @@ -17,7 +17,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.Exercise; @@ -25,6 +24,7 @@ import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.dto.TeamImportStrategyType; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TeamImportIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -102,7 +102,7 @@ void initTestCase() { importedTeams = importedTeamsWithBody.getFirst(); importedTeamsBody = importedTeamsWithBody.getSecond(); // Select a tutor for the teams - tutor = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + tutor = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); } private void testImportTeamsIntoExercise(ImportType type, TeamImportStrategyType importStrategyType, List body, List addedTeams) throws Exception { @@ -290,7 +290,7 @@ void testImportTeamsFromListBadRequests() throws Exception { request.put(importFromListUrl(), getTeamsIntoLoginOnlyTeams(teams), HttpStatus.BAD_REQUEST); // If user does not have an identifier: registration number or login, the request should fail - userRepository.saveAll(teams.stream().map(Team::getStudents).flatMap(Collection::stream).toList()); + userTestRepository.saveAll(teams.stream().map(Team::getStudents).flatMap(Collection::stream).toList()); request.put(importFromListUrl(), getTeamsIntoOneIdentifierTeams(teams, null), HttpStatus.BAD_REQUEST); // If user's registration number points to same user with a login in request, it should fail @@ -352,7 +352,7 @@ private Pair, List> getImportedTeamsAndBody(String shortNamePre registrationPrefix); var users = generatedTeams.stream().map(Team::getStudents).flatMap(Collection::stream).toList(); users.forEach(u -> userUtilService.cleanUpRegistrationNumberForUser(u)); - userRepository.saveAll(users); + userTestRepository.saveAll(users); List teamsWithLogins = getTeamsIntoLoginOnlyTeams(generatedTeams.subList(0, 2)); List teamsWithRegistrationNumbers = getTeamsIntoRegistrationNumberOnlyTeams(generatedTeams.subList(2, 3)); List body = Stream.concat(teamsWithLogins.stream(), teamsWithRegistrationNumbers.stream()).toList(); diff --git a/src/test/java/de/tum/cit/aet/artemis/team/TeamIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/team/TeamIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamIntegrationTest.java index 6281d327147d..5cb859499b2a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/team/TeamIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.team; +package de.tum.cit.aet.artemis.exercise.team; import static org.assertj.core.api.Assertions.assertThat; @@ -16,7 +16,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; @@ -28,15 +27,16 @@ import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.ExerciseDetailsDTO; import de.tum.cit.aet.artemis.exercise.dto.TeamSearchUserDTO; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class TeamIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -79,8 +79,8 @@ void initTestCase() { exercise.setMode(ExerciseMode.TEAM); exercise.setReleaseDate(ZonedDateTime.now().minusDays(1)); exercise = exerciseRepository.save(exercise); - students = new HashSet<>(userRepository.searchByLoginOrNameInGroup("tumuser", TEST_PREFIX + "student")); - tutor = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); + students = new HashSet<>(userTestRepository.searchByLoginOrNameInGroup("tumuser", TEST_PREFIX + "student")); + tutor = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(); } private String resourceUrl() { @@ -149,7 +149,7 @@ void testCreateTeam() throws Exception { void testCreateTeam_StudentsAlreadyAssigned_BadRequest() throws Exception { // Create team that contains student "student1" Team team1 = new Team().name(TEST_PREFIX + "Team 1").shortName(TEST_PREFIX + "team1").exercise(exercise) - .students(Set.of(userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow())); + .students(Set.of(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow())); teamRepo.save(team1); // Try to create team with a student that is already assigned to another team @@ -224,9 +224,9 @@ void testUpdateTeam_BadRequest() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "tutor1", roles = "TA") void testUpdateTeam_StudentsAlreadyAssigned_BadRequest() throws Exception { - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); - User student2 = userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); - User student3 = userRepository.findOneByLogin(TEST_PREFIX + "student3").orElseThrow(); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow(); + User student2 = userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow(); + User student3 = userTestRepository.findOneByLogin(TEST_PREFIX + "student3").orElseThrow(); Team team1 = new Team().name(TEST_PREFIX + "Team 1").shortName(TEST_PREFIX + "team1").exercise(exercise).students(Set.of(student1, student2)); team1.setOwner(tutor); @@ -275,7 +275,7 @@ void testUpdateTeam_Forbidden_ShortNameChanged() throws Exception { void testUpdateTeam_Forbidden_OwnerChanged() throws Exception { // It should not be allowed to change a team's owner as a tutor Team team = teamUtilService.addTeamForExercise(exercise, tutor); - team.setOwner(userRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow()); + team.setOwner(userTestRepository.findOneByLogin(TEST_PREFIX + "tutor2").orElseThrow()); request.putWithResponseBody(resourceUrl() + "/" + team.getId(), team, Team.class, HttpStatus.FORBIDDEN); } @@ -458,14 +458,14 @@ void testTeamOperationsAsStudent() throws Exception { void testAssignedTeamIdOnExerciseForCurrentUser() throws Exception { var student = userUtilService.getUserByLogin(TEST_PREFIX + "student1"); student.setGroups(Set.of(TEST_PREFIX + "student" + "assignedTeam")); - userRepository.save(student); + userTestRepository.save(student); course.setStudentGroupName(TEST_PREFIX + "student" + "assignedTeam"); courseRepository.save(course); // Create team that contains student "student1" (Team shortName needs to be empty since it is used as a prefix for the generated student logins) Team team = new Team().name(TEST_PREFIX + "Team").shortName(TEST_PREFIX + "team").exercise(exercise) - .students(userRepository.findOneByLogin(TEST_PREFIX + "student1").map(Set::of).orElseThrow()); + .students(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").map(Set::of).orElseThrow()); team = teamRepo.save(team); // Check for endpoint: @GetMapping("courses/for-dashboard") @@ -565,7 +565,7 @@ void getCourseWithExercisesAndParticipationsForTeam_AsTutor() throws Exception { @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void getCourseWithExercisesAndParticipationsForTeam_AsStudentInTeam_Allowed() throws Exception { Team team = teamRepo.save(new Team().name(TEST_PREFIX + "Team").shortName(TEST_PREFIX + "team").exercise(exercise) - .students(userRepository.findOneByLogin(TEST_PREFIX + "student1").map(Set::of).orElseThrow())); + .students(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").map(Set::of).orElseThrow())); request.get(resourceUrlCourseWithExercisesAndParticipationsForTeam(course, team), HttpStatus.OK, Course.class); } diff --git a/src/test/java/de/tum/cit/aet/artemis/team/TeamUtilService.java b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamUtilService.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/team/TeamUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamUtilService.java index 4b5d1d62acbf..542647f0dd8d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/team/TeamUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/team/TeamUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.team; +package de.tum.cit.aet.artemis.exercise.team; import java.util.ArrayList; import java.util.Collection; @@ -11,12 +11,12 @@ import de.tum.cit.aet.artemis.core.domain.Authority; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.Role; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; /** * Service responsible for initializing the database with specific testdata related to teams for use in integration tests. @@ -28,7 +28,7 @@ public class TeamUtilService { private UserUtilService userUtilService; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; @Autowired private TeamRepository teamRepo; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/ParticipationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/ParticipationTestRepository.java new file mode 100644 index 000000000000..57643725cb78 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/ParticipationTestRepository.java @@ -0,0 +1,39 @@ +package de.tum.cit.aet.artemis.exercise.test_repository; + +import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; +import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; + +@Repository +@Primary +public interface ParticipationTestRepository extends ParticipationRepository { + + @EntityGraph(type = LOAD, attributePaths = { "submissions" }) + List findByExercise_ExerciseGroup_Exam_Id(long examId); + + Set findByExerciseId(long exerciseId); + + @Query(""" + SELECT p + FROM Participation p + LEFT JOIN FETCH p.submissions s + WHERE p.id = :participationId + AND (s.id = (SELECT MAX(s2.id) FROM p.submissions s2) OR s.id IS NULL) + """) + Optional findByIdWithLatestSubmission(@Param("participationId") long participationId); + + default Participation findByIdWithLatestSubmissionElseThrow(Long participationId) { + return getValueElseThrow(findByIdWithLatestSubmission(participationId), participationId); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/StudentParticipationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/StudentParticipationTestRepository.java new file mode 100644 index 000000000000..f3c63bd475ae --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/StudentParticipationTestRepository.java @@ -0,0 +1,52 @@ +package de.tum.cit.aet.artemis.exercise.test_repository; + +import java.util.List; +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; + +@Repository +@Primary +public interface StudentParticipationTestRepository extends StudentParticipationRepository { + + @Query(""" + SELECT DISTINCT p + FROM StudentParticipation p + LEFT JOIN FETCH p.submissions s + LEFT JOIN FETCH s.results r + LEFT JOIN FETCH r.assessor + WHERE p.exercise.id = :exerciseId + AND p.testRun = :testRun + """) + List findByExerciseIdAndTestRunWithEagerSubmissionsResultAssessor(@Param("exerciseId") long exerciseId, @Param("testRun") boolean testRun); + + @Query(""" + SELECT p + FROM StudentParticipation p + LEFT JOIN FETCH p.results r + LEFT JOIN FETCH r.submission rs + LEFT JOIN FETCH p.submissions s + LEFT JOIN FETCH r.assessor + WHERE p.id = :participationId + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + AND (rs.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR rs.type IS NULL) + """) + Optional findWithEagerLegalSubmissionsAndResultsAssessorsById(@Param("participationId") long participationId); + + @Query(""" + SELECT p + FROM Participation p + LEFT JOIN FETCH p.results r + LEFT JOIN FETCH r.submission s + LEFT JOIN FETCH r.feedbacks + WHERE p.id = :participationId + AND (s.type <> de.tum.cit.aet.artemis.exercise.domain.SubmissionType.ILLEGAL OR s.type IS NULL) + """) + Optional findWithEagerResultsAndFeedbackById(@Param("participationId") long participationId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/SubmissionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/SubmissionTestRepository.java new file mode 100644 index 000000000000..759ff43aab58 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/test_repository/SubmissionTestRepository.java @@ -0,0 +1,42 @@ +package de.tum.cit.aet.artemis.exercise.test_repository; + +import java.util.List; +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.exercise.domain.Submission; +import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; + +@Repository +@Primary +public interface SubmissionTestRepository extends SubmissionRepository { + + /** + * Calculate the number of submitted submissions for the given exercise. This query uses the participations to make sure that each student is only counted once + * + * @param exerciseId the exercise id we are interested in + * @return the number of submissions belonging to the exercise id, which have the submitted flag set to true + */ + @Query(""" + SELECT COUNT(DISTINCT p) + FROM StudentParticipation p + JOIN p.submissions s + WHERE p.exercise.id = :exerciseId + AND s.submitted = TRUE + """) + long countByExerciseIdSubmitted(@Param("exerciseId") long exerciseId); + + /** + * Gets all submitted Submissions for the given exercise. Note that you usually only want the latest submissions. + * + * @param exerciseId the ID of the exercise + * @return Set of Submissions + */ + Set findByParticipation_ExerciseIdAndSubmittedIsTrue(long exerciseId); + + List findByParticipation_Exercise_ExerciseGroup_Exam_Id(long examId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseFactory.java b/src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseFactory.java index 0b3790d05b46..caac000ecc1b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise; +package de.tum.cit.aet.artemis.exercise.util; import java.time.ZonedDateTime; import java.util.HashSet; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/ExerciseIntegrationTestService.java b/src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseIntegrationTestService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/util/ExerciseIntegrationTestService.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseIntegrationTestService.java index f233addde06f..2b9a3a6296e3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/ExerciseIntegrationTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseIntegrationTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.exercise.util; import static org.assertj.core.api.Assertions.assertThat; @@ -12,6 +12,8 @@ import de.tum.cit.aet.artemis.core.dto.SortingOrder; import de.tum.cit.aet.artemis.core.util.PageUtil; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseUtilService.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseUtilService.java index a7a2869dc2b5..fa04fd24ca0d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/ExerciseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/util/ExerciseUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise; +package de.tum.cit.aet.artemis.exercise.util; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -18,14 +18,17 @@ import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.domain.GradingInstruction; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.AnswerPostRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationFactory; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; @@ -33,30 +36,27 @@ import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.service.ModelingSubmissionService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismVerdict; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; -import de.tum.cit.aet.artemis.post.ConversationFactory; -import de.tum.cit.aet.artemis.post.ConversationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; /** * Service responsible for initializing the database with specific testdata related to exercises for use in integration tests. @@ -68,46 +68,46 @@ public class ExerciseUtilService { private ExerciseRepository exerciseRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired - private ModelingExerciseUtilService modelingExerciseUtilService; + private ChannelRepository channelRepository; @Autowired - private ParticipationUtilService participationUtilService; + private AnswerPostRepository answerPostRepository; @Autowired - private UserUtilService userUtilService; + private PostTestRepository postRepository; @Autowired - private ModelingSubmissionService modelSubmissionService; + private PlagiarismCaseRepository plagiarismCaseRepository; @Autowired - private ProgrammingExerciseUtilService programmingExerciseUtilService; + private ModelingExerciseUtilService modelingExerciseUtilService; @Autowired - private TextExerciseUtilService textExerciseUtilService; + private ParticipationUtilService participationUtilService; @Autowired - private FileUploadExerciseUtilService fileUploadExerciseUtilService; + private UserUtilService userUtilService; @Autowired - private ChannelRepository channelRepository; + private ModelingSubmissionService modelSubmissionService; @Autowired - private AnswerPostRepository answerPostRepository; + private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private PostRepository postRepository; + private TextExerciseUtilService textExerciseUtilService; @Autowired - private PlagiarismCaseRepository plagiarismCaseRepository; + private FileUploadExerciseUtilService fileUploadExerciseUtilService; @Autowired private ConversationUtilService conversationUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/InvalidExerciseConfiguration.java b/src/test/java/de/tum/cit/aet/artemis/exercise/util/InvalidExerciseConfiguration.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/util/InvalidExerciseConfiguration.java rename to src/test/java/de/tum/cit/aet/artemis/exercise/util/InvalidExerciseConfiguration.java index b7c68ea260f5..12484d3212b5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/InvalidExerciseConfiguration.java +++ b/src/test/java/de/tum/cit/aet/artemis/exercise/util/InvalidExerciseConfiguration.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.exercise.util; import org.springframework.http.HttpStatus; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadAssessmentIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadAssessmentIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java index 6ad79e7241e2..ca1177b834fb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.fileupload; +package de.tum.cit.aet.artemis.fileupload; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.eq; @@ -22,8 +22,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; @@ -33,26 +31,30 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.dto.AssessmentUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.dto.FileUploadAssessmentDTO; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadExerciseRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.programming.dto.ResultDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FileUploadAssessmentIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -67,13 +69,13 @@ class FileUploadAssessmentIntegrationTest extends AbstractSpringIntegrationIndep private FileUploadExerciseRepository fileUploadExerciseRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ExamRepository examRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private FileUploadExerciseUtilService fileUploadExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java index 4125fccbc947..131eeaec747b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.fileupload; +package de.tum.cit.aet.artemis.fileupload; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static java.time.ZonedDateTime.now; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -29,35 +29,37 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.domain.GradingInstruction; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.dto.CourseForDashboardDTO; import de.tum.cit.aet.artemis.core.dto.SearchResultPageDTO; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadExerciseRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FileUploadExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -73,7 +75,7 @@ class FileUploadExerciseIntegrationTest extends AbstractSpringIntegrationIndepen private FileUploadExerciseRepository fileUploadExerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ChannelRepository channelRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java index bbd03d41c6e7..7d88ad1e0b01 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.fileupload; +package de.tum.cit.aet.artemis.fileupload; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatNoException; @@ -27,7 +27,6 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.config.Constants; @@ -38,15 +37,17 @@ import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadSubmissionRepository; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class FileUploadSubmissionIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -56,7 +57,7 @@ class FileUploadSubmissionIntegrationTest extends AbstractSpringIntegrationIndep private FileUploadSubmissionRepository fileUploadSubmissionRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired private FileUploadExerciseUtilService fileUploadExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseFactory.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/util/FileUploadExerciseFactory.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/fileupload/util/FileUploadExerciseFactory.java index 8e577b124304..927099073b68 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/util/FileUploadExerciseFactory.java @@ -1,10 +1,10 @@ -package de.tum.cit.aet.artemis.exercise.fileupload; +package de.tum.cit.aet.artemis.fileupload.util; import java.time.ZonedDateTime; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.ExerciseFactory; +import de.tum.cit.aet.artemis.exercise.util.ExerciseFactory; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; /** diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/util/FileUploadExerciseUtilService.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/fileupload/util/FileUploadExerciseUtilService.java index e5981d083deb..4b6084891726 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/fileupload/FileUploadExerciseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/util/FileUploadExerciseUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.fileupload; +package de.tum.cit.aet.artemis.fileupload.util; import static org.assertj.core.api.Assertions.assertThat; @@ -15,23 +15,23 @@ import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; import de.tum.cit.aet.artemis.fileupload.repository.FileUploadSubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.user.UserUtilService; /** * Service responsible for initializing the database with specific testdata related to file upload exercises for use in integration tests. @@ -49,19 +49,19 @@ public class FileUploadExerciseUtilService { private ExerciseRepository exerciseRepo; @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private FileUploadSubmissionRepository fileUploadSubmissionRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired private ExamUtilService examUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/ZipFileTestUtilService.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/util/ZipFileTestUtilService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/util/ZipFileTestUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/fileupload/util/ZipFileTestUtilService.java index 22b81aa17be2..446e00ff9f9a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/ZipFileTestUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/util/ZipFileTestUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.fileupload.util; import static org.assertj.core.api.Assertions.fail; diff --git a/src/test/java/de/tum/cit/aet/artemis/iris/AbstractIrisIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/iris/AbstractIrisIntegrationTest.java index 3f2a4f8d95f9..34337b170baf 100644 --- a/src/test/java/de/tum/cit/aet/artemis/iris/AbstractIrisIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/iris/AbstractIrisIntegrationTest.java @@ -16,16 +16,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; -import de.tum.cit.aet.artemis.connector.IrisRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.IrisRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.iris.domain.IrisTemplate; import de.tum.cit.aet.artemis.iris.domain.settings.IrisSubSettings; import de.tum.cit.aet.artemis.iris.repository.IrisSettingsRepository; import de.tum.cit.aet.artemis.iris.service.settings.IrisSettingsService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; public abstract class AbstractIrisIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -37,7 +37,7 @@ public abstract class AbstractIrisIntegrationTest extends AbstractSpringIntegrat protected IrisRequestMockProvider irisRequestMockProvider; @Autowired - protected ProgrammingExerciseRepository programmingExerciseRepository; + protected ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private IrisSettingsRepository irisSettingsRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/iris/IrisChatMessageIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/iris/IrisChatMessageIntegrationTest.java index 1a8ab50d721c..ec5028485504 100644 --- a/src/test/java/de/tum/cit/aet/artemis/iris/IrisChatMessageIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/iris/IrisChatMessageIntegrationTest.java @@ -31,6 +31,7 @@ import org.springframework.util.LinkedMultiValueMap; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.iris.domain.message.IrisMessage; import de.tum.cit.aet.artemis.iris.domain.message.IrisMessageContent; import de.tum.cit.aet.artemis.iris.domain.message.IrisMessageSender; @@ -44,7 +45,6 @@ import de.tum.cit.aet.artemis.iris.service.pyris.dto.status.PyrisStageDTO; import de.tum.cit.aet.artemis.iris.service.pyris.dto.status.PyrisStageState; import de.tum.cit.aet.artemis.iris.service.session.IrisExerciseChatSessionService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProjectType; diff --git a/src/test/java/de/tum/cit/aet/artemis/iris/PyrisLectureIngestionTest.java b/src/test/java/de/tum/cit/aet/artemis/iris/PyrisLectureIngestionTest.java index 748df0fc67e7..e7cdc125faa8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/iris/PyrisLectureIngestionTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/iris/PyrisLectureIngestionTest.java @@ -16,7 +16,8 @@ import org.springframework.util.LinkedMultiValueMap; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.iris.domain.settings.IrisCourseSettings; import de.tum.cit.aet.artemis.iris.repository.IrisSettingsRepository; import de.tum.cit.aet.artemis.iris.service.pyris.PyrisJobService; @@ -25,11 +26,10 @@ import de.tum.cit.aet.artemis.iris.service.pyris.dto.lectureingestionwebhook.PyrisLectureIngestionStatusUpdateDTO; import de.tum.cit.aet.artemis.iris.service.pyris.dto.status.PyrisStageDTO; import de.tum.cit.aet.artemis.iris.service.pyris.dto.status.PyrisStageState; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; class PyrisLectureIngestionTest extends AbstractIrisIntegrationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentResourceIntegrationTest.java index c8506349af8f..001b2ea8cda3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentResourceIntegrationTest.java @@ -18,14 +18,15 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AttachmentResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java index 82d42b46e22e..8bd6f3f6edd4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitIntegrationTest.java @@ -35,9 +35,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.core.security.SecurityUtils; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; @@ -47,7 +46,10 @@ import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.AttachmentUnitRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; +import de.tum.cit.aet.artemis.lecture.test_repository.SlideTestRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AttachmentUnitIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -65,7 +67,7 @@ class AttachmentUnitIntegrationTest extends AbstractSpringIntegrationIndependent private LectureRepository lectureRepository; @Autowired - private SlideRepository slideRepository; + private SlideTestRepository slideRepository; @Autowired private LectureUtilService lectureUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java index 3691690e2027..664b1b3d5bc6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java @@ -28,14 +28,15 @@ import org.springframework.util.MultiValueMap; import org.springframework.util.ResourceUtils; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.dto.LectureUnitSplitDTO; import de.tum.cit.aet.artemis.lecture.dto.LectureUnitSplitInformationDTO; import de.tum.cit.aet.artemis.lecture.repository.AttachmentUnitRepository; -import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitProcessingService; +import de.tum.cit.aet.artemis.lecture.test_repository.SlideTestRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AttachmentUnitsIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -45,7 +46,7 @@ class AttachmentUnitsIntegrationTest extends AbstractSpringIntegrationIndependen private AttachmentUnitRepository attachmentUnitRepository; @Autowired - private SlideRepository slideRepository; + private SlideTestRepository slideRepository; @Autowired private LectureUtilService lectureUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java index b0607630a481..18ffb227b586 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/ExerciseUnitIntegrationTest.java @@ -1,6 +1,6 @@ package de.tum.cit.aet.artemis.lecture; -import static de.tum.cit.aet.artemis.util.RequestUtilService.deleteProgrammingExerciseParamsFalse; +import static de.tum.cit.aet.artemis.core.util.RequestUtilService.deleteProgrammingExerciseParamsFalse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; @@ -16,7 +16,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; @@ -26,9 +25,10 @@ import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; @@ -43,10 +43,10 @@ class ExerciseUnitIntegrationTest extends AbstractSpringIntegrationIndependentTe private ModelingExerciseRepository modelingExerciseRepository; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private FileUploadExerciseRepository fileUploadExerciseRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java index 4f959dc82c34..0ea000015653 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureIntegrationTest.java @@ -21,12 +21,13 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; @@ -38,10 +39,11 @@ import de.tum.cit.aet.artemis.lecture.repository.AttachmentRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; class LectureIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitIntegrationTest.java index e5c539107c0a..de053a49ec99 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitIntegrationTest.java @@ -16,8 +16,7 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; @@ -30,6 +29,8 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository; import de.tum.cit.aet.artemis.lecture.repository.TextUnitRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LectureUnitIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -226,7 +227,7 @@ void setLectureUnitCompletion() throws Exception { LectureUnit lectureUnit = this.lecture1.getLectureUnits().getFirst(); assertThat(lectureUnit.getCompletedUsers()).isNotEmpty(); - assertThat(lectureUnit.isCompletedFor(userRepository.getUser())).isTrue(); + assertThat(lectureUnit.isCompletedFor(userTestRepository.getUser())).isTrue(); // Set lecture unit as uncompleted for user request.postWithoutLocation("/api/lectures/" + lecture1.getId() + "/lecture-units/" + lecture1.getLectureUnits().getFirst().getId() + "/completion?completed=false", null, @@ -236,7 +237,7 @@ void setLectureUnitCompletion() throws Exception { lectureUnit = this.lecture1.getLectureUnits().getFirst(); assertThat(lectureUnit.getCompletedUsers()).isEmpty(); - assertThat(lectureUnit.isCompletedFor(userRepository.getUser())).isFalse(); + assertThat(lectureUnit.isCompletedFor(userTestRepository.getUser())).isFalse(); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitServiceTest.java index 99b6eec6a2b3..2a79f139fc96 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUnitServiceTest.java @@ -9,14 +9,15 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.LectureUnitCompletion; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository; import de.tum.cit.aet.artemis.lecture.service.LectureUnitService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LectureUnitServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java index 62cf2eab7bc2..ac8fab7c6e38 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/OnlineUnitIntegrationTest.java @@ -28,15 +28,16 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.core.dto.OnlineResourceDTO; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.OnlineUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.OnlineUnitRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class OnlineUnitIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java index 5a4e2fe0986b..0c03d3616562 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/TextUnitIntegrationTest.java @@ -15,14 +15,15 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.TextUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.TextUnitRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TextUnitIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java index 02b5ec49164f..51d622d187bc 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/VideoUnitIntegrationTest.java @@ -15,14 +15,15 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.domain.VideoUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; import de.tum.cit.aet.artemis.lecture.repository.VideoUnitRepository; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class VideoUnitIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/LectureImportServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/service/LectureImportServiceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/service/LectureImportServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/lecture/service/LectureImportServiceTest.java index 0c7d316651ba..9b653c6c38cf 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/LectureImportServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/service/LectureImportServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.lecture.service; import static org.assertj.core.api.Assertions.assertThat; @@ -10,17 +10,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.domain.LectureUnit; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -import de.tum.cit.aet.artemis.lecture.service.LectureImportService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LectureImportServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/LectureServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/lecture/service/LectureServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/LectureServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/lecture/service/LectureServiceTest.java index 6e75b3f91c77..d040b3442839 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/LectureServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/service/LectureServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.lecture.service; import static org.assertj.core.api.Assertions.assertThat; @@ -13,20 +13,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.SearchResultPageDTO; import de.tum.cit.aet.artemis.core.dto.pageablesearch.SearchTermPageableSearchDTO; -import de.tum.cit.aet.artemis.lecture.LectureFactory; -import de.tum.cit.aet.artemis.lecture.LectureUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.Lecture; import de.tum.cit.aet.artemis.lecture.repository.LectureRepository; -import de.tum.cit.aet.artemis.lecture.service.LectureService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.lecture.util.LectureFactory; +import de.tum.cit.aet.artemis.lecture.util.LectureUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LectureServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/test_repository/SlideTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/lecture/test_repository/SlideTestRepository.java new file mode 100644 index 000000000000..549b832774fb --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/test_repository/SlideTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.lecture.test_repository; + +import java.util.List; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.lecture.domain.Slide; +import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; + +@Repository +@Primary +public interface SlideTestRepository extends SlideRepository { + + List findAllByAttachmentUnitId(Long attachmentUnitId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureFactory.java b/src/test/java/de/tum/cit/aet/artemis/lecture/util/LectureFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/lecture/LectureFactory.java rename to src/test/java/de/tum/cit/aet/artemis/lecture/util/LectureFactory.java index 4848460a768a..6a44f72a8aec 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/util/LectureFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.lecture; +package de.tum.cit.aet.artemis.lecture.util; import static org.assertj.core.api.Assertions.fail; diff --git a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUtilService.java b/src/test/java/de/tum/cit/aet/artemis/lecture/util/LectureUtilService.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/lecture/LectureUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/lecture/util/LectureUtilService.java index c9fe9f1e6fdd..3646ecaa7214 100644 --- a/src/test/java/de/tum/cit/aet/artemis/lecture/LectureUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/lecture/util/LectureUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.lecture; +package de.tum.cit.aet.artemis.lecture.util; import static org.assertj.core.api.Assertions.fail; @@ -17,13 +17,14 @@ import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; -import de.tum.cit.aet.artemis.communication.repository.conversation.ConversationRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationFactory; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; import de.tum.cit.aet.artemis.core.service.FilePathService; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.lecture.domain.Attachment; import de.tum.cit.aet.artemis.lecture.domain.AttachmentUnit; @@ -42,10 +43,9 @@ import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository; import de.tum.cit.aet.artemis.lecture.repository.LectureUnitRepository; import de.tum.cit.aet.artemis.lecture.repository.OnlineUnitRepository; -import de.tum.cit.aet.artemis.lecture.repository.SlideRepository; import de.tum.cit.aet.artemis.lecture.repository.TextUnitRepository; import de.tum.cit.aet.artemis.lecture.repository.VideoUnitRepository; -import de.tum.cit.aet.artemis.post.ConversationFactory; +import de.tum.cit.aet.artemis.lecture.test_repository.SlideTestRepository; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; @@ -60,7 +60,7 @@ public class LectureUtilService { private static final ZonedDateTime futureFutureTimestamp = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private LectureRepository lectureRepo; @@ -81,7 +81,7 @@ public class LectureUtilService { private AttachmentRepository attachmentRepository; @Autowired - private SlideRepository slideRepository; + private SlideTestRepository slideRepository; @Autowired private TextUnitRepository textUnitRepository; @@ -96,7 +96,7 @@ public class LectureUtilService { private CourseUtilService courseUtilService; @Autowired - private ConversationRepository conversationRepository; + private ConversationTestRepository conversationRepository; @Autowired private LectureUnitCompletionRepository lectureUnitCompletionRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/Lti13LaunchIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/Lti13LaunchIntegrationTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/Lti13LaunchIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/Lti13LaunchIntegrationTest.java index 5e0a64c362de..cf1b7c35814a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/Lti13LaunchIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/Lti13LaunchIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.lti; -import static de.tum.cit.aet.artemis.util.TestUriParamsUtil.assertUriParamsContain; +import static de.tum.cit.aet.artemis.core.util.TestUriParamsUtil.assertUriParamsContain; import static org.assertj.core.api.Assertions.assertThat; import java.net.URI; @@ -21,6 +21,7 @@ import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.security.test.context.support.WithMockUser; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import io.jsonwebtoken.Jwts; /** @@ -51,9 +52,9 @@ class Lti13LaunchIntegrationTest extends AbstractSpringIntegrationIndependentTes @BeforeEach void init() { userUtilService.addUsers(TEST_PREFIX, 1, 1, 0, 1); - var user = userRepository.findUserWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student1").orElseThrow(); + var user = userTestRepository.findUserWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student1").orElseThrow(); user.setInternal(false); - userRepository.save(user); + userTestRepository.save(user); } @Test diff --git a/src/test/java/de/tum/cit/aet/artemis/LtiDeepLinkingIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/LtiDeepLinkingIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/LtiDeepLinkingIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/LtiDeepLinkingIntegrationTest.java index 375dab3f26fa..e1da79c21df6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/LtiDeepLinkingIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/LtiDeepLinkingIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.lti; import static org.mockito.Mockito.any; import static org.mockito.Mockito.when; @@ -29,9 +29,10 @@ import com.nimbusds.jose.jwk.RSAKey; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.lti.config.CustomLti13Configurer; import de.tum.cit.aet.artemis.lti.dto.Claims; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import io.jsonwebtoken.Jwts; class LtiDeepLinkingIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -46,9 +47,9 @@ class LtiDeepLinkingIntegrationTest extends AbstractSpringIntegrationIndependent @BeforeEach void init() { userUtilService.addUsers(TEST_PREFIX, 1, 1, 0, 1); - var user = userRepository.findUserWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student1").orElseThrow(); + var user = userTestRepository.findUserWithGroupsAndAuthoritiesByLogin(TEST_PREFIX + "student1").orElseThrow(); user.setInternal(false); - userRepository.save(user); + userTestRepository.save(user); course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise(); course.setOnlineCourse(true); diff --git a/src/test/java/de/tum/cit/aet/artemis/LtiIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/LtiIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/LtiIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/LtiIntegrationTest.java index b1bc1f8e1003..aa8fa6d64241 100644 --- a/src/test/java/de/tum/cit/aet/artemis/LtiIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/LtiIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.lti; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -32,6 +32,7 @@ import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.lti.domain.LtiPlatformConfiguration; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class LtiIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/LtiQuizIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/LtiQuizIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/LtiQuizIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/LtiQuizIntegrationTest.java index 3991acb2e4dc..022dfa6f946d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/LtiQuizIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/LtiQuizIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.lti; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -30,18 +30,19 @@ import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.quiz.QuizExerciseFactory; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; import de.tum.cit.aet.artemis.quiz.domain.QuizMode; import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; import de.tum.cit.aet.artemis.quiz.service.QuizExerciseService; import de.tum.cit.aet.artemis.quiz.service.QuizSubmissionService; -import de.tum.cit.aet.artemis.util.RequestUtilService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @Isolated class LtiQuizIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -52,10 +53,10 @@ class LtiQuizIntegrationTest extends AbstractSpringIntegrationIndependentTest { private QuizExerciseService quizExerciseService; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseTestRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ParticipationUtilService participationUtilService; @@ -109,7 +110,7 @@ void testLtiServicesAreCalledUponQuizSubmission(boolean isSubmitted) throws Exce verifyNoInteractions(lti13Service); // End the quiz right now - quizExercise = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + quizExercise = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(quizExercise).isNotNull(); quizExercise.setDueDate(ZonedDateTime.now()); exerciseRepository.saveAndFlush(quizExercise); @@ -165,7 +166,7 @@ private QuizExercise createQuizExercise(ZonedDateTime releaseDate) throws Except QuizExercise quizExerciseServer = createQuizExerciseWithFiles(quizExercise); assertThat(quizExerciseServer).isNotNull(); - QuizExercise quizExerciseDatabase = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExerciseServer.getId()); + QuizExercise quizExerciseDatabase = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExerciseServer.getId()); assertThat(quizExerciseServer).isNotNull(); assertThat(quizExerciseDatabase).isNotNull(); diff --git a/src/test/java/de/tum/cit/aet/artemis/OAuth2JWKSIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/OAuth2JWKSIntegrationTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/OAuth2JWKSIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/OAuth2JWKSIntegrationTest.java index a0abcae7f10a..86aaf9fc33f9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/OAuth2JWKSIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/OAuth2JWKSIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.lti; import static org.assertj.core.api.Assertions.assertThat; @@ -11,17 +11,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.OnlineCourseConfigurationRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.lti.domain.LtiPlatformConfiguration; import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; +import de.tum.cit.aet.artemis.lti.test_repository.OnlineCourseConfigurationTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class OAuth2JWKSIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "oauth2jwksintegrationtest"; @Autowired - private OnlineCourseConfigurationRepository onlineCourseConfigurationRepository; + private OnlineCourseConfigurationTestRepository onlineCourseConfigurationRepository; @Test @WithAnonymousUser diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/service/LtiDeepLinkingServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/service/LtiDeepLinkingServiceTest.java index f116e5a80c39..de205dc54fb1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/service/LtiDeepLinkingServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.lti; +package de.tum.cit.aet.artemis.lti.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -38,7 +38,6 @@ import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; import de.tum.cit.aet.artemis.lti.config.Lti13TokenRetriever; import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; -import de.tum.cit.aet.artemis.lti.service.LtiDeepLinkingService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import uk.ac.ox.ctl.lti13.lti.Claims; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/OnlineCourseConfigurationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/lti/service/OnlineCourseConfigurationServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/OnlineCourseConfigurationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/lti/service/OnlineCourseConfigurationServiceTest.java index 3f891a10c280..28217ced4ec3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/OnlineCourseConfigurationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/service/OnlineCourseConfigurationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.lti.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -22,13 +22,12 @@ import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.lti.domain.LtiPlatformConfiguration; import de.tum.cit.aet.artemis.lti.domain.OnlineCourseConfiguration; -import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; -import de.tum.cit.aet.artemis.lti.service.OnlineCourseConfigurationService; +import de.tum.cit.aet.artemis.lti.test_repository.LtiPlatformConfigurationTestRepository; class OnlineCourseConfigurationServiceTest { @Mock - private LtiPlatformConfigurationRepository ltiPlatformConfigurationRepository; + private LtiPlatformConfigurationTestRepository ltiPlatformConfigurationRepository; private OnlineCourseConfigurationService onlineCourseConfigurationService; diff --git a/src/test/java/de/tum/cit/aet/artemis/lti/test_repository/LtiPlatformConfigurationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/lti/test_repository/LtiPlatformConfigurationTestRepository.java new file mode 100644 index 000000000000..819e7c91fd6b --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/lti/test_repository/LtiPlatformConfigurationTestRepository.java @@ -0,0 +1,22 @@ +package de.tum.cit.aet.artemis.lti.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.lti.domain.LtiPlatformConfiguration; +import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; + +@Repository +@Primary +public interface LtiPlatformConfigurationTestRepository extends LtiPlatformConfigurationRepository { + + /** + * Finds an LTI platform configuration by its client ID. + * + * @param clientId The registration ID. + * @return Optional of LtiPlatformConfiguration. + */ + Optional findByClientId(String clientId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/OnlineCourseConfigurationRepository.java b/src/test/java/de/tum/cit/aet/artemis/lti/test_repository/OnlineCourseConfigurationTestRepository.java similarity index 62% rename from src/test/java/de/tum/cit/aet/artemis/core/repository/OnlineCourseConfigurationRepository.java rename to src/test/java/de/tum/cit/aet/artemis/lti/test_repository/OnlineCourseConfigurationTestRepository.java index 397afaf3c799..55e10ef3bd12 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/OnlineCourseConfigurationRepository.java +++ b/src/test/java/de/tum/cit/aet/artemis/lti/test_repository/OnlineCourseConfigurationTestRepository.java @@ -1,5 +1,6 @@ -package de.tum.cit.aet.artemis.core.repository; +package de.tum.cit.aet.artemis.lti.test_repository; +import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Repository; import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; @@ -9,6 +10,7 @@ * Spring Data JPA repository for the OnlineCourseConfiguration entity. */ @Repository -public interface OnlineCourseConfigurationRepository extends ArtemisJpaRepository { +@Primary +public interface OnlineCourseConfigurationTestRepository extends ArtemisJpaRepository { // This interface is intentionally left blank. Spring Data JPA generates the implementation at runtime. } diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ApollonConversionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ApollonConversionIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ApollonConversionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/ApollonConversionIntegrationTest.java index deaa739c8ab7..922438c3a17f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ApollonConversionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ApollonConversionIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling; import static org.assertj.core.api.Assertions.assertThat; @@ -18,10 +18,10 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.RestTemplate; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.connector.apollon.ApollonRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.apollon.ApollonRequestMockProvider; import de.tum.cit.aet.artemis.modeling.dto.ApollonModelDTO; import de.tum.cit.aet.artemis.modeling.service.apollon.ApollonConversionService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ApollonConversionIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ApollonDiagramResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ApollonDiagramResourceIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ApollonDiagramResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/ApollonDiagramResourceIntegrationTest.java index 05c2309b672d..80d25259b60c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ApollonDiagramResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ApollonDiagramResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling; import static org.assertj.core.api.Assertions.assertThat; @@ -13,12 +13,13 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.modeling.domain.ApollonDiagram; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.repository.ApollonDiagramRepository; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ApollonDiagramResourceIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java index 9d3b828824c1..24b48fb8761e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingAssessmentIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.loadFileFromResources; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.loadFileFromResources; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.isA; @@ -26,7 +26,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; @@ -37,41 +36,44 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.dto.AssessmentUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ComplaintResponseRepository; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.service.AssessmentService; +import de.tum.cit.aet.artemis.assessment.test_repository.ComplaintResponseTestRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.dto.ModelingAssessmentDTO; import de.tum.cit.aet.artemis.modeling.repository.ModelClusterRepository; import de.tum.cit.aet.artemis.modeling.repository.ModelElementRepository; -import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; import de.tum.cit.aet.artemis.modeling.service.compass.CompassService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.test_repository.ModelingSubmissionTestRepository; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.plagiarism.PlagiarismUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus; import de.tum.cit.aet.artemis.plagiarism.domain.modeling.ModelingSubmissionElement; import de.tum.cit.aet.artemis.plagiarism.dto.PlagiarismResultDTO; import de.tum.cit.aet.artemis.programming.dto.ResultDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class ModelingAssessmentIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -80,13 +82,13 @@ class ModelingAssessmentIntegrationTest extends AbstractSpringIntegrationLocalCI public static final String API_MODELING_SUBMISSIONS = "/api/modeling-submissions/"; @Autowired - private ModelingSubmissionRepository modelingSubmissionRepo; + private ModelingSubmissionTestRepository modelingSubmissionRepo; @Autowired private ParticipationService participationService; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepository; + private ExampleSubmissionTestRepository exampleSubmissionRepository; @Autowired private CompassService compassService; @@ -98,13 +100,13 @@ class ModelingAssessmentIntegrationTest extends AbstractSpringIntegrationLocalCI private ExamRepository examRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private ComplaintResponseRepository complaintResponseRepository; + private ComplaintResponseTestRepository complaintResponseRepository; @Autowired private ComplaintRepository complaintRepository; @@ -1481,7 +1483,7 @@ void overrideAssessmentAfterComplaint() throws Exception { modelingExercise = exerciseRepository.saveAndFlush(modelingExercise); // creating participation of student1 by starting the exercise - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElse(null); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElse(null); StudentParticipation studentParticipation = participationService.startExercise(modelingExercise, student1, false); // creating submission of student1 @@ -1493,7 +1495,7 @@ void overrideAssessmentAfterComplaint() throws Exception { submission = submissionRepository.saveAndFlush(submission); // creating assessment by tutor1 - User tutor1 = userRepository.findOneByLogin("tutor1").orElse(null); + User tutor1 = userTestRepository.findOneByLogin("tutor1").orElse(null); Result firstResult = ParticipationFactory.generateResult(true, 50); firstResult.setAssessor(tutor1); firstResult.setHasComplaint(true); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingComparisonTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingComparisonTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingComparisonTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/ModelingComparisonTest.java index b23e9402a965..ca6e02283c25 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingComparisonTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingComparisonTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling; import static org.assertj.core.api.Assertions.assertThat; @@ -8,11 +8,12 @@ import org.junit.jupiter.api.Test; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.service.StudentExamService; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; class ModelingComparisonTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java index 874fc5a63650..95087f641584 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingExerciseIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -29,7 +29,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission; import de.tum.cit.aet.artemis.assessment.domain.Feedback; @@ -39,38 +38,41 @@ import de.tum.cit.aet.artemis.assessment.domain.TutorParticipation; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; -import de.tum.cit.aet.artemis.assessment.repository.TutorParticipationRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.TutorParticipationTestRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.dto.CourseForDashboardDTO; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.TeamAssignmentConfig; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseIntegrationTestService; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.modeling.ModelingPlagiarismResult; import de.tum.cit.aet.artemis.plagiarism.dto.PlagiarismResultDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorParticipationStatus; -import de.tum.cit.aet.artemis.util.ExerciseIntegrationTestService; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; class ModelingExerciseIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -86,7 +88,7 @@ class ModelingExerciseIntegrationTest extends AbstractSpringIntegrationLocalCILo private TeamRepository teamRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private FeedbackRepository feedbackRepository; @@ -95,13 +97,13 @@ class ModelingExerciseIntegrationTest extends AbstractSpringIntegrationLocalCILo private GradingCriterionRepository gradingCriterionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ExerciseIntegrationTestService exerciseIntegrationTestService; @Autowired - private TutorParticipationRepository tutorParticipationRepository; + private TutorParticipationTestRepository tutorParticipationRepository; @Autowired private ChannelRepository channelRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingSubmissionIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/ModelingSubmissionIntegrationTest.java index 97c71c1fc784..622e73a06ac0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/ModelingSubmissionIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.within; @@ -20,44 +20,46 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.communication.domain.Post; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExerciseGroupRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.SubmissionVersion; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.SubmissionVersionRepository; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; import de.tum.cit.aet.artemis.modeling.service.compass.CompassService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.test_repository.ModelingSubmissionTestRepository; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismSubmission; import de.tum.cit.aet.artemis.plagiarism.domain.modeling.ModelingSubmissionElement; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismComparisonRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class ModelingSubmissionIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -67,10 +69,10 @@ class ModelingSubmissionIntegrationTest extends AbstractSpringIntegrationLocalCI private TeamRepository teamRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private ModelingSubmissionRepository modelingSubmissionRepo; + private ModelingSubmissionTestRepository modelingSubmissionRepo; @Autowired private SubmissionVersionRepository submissionVersionRepository; @@ -82,7 +84,7 @@ class ModelingSubmissionIntegrationTest extends AbstractSpringIntegrationLocalCI private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private CompassService compassService; @@ -94,7 +96,7 @@ class ModelingSubmissionIntegrationTest extends AbstractSpringIntegrationLocalCI private PlagiarismCaseRepository plagiarismCaseRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private ModelingExerciseUtilService modelingExerciseUtilService; @@ -273,8 +275,8 @@ void saveAndSubmitModelingSubmission_isTeamMode() throws Exception { team.setName("Team"); team.setShortName(TEST_PREFIX + "team"); team.setExercise(useCaseExercise); - team.addStudents(userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); - team.addStudents(userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow()); + team.addStudents(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); + team.addStudents(userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow()); teamRepository.save(useCaseExercise, team); participationUtilService.addTeamParticipationForExercise(useCaseExercise, team.getId()); @@ -463,7 +465,7 @@ void getModelSubmissionWithResult_involved_allowed() throws Exception { plagiarismCase.setExercise(classExercise); plagiarismCase = plagiarismCaseRepository.save(plagiarismCase); Post post = new Post(); - post.setAuthor(userRepository.getUserByLoginElseThrow(TEST_PREFIX + "instructor1")); + post.setAuthor(userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "instructor1")); post.setTitle("Title Plagiarism Case Post"); post.setContent("Content Plagiarism Case Post"); post.setVisibleForStudents(true); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/FeedbackSelectorTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/FeedbackSelectorTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/FeedbackSelectorTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/FeedbackSelectorTest.java index d9c1320ad7d2..34be9acd412e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/FeedbackSelectorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/FeedbackSelectorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.controller; +package de.tum.cit.aet.artemis.modeling.compass.controller; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/ModelClusterFactoryTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/ModelClusterFactoryTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/ModelClusterFactoryTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/ModelClusterFactoryTest.java index 080df31329d8..813365924db9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/ModelClusterFactoryTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/ModelClusterFactoryTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.controller; +package de.tum.cit.aet.artemis.modeling.compass.controller; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.loadFileFromResources; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.loadFileFromResources; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; @@ -8,12 +8,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; import de.tum.cit.aet.artemis.modeling.domain.ModelCluster; import de.tum.cit.aet.artemis.modeling.domain.ModelElement; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.service.compass.controller.ModelClusterFactory; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; class ModelClusterFactoryTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/UMLModelParserTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/UMLModelParserTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/UMLModelParserTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/UMLModelParserTest.java index 8b694ea41daa..988936232abd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/controller/UMLModelParserTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/controller/UMLModelParserTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.controller; +package de.tum.cit.aet.artemis.modeling.compass.controller; import static com.google.gson.JsonParser.parseString; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.activity.UMLActivityNode.UMLActivityNodeType.ACTIVITY_ACTION_NODE; @@ -24,6 +24,7 @@ import com.google.gson.JsonObject; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLElement; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.activity.UMLActivity; @@ -36,7 +37,6 @@ import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLPackage; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLRelationship; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.parsers.UMLModelParser; -import de.tum.cit.aet.artemis.util.TestResourceUtils; class UMLModelParserTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/AbstractUMLDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/AbstractUMLDiagramTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/AbstractUMLDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/AbstractUMLDiagramTest.java index 5569b6c2e102..e11d7e8156fd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/AbstractUMLDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/AbstractUMLDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/UMLDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/UMLDiagramTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/UMLDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/UMLDiagramTest.java index 2802615215c4..f703d7e925b3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/UMLDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/UMLDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityDiagramTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityDiagramTest.java index 9582128f7b62..68db5570ba4a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.activity; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.activity; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -14,7 +14,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLElement; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.activity.UMLActivity; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityDiagrams.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityDiagrams.java index 325dc0e9fb81..806fdf585715 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.activity; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.activity; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityNodeTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityNodeTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityNodeTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityNodeTest.java index b40332b2099e..c33311e65799 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityNodeTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityNodeTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.activity; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.activity; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.activity.UMLActivityNode.UMLActivityNodeType.ACTIVITY_ACTION_NODE; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.activity.UMLActivityNode.UMLActivityNodeType.ACTIVITY_FINAL_NODE; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityTest.java index 2b79d01053df..362774410237 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLActivityTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLActivityTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.activity; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.activity; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLControlFlowTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLControlFlowTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLControlFlowTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLControlFlowTest.java index 7bb6c7755095..1e82e9a14087 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/UMLControlFlowTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/UMLControlFlowTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.activity; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.activity; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/BPMNDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/BPMNDiagramTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/BPMNDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/BPMNDiagramTest.java index e6d4940623de..50d3c1b379e0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/BPMNDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/BPMNDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.bpmn; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.bpmn; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLElement; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.bpmn.BPMNAnnotation; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/BPMNDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/BPMNDiagrams.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/BPMNDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/BPMNDiagrams.java index 984f1e4ed295..76f1b3c2c86a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/BPMNDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/BPMNDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.bpmn; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.bpmn; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLAttributeTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLAttributeTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLAttributeTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLAttributeTest.java index 35bae0ea0485..f34cf38291be 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLAttributeTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLAttributeTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassDiagramTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassDiagramTest.java index c1e39fa57dd3..db38a4307738 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @@ -12,7 +12,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLElement; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLAttribute; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLClass; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassDiagrams.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassDiagrams.java index 35933cc5ecb2..623589048451 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassTest.java index 102af805a7e7..b99622aaacfa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLClassTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLClassTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLClass.UMLClassType.ABSTRACT_CLASS; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLClass.UMLClassType.CLASS; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLMethodTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLMethodTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLMethodTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLMethodTest.java index dbf3ec916b71..d806423e858e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLMethodTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLMethodTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLPackageTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLPackageTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLPackageTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLPackageTest.java index 49494b7ef94f..8c72068d82ed 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLPackageTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLPackageTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLRelationshipTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLRelationshipTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLRelationshipTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLRelationshipTest.java index 80652e2b433e..54fa4f4feade 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/UMLRelationshipTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/UMLRelationshipTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.classdiagram; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.classdiagram; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLRelationship.UMLRelationshipType.CLASS_BIDIRECTIONAL; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.classdiagram.UMLRelationship.UMLRelationshipType.CLASS_UNIDIRECTIONAL; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/UMLCommunicationDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/UMLCommunicationDiagramTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/UMLCommunicationDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/UMLCommunicationDiagramTest.java index 7313285ab401..0422944a61c1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/UMLCommunicationDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/UMLCommunicationDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.communication; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.communication; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.communication.UMLCommunicationDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.communication.UMLCommunicationLink; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/UMLCommunicationDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/UMLCommunicationDiagrams.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/UMLCommunicationDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/UMLCommunicationDiagrams.java index 7a8b02e4fe1e..07f6fdeae18a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/UMLCommunicationDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/UMLCommunicationDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.communication; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.communication; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/UMLComponentDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/UMLComponentDiagramTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/UMLComponentDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/UMLComponentDiagramTest.java index 0bfec3ed049f..0019a2ff88b9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/UMLComponentDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/UMLComponentDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.component; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.component; import static com.google.gson.JsonParser.parseString; import static de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.component.UMLComponentRelationship.UMLComponentRelationshipType.COMPONENT_DEPENDENCY; @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.component.UMLComponent; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.component.UMLComponentDiagram; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/UMLComponentDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/UMLComponentDiagrams.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/UMLComponentDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/UMLComponentDiagrams.java index 036befc3f56b..f4eac4868b02 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/UMLComponentDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/UMLComponentDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.component; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.component; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/UMLDeploymentDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/UMLDeploymentDiagramTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/UMLDeploymentDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/UMLDeploymentDiagramTest.java index 8975807fb094..3c1ef4c565ab 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/UMLDeploymentDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/UMLDeploymentDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.deployment; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.deployment; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.component.UMLComponent; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.deployment.UMLArtifact; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/UMLDeploymentDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/UMLDeploymentDiagrams.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/UMLDeploymentDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/UMLDeploymentDiagrams.java index e992f7679851..bc824bb7866d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/UMLDeploymentDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/UMLDeploymentDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.deployment; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.deployment; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/FlowchartTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/FlowchartTest.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/FlowchartTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/FlowchartTest.java index d54b8a11ca4a..b079ac79b659 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/FlowchartTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/FlowchartTest.java @@ -1,12 +1,12 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart; import static com.google.gson.JsonParser.parseString; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1A; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1A_V3; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1B; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1B_V3; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_2; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_2_V3; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1A; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1A_V3; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1B; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_1B_V3; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_2; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart.FlowchartUtil.FLOWCHART_MODEL_2_V3; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.InstanceOfAssertFactories.type; @@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.flowchart.Flowchart; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.flowchart.FlowchartDecision; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/FlowchartUtil.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/FlowchartUtil.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/FlowchartUtil.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/FlowchartUtil.java index 2b601abe5767..4c090e618f1d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/FlowchartUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/FlowchartUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.flowchart; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.flowchart; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/UMLObjectDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/UMLObjectDiagramTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/UMLObjectDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/UMLObjectDiagramTest.java index 4535e0f36339..01c9050d937d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/UMLObjectDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/UMLObjectDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.object; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.object; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.object.UMLObject; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.object.UMLObjectDiagram; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/UMLObjectDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/UMLObjectDiagrams.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/UMLObjectDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/UMLObjectDiagrams.java index 6d31fd57081d..fbc8e1504097 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/UMLObjectDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/UMLObjectDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.object; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.object; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/PetriNetTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/PetriNetTest.java similarity index 85% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/PetriNetTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/PetriNetTest.java index 0acbfd84937d..0fdef33c4b19 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/PetriNetTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/PetriNetTest.java @@ -1,12 +1,12 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet; import static com.google.gson.JsonParser.parseString; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1A; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1A_V3; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1B; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1B_V3; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_2; -import static de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_2_V3; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1A; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1A_V3; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1B; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_1B_V3; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_2; +import static de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet.PetriNets.PETRI_NET_MODEL_2_V3; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.InstanceOfAssertFactories.type; @@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.parsers.UMLModelParser; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.petrinet.PetriNet; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/PetriNets.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/PetriNets.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/PetriNets.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/PetriNets.java index 45f71016a8a3..84237eb4aa67 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/PetriNets.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/PetriNets.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.petrinet; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.petrinet; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/SyntaxTreeTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/SyntaxTreeTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/SyntaxTreeTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/SyntaxTreeTest.java index 04fb8c29b69c..c695dedc784c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/SyntaxTreeTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/SyntaxTreeTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.syntaxtree; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.syntaxtree; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.parsers.UMLModelParser; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.syntaxtree.SyntaxTree; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/SyntaxTrees.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/SyntaxTrees.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/SyntaxTrees.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/SyntaxTrees.java index 89a8bd5180f8..9ce46423d512 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/SyntaxTrees.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/SyntaxTrees.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.syntaxtree; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.syntaxtree; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/UMLUseCaseDiagramTest.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/UMLUseCaseDiagramTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/UMLUseCaseDiagramTest.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/UMLUseCaseDiagramTest.java index 84a601888b0b..8afb8ee9ea26 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/UMLUseCaseDiagramTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/UMLUseCaseDiagramTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.usecase; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.usecase; import static com.google.gson.JsonParser.parseString; import static org.assertj.core.api.Assertions.assertThat; @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.AbstractUMLDiagramTest; +import de.tum.cit.aet.artemis.modeling.compass.umlmodel.AbstractUMLDiagramTest; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.UMLDiagram; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.parsers.UMLModelParser; import de.tum.cit.aet.artemis.modeling.service.compass.umlmodel.usecase.UMLActor; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/UMLUseCaseDiagrams.java b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/UMLUseCaseDiagrams.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/UMLUseCaseDiagrams.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/UMLUseCaseDiagrams.java index d6bc64258858..9f73b9c6f790 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/UMLUseCaseDiagrams.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/UMLUseCaseDiagrams.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling.compass.umlmodel.usecase; +package de.tum.cit.aet.artemis.modeling.compass.umlmodel.usecase; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/modeling/test_repository/ModelingSubmissionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/modeling/test_repository/ModelingSubmissionTestRepository.java new file mode 100644 index 000000000000..78f553afb23d --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/test_repository/ModelingSubmissionTestRepository.java @@ -0,0 +1,31 @@ +package de.tum.cit.aet.artemis.modeling.test_repository; + +import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; +import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; + +@Repository +@Primary +public interface ModelingSubmissionTestRepository extends ModelingSubmissionRepository { + + @Query(""" + SELECT DISTINCT submission + FROM ModelingSubmission submission + LEFT JOIN FETCH submission.results r + LEFT JOIN FETCH r.assessor + WHERE submission.id = :submissionId + """) + Optional findByIdWithEagerResult(@Param("submissionId") Long submissionId); + + @EntityGraph(type = LOAD, attributePaths = { "results" }) + Optional findWithEagerResultById(Long submissionId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseFactory.java b/src/test/java/de/tum/cit/aet/artemis/modeling/util/ModelingExerciseFactory.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/util/ModelingExerciseFactory.java index 943824bb5a95..a8f20973380e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/util/ModelingExerciseFactory.java @@ -1,13 +1,13 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling.util; import java.time.ZonedDateTime; import java.util.HashSet; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.ExerciseFactory; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.util.ExerciseFactory; import de.tum.cit.aet.artemis.modeling.domain.ApollonDiagram; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/modeling/util/ModelingExerciseUtilService.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/modeling/util/ModelingExerciseUtilService.java index e4e998a93daa..8b8c4c18be85 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/modeling/ModelingExerciseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/modeling/util/ModelingExerciseUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.modeling; +package de.tum.cit.aet.artemis.modeling.util; import static org.assertj.core.api.Assertions.assertThat; @@ -21,31 +21,31 @@ import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.AssessmentService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; import de.tum.cit.aet.artemis.modeling.repository.ModelingExerciseRepository; -import de.tum.cit.aet.artemis.modeling.repository.ModelingSubmissionRepository; import de.tum.cit.aet.artemis.modeling.service.ModelingSubmissionService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.test_repository.ModelingSubmissionTestRepository; import de.tum.cit.aet.artemis.plagiarism.domain.modeling.ModelingPlagiarismResult; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismResultRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; /** * Service responsible for initializing the database with specific testdata related to modeling exercises for use in integration tests. @@ -60,7 +60,7 @@ public class ModelingExerciseUtilService { private static final ZonedDateTime futureFutureTimestamp = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private ExerciseRepository exerciseRepo; @@ -69,13 +69,13 @@ public class ModelingExerciseUtilService { private ModelingExerciseRepository modelingExerciseRepository; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired - private ModelingSubmissionRepository modelingSubmissionRepo; + private ModelingSubmissionTestRepository modelingSubmissionRepo; @Autowired private FeedbackRepository feedbackRepo; diff --git a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java index bd3472b2e25e..0f77e7d0c133 100644 --- a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismAnswerPostIntegrationTest.java @@ -15,14 +15,14 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.AnswerPost; import de.tum.cit.aet.artemis.communication.domain.Post; import de.tum.cit.aet.artemis.communication.repository.AnswerPostRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class PlagiarismAnswerPostIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -32,7 +32,7 @@ class PlagiarismAnswerPostIntegrationTest extends AbstractSpringIntegrationIndep private AnswerPostRepository answerPostRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private ConversationUtilService conversationUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCaseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCaseIntegrationTest.java index 8d7d7a640104..8b9e7fba08f8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCaseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCaseIntegrationTest.java @@ -15,15 +15,13 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.communication.domain.Post; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.Team; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismResult; @@ -34,7 +32,9 @@ import de.tum.cit.aet.artemis.plagiarism.dto.PlagiarismVerdictDTO; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismComparisonRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class PlagiarismCaseIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -44,7 +44,7 @@ class PlagiarismCaseIntegrationTest extends AbstractSpringIntegrationIndependent private PlagiarismCaseRepository plagiarismCaseRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private PlagiarismComparisonRepository plagiarismComparisonRepository; @@ -276,7 +276,7 @@ void testGetPlagiarismCaseInfoWithoutVerdictForExerciseForStudent() throws Excep private void addPost() { Post post = new Post(); - post.setAuthor(userRepository.getUserByLoginElseThrow(TEST_PREFIX + "instructor1")); + post.setAuthor(userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "instructor1")); post.setTitle("Title Plagiarism Case Post"); post.setContent("Content Plagiarism Case Post"); post.setVisibleForStudents(true); diff --git a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCheckIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCheckIntegrationTest.java index 0246d2ebf6d0..ad495be0fb88 100644 --- a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCheckIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismCheckIntegrationTest.java @@ -11,9 +11,9 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.plagiarism.dto.PlagiarismResultDTO; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class PlagiarismCheckIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismIntegrationTest.java index 63bb14a38027..03195b16e021 100644 --- a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismIntegrationTest.java @@ -13,13 +13,11 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismSubmission; @@ -29,8 +27,10 @@ import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismComparisonRepository; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismResultRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class PlagiarismIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismPostIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismPostIntegrationTest.java index b128d1d31835..15b7326e9094 100644 --- a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismPostIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismPostIntegrationTest.java @@ -24,7 +24,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.communication.domain.DisplayPriority; import de.tum.cit.aet.artemis.communication.domain.Post; import de.tum.cit.aet.artemis.communication.domain.UserRole; @@ -32,21 +31,22 @@ import de.tum.cit.aet.artemis.communication.dto.PostContextFilterDTO; import de.tum.cit.aet.artemis.communication.dto.PostDTO; import de.tum.cit.aet.artemis.communication.repository.ConversationMessageRepository; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationService; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.CourseInformationSharingConfiguration; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class PlagiarismPostIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { private static final String TEST_PREFIX = "postintegration"; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private ConversationMessageRepository conversationMessageRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/web/rest/plagiarism/PlagiarismResultResponseBuilderTest.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismResultResponseBuilderTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/web/rest/plagiarism/PlagiarismResultResponseBuilderTest.java rename to src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismResultResponseBuilderTest.java index a223703c32b2..b15181c3d76a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/web/rest/plagiarism/PlagiarismResultResponseBuilderTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismResultResponseBuilderTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.web.rest.plagiarism; +package de.tum.cit.aet.artemis.plagiarism; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismUtilService.java b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismUtilService.java index d52d0d30be54..67208a1bfabe 100644 --- a/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/plagiarism/PlagiarismUtilService.java @@ -12,24 +12,24 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.exercise.team.TeamUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.modeling.domain.DiagramType; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; -import de.tum.cit.aet.artemis.team.TeamUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseFactory; import de.tum.cit.aet.artemis.text.domain.TextExercise; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; /** * Service responsible for initializing the database with specific testdata related to plagiarisms for use in integration tests. @@ -44,16 +44,16 @@ public class PlagiarismUtilService { private static final ZonedDateTime FUTURE_FUTURE_TIMESTAMP = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private ExerciseRepository exerciseRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/AuxiliaryRepositoryServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/AuxiliaryRepositoryServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/AuxiliaryRepositoryServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/AuxiliaryRepositoryServiceTest.java index 4ef78e883309..6bb1268ff527 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/AuxiliaryRepositoryServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/AuxiliaryRepositoryServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -10,14 +10,15 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.repository.AuxiliaryRepositoryRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.AuxiliaryRepositoryService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class AuxiliaryRepositoryServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -38,7 +39,7 @@ class AuxiliaryRepositoryServiceTest extends AbstractSpringIntegrationIndependen private ProgrammingExerciseUtilService programmingExerciseUtilService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; private static ProgrammingExercise programmingExerciseBeforeUpdate; diff --git a/src/test/java/de/tum/cit/aet/artemis/BuildPlanIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/BuildPlanIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/BuildPlanIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/BuildPlanIntegrationTest.java index 880d34fb3c51..adab0997cd23 100644 --- a/src/test/java/de/tum/cit/aet/artemis/BuildPlanIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/BuildPlanIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; @@ -9,7 +9,6 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; @@ -17,14 +16,16 @@ import de.tum.cit.aet.artemis.programming.domain.build.BuildPlan; import de.tum.cit.aet.artemis.programming.repository.BuildPlanRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class BuildPlanIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "buildplanintegration"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ConsistencyCheckGitlabJenkinsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ConsistencyCheckGitlabJenkinsIntegrationTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ConsistencyCheckGitlabJenkinsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ConsistencyCheckGitlabJenkinsIntegrationTest.java index 069ef1b9531c..38b1447bc645 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ConsistencyCheckGitlabJenkinsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ConsistencyCheckGitlabJenkinsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.service.ConsistencyCheckTestService; +import de.tum.cit.aet.artemis.programming.service.ConsistencyCheckTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ConsistencyCheckGitlabJenkinsIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ContinuousIntegrationTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/ContinuousIntegrationTestService.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ContinuousIntegrationTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ContinuousIntegrationTestService.java index 72a43c35849d..7268656989bf 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ContinuousIntegrationTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ContinuousIntegrationTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -18,14 +18,16 @@ import org.springframework.stereotype.Service; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.service.GitService; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.GitUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.MockDelegate; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; @Service public class ContinuousIntegrationTestService { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/CourseGitlabJenkinsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/CourseGitlabJenkinsIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/CourseGitlabJenkinsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/CourseGitlabJenkinsIntegrationTest.java index bbd5a09f9d22..50e46b7e57db 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/CourseGitlabJenkinsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/CourseGitlabJenkinsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verifyNoInteractions; @@ -20,12 +20,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.course.CourseTestService; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseTestService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class CourseGitlabJenkinsIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -35,7 +36,7 @@ class CourseGitlabJenkinsIntegrationTest extends AbstractSpringIntegrationJenkin private CourseTestService courseTestService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ObjectMapper objectMapper; @@ -224,15 +225,15 @@ void testSetPermissionsForNewGroupMembersInCourse() throws Exception { // Create editor in the course User user = userUtilService.createAndSaveUser("new-editor"); user.setGroups(Set.of("new-editor-group")); - userRepository.save(user); + userTestRepository.save(user); user = userUtilService.createAndSaveUser("new-ta"); user.setGroups(Set.of("new-ta-group")); - userRepository.save(user); + userTestRepository.save(user); user = userUtilService.createAndSaveUser("new-instructor"); user.setGroups(Set.of("new-instructor-group")); - userRepository.save(user); + userTestRepository.save(user); gitlabRequestMockProvider.mockUpdateCoursePermissions(course, oldInstructorGroup, oldEditorGroup, oldTaGroup); jenkinsRequestMockProvider.mockUpdateCoursePermissions(course, oldInstructorGroup, course.getEditorGroupName(), course.getTeachingAssistantGroupName(), false, false); @@ -253,7 +254,7 @@ void testSetPermissionsForNewGroupMembersInCourseFails() throws Exception { // Create editor in the course User user = userUtilService.createAndSaveUser("new-editor"); user.setGroups(Set.of("new-instructor-group")); - user = userRepository.save(user); + user = userTestRepository.save(user); gitlabRequestMockProvider.mockGetUserId(user.getLogin(), true, true); request.performMvcRequest(courseTestService.buildUpdateCourse(course.getId(), course)).andExpect(status().isInternalServerError()).andReturn(); @@ -268,7 +269,7 @@ void testSetPermissionsForNewGroupMembersInCourseMemberDoesntExist() throws Exce // Create editor in the course User user = userUtilService.createAndSaveUser("new-editor"); user.setGroups(Set.of("new-instructor-group")); - user = userRepository.save(user); + user = userTestRepository.save(user); gitlabRequestMockProvider.mockFailOnGetUserById(user.getLogin()); request.performMvcRequest(courseTestService.buildUpdateCourse(course.getId(), course)).andExpect(status().isInternalServerError()).andReturn(); @@ -286,7 +287,7 @@ void testFailToUpdateOldMembersInCourse() throws Exception { var exercise = courseExercise.stream().findFirst(); assertThat(exercise).isPresent(); - var user = userRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalseAndGroupsContains(course.getTeachingAssistantGroupName()).stream().findFirst(); + var user = userTestRepository.findAllWithGroupsAndAuthoritiesByIsDeletedIsFalseAndGroupsContains(course.getTeachingAssistantGroupName()).stream().findFirst(); assertThat(user).isPresent(); gitlabRequestMockProvider.mockFailToUpdateOldGroupMembers(exercise.get(), user.get()); @@ -300,13 +301,13 @@ void testFailToUpdateOldMembersInCourse() throws Exception { * @param groups the groups to change */ private void changeUserGroup(String userLogin, Set groups) { - Optional user = userRepository.findOneWithGroupsByLogin(userLogin); + Optional user = userTestRepository.findOneWithGroupsByLogin(userLogin); assertThat(user).isPresent(); User updatedUser = user.get(); updatedUser.setGroups(groups); - userRepository.save(updatedUser); + userTestRepository.save(updatedUser); } @Test @@ -315,7 +316,7 @@ void testUpdateCourseGroupsFailsToGetUser() throws Exception { Course course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise(); course.setInstructorGroupName("new-instructor-group"); - Optional user = userRepository.findOneWithGroupsByLogin(TEST_PREFIX + "instructor1"); + Optional user = userTestRepository.findOneWithGroupsByLogin(TEST_PREFIX + "instructor1"); assertThat(user).isPresent(); gitlabRequestMockProvider.mockFailToGetUserWhenUpdatingOldMembers(user.get()); @@ -328,7 +329,7 @@ void testUpdateCourseGroupsFailsToRemoveOldMember() throws Exception { Course course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise(); course.setInstructorGroupName("new-instructor-group"); - Optional user = userRepository.findOneWithGroupsByLogin(TEST_PREFIX + "instructor1"); + Optional user = userTestRepository.findOneWithGroupsByLogin(TEST_PREFIX + "instructor1"); assertThat(user).isPresent(); var exercise = programmingExerciseRepository.findAllProgrammingExercisesInCourseOrInExamsOfCourse(course).stream().findFirst(); @@ -570,7 +571,7 @@ void testRemoveTutorFromCourse_removeUserFromGitlabGroupFails() throws Exception course = courseRepository.save(course); programmingExerciseUtilService.addProgrammingExerciseToCourse(course); - Optional optionalTutor = userRepository.findOneWithGroupsByLogin(TEST_PREFIX + "tutor1"); + Optional optionalTutor = userTestRepository.findOneWithGroupsByLogin(TEST_PREFIX + "tutor1"); assertThat(optionalTutor).isPresent(); String tutorGroup = course.getTeachingAssistantGroupName(); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/GitServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/GitServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/GitServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/GitServiceTest.java index 3355258f7bc0..f03dc054e698 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/GitServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/GitServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; @@ -33,13 +33,13 @@ import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.exception.GitException; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.programming.domain.File; import de.tum.cit.aet.artemis.programming.domain.FileType; import de.tum.cit.aet.artemis.programming.domain.Repository; -import de.tum.cit.aet.artemis.user.UserFactory; -import de.tum.cit.aet.artemis.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class GitServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/GitlabServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/GitlabServiceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/GitlabServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/GitlabServiceTest.java index 6a33d077e1d3..8e857fed08c2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/GitlabServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/GitlabServiceTest.java @@ -1,8 +1,8 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST_WITHOUT_COMMIT; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST_WRONG_COMMIT_ORDER; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST_WITHOUT_COMMIT; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST_WRONG_COMMIT_ORDER; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; @@ -28,19 +28,20 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.exception.VersionControlException; import de.tum.cit.aet.artemis.programming.domain.Commit; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class GitlabServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/settings/ide/IdePreferencesIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/IdePreferencesIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/settings/ide/IdePreferencesIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/IdePreferencesIntegrationTest.java index 7a0ba5b22b2f..888424193c1e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/settings/ide/IdePreferencesIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/IdePreferencesIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.settings.ide; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; @@ -13,7 +13,6 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.ide.Ide; @@ -22,6 +21,7 @@ import de.tum.cit.aet.artemis.programming.dto.IdeMappingDTO; import de.tum.cit.aet.artemis.programming.repository.settings.IdeRepository; import de.tum.cit.aet.artemis.programming.repository.settings.UserIdeMappingRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class IdePreferencesIntegrationTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/PlantUmlIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/PlantUmlIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/PlantUmlIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/PlantUmlIntegrationTest.java index cdc15b3b5946..304ab40f1351 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/PlantUmlIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/PlantUmlIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -17,7 +17,7 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import net.sourceforge.plantuml.SourceStringReader; import net.sourceforge.plantuml.core.DiagramDescription; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingAssessmentIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingAssessmentIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java index c0f819a98055..b39e0c0bc704 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingAssessmentIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doNothing; @@ -25,8 +25,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentNote; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; @@ -37,31 +35,35 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.dto.AssessmentUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.dto.ResultDTO; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingAssessmentIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -72,7 +74,7 @@ class ProgrammingAssessmentIntegrationTest extends AbstractSpringIntegrationInde private final Double offsetByTenThousandth = 0.0001; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @@ -87,10 +89,10 @@ class ProgrammingAssessmentIntegrationTest extends AbstractSpringIntegrationInde private ExamRepository examRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; @@ -693,7 +695,7 @@ void testSaveAssessmentNote() throws Exception { assessmentNote.setNote("note"); manualResult.setAssessmentNote(assessmentNote); - User user = userRepository.getUser(); + User user = userTestRepository.getUser(); manualResult.setAssessor(user); manualResult = request.putWithResponseBody("/api/participations/" + manualResult.getParticipation().getId() + "/manual-results", manualResult, Result.class, HttpStatus.OK); @@ -927,7 +929,7 @@ void multipleCorrectionRoundsForExam() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void overrideProgrammingAssessmentAfterComplaint() throws Exception { - User student1 = userRepository.findOneByLogin(TEST_PREFIX + "student1").orElse(null); + User student1 = userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElse(null); // Starting participation StudentParticipation participation = ParticipationFactory.generateProgrammingExerciseStudentParticipation(InitializationState.INITIALIZED, programmingExercise, student1); @@ -942,7 +944,7 @@ void overrideProgrammingAssessmentAfterComplaint() throws Exception { programmingSubmission = submissionRepository.save(programmingSubmission); // assess this submission - User tutor1 = userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElse(null); + User tutor1 = userTestRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElse(null); Result initialResult = ParticipationFactory.generateResult(true, 50); initialResult.setAssessor(tutor1); initialResult.setHasComplaint(true); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseBuildPlanTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseBuildPlanTest.java similarity index 85% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseBuildPlanTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseBuildPlanTest.java index e53e795aaa2d..e91fb769e4fa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseBuildPlanTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseBuildPlanTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; @@ -8,10 +8,11 @@ import org.springframework.http.HttpStatus; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationGitlabCIGitlabSamlTest; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationGitlabCIGitlabSamlTest; class ProgrammingExerciseBuildPlanTest extends AbstractSpringIntegrationGitlabCIGitlabSamlTest { @@ -32,7 +33,7 @@ class ProgrammingExerciseBuildPlanTest extends AbstractSpringIntegrationGitlabCI """; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; private Long programmingExerciseId; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGitIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGitIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java index 2a04be6da5f8..0fb13f48c51a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGitIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -26,15 +26,16 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.GitService; -import de.tum.cit.aet.artemis.util.GitUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseGitIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -46,7 +47,7 @@ class ProgrammingExerciseGitIntegrationTest extends AbstractSpringIntegrationInd private GitUtilService gitUtilService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGitlabJenkinsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitlabJenkinsIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGitlabJenkinsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitlabJenkinsIntegrationTest.java index 0ac16c56bd21..8918d1190bef 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGitlabJenkinsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGitlabJenkinsIntegrationTest.java @@ -1,7 +1,5 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseTestService.STUDENT_LOGIN; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.C; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.EMPTY; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.HASKELL; @@ -9,6 +7,8 @@ import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.KOTLIN; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.PYTHON; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.SWIFT; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService.STUDENT_LOGIN; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; @@ -38,14 +38,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.programming.domain.AeolusTarget; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.service.ProgrammingLanguageFeatureService; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingExerciseGitlabJenkinsIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -91,7 +92,7 @@ void createProgrammingExercise_validExercise_created(ExerciseMode mode) throws E } @ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}") - @MethodSource("de.tum.cit.aet.artemis.exercise.programming.ArgumentSources#generateJenkinsSupportedLanguages") + @MethodSource("de.tum.cit.aet.artemis.programming.util.ArgumentSources#generateJenkinsSupportedLanguages") @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void createProgrammingExercise_programmingLanguage_validExercise_created(ProgrammingLanguage language) throws Exception { forceDefaultBuildPlanCreation(); @@ -100,14 +101,14 @@ void createProgrammingExercise_programmingLanguage_validExercise_created(Program } @ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}") - @MethodSource("de.tum.cit.aet.artemis.exercise.programming.ArgumentSources#generateJenkinsSupportedLanguages") + @MethodSource("de.tum.cit.aet.artemis.programming.util.ArgumentSources#generateJenkinsSupportedLanguages") @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void createProgrammingExercise_custom_build_plan_validExercise_created(ProgrammingLanguage language) throws Exception { programmingExerciseTestService.createProgrammingExercise_custom_build_plan_validExercise_created(language, true); } @ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}") - @MethodSource("de.tum.cit.aet.artemis.exercise.programming.ArgumentSources#generateJenkinsSupportedLanguages") + @MethodSource("de.tum.cit.aet.artemis.programming.util.ArgumentSources#generateJenkinsSupportedLanguages") @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void createProgrammingExercise_failed_custom_build_plan_validExercise_created(ProgrammingLanguage language) throws Exception { programmingExerciseTestService.createProgrammingExercise_custom_build_plan_validExercise_created(language, false); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGradingServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGradingServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGradingServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGradingServiceTest.java index 9a4704c80b2d..3b7b0bad36c8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseGradingServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseGradingServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static de.tum.cit.aet.artemis.core.config.Constants.TEST_CASES_DUPLICATE_NOTIFICATION; import static org.assertj.core.api.Assertions.assertThat; @@ -29,28 +29,27 @@ import org.springframework.security.test.context.TestSecurityContextHolder; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.CategoryState; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.core.util.RoundingUtil; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; @@ -59,11 +58,13 @@ import de.tum.cit.aet.artemis.programming.domain.SolutionProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.dto.ProgrammingExerciseGradingStatisticsDTO; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.StaticCodeAnalysisCategoryRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseGradingService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * Tests the {@link ProgrammingExerciseGradingService}. @@ -81,16 +82,13 @@ abstract class ProgrammingExerciseGradingServiceTest extends AbstractSpringInteg private static final String TEST_PREFIX = "progexgradingservice"; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ExerciseRepository exerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; - - @Autowired - private ResultRepository resultRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private StaticCodeAnalysisCategoryRepository staticCodeAnalysisCategoryRepository; @@ -99,7 +97,7 @@ abstract class ProgrammingExerciseGradingServiceTest extends AbstractSpringInteg private ExamRepository examRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java index 6e49b375283c..6906106f8fac 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationJenkinsGitlabTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.SOLUTION; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.TEMPLATE; @@ -20,9 +20,10 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseService; +import de.tum.cit.aet.artemis.programming.util.ArgumentSources; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingExerciseIntegrationJenkinsGitlabTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseIntegrationTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseIntegrationTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java index 7374b74962f4..7bfbb4253069 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseIntegrationTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseIntegrationTestService.java @@ -1,12 +1,12 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.SOLUTION; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.TEMPLATE; import static de.tum.cit.aet.artemis.programming.web.ProgrammingExerciseResourceErrorKeys.INVALID_SOLUTION_BUILD_PLAN_ID; import static de.tum.cit.aet.artemis.programming.web.ProgrammingExerciseResourceErrorKeys.INVALID_SOLUTION_REPOSITORY_URL; import static de.tum.cit.aet.artemis.programming.web.ProgrammingExerciseResourceErrorKeys.INVALID_TEMPLATE_BUILD_PLAN_ID; import static de.tum.cit.aet.artemis.programming.web.ProgrammingExerciseResourceErrorKeys.INVALID_TEMPLATE_REPOSITORY_URL; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.any; @@ -68,25 +68,27 @@ import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; import de.tum.cit.aet.artemis.communication.domain.notification.Notification; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; import de.tum.cit.aet.artemis.core.dto.RepositoryExportOptionsDTO; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.ProgrammingExerciseTestRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.service.FileService; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; +import de.tum.cit.aet.artemis.fileupload.util.ZipFileTestUtilService; import de.tum.cit.aet.artemis.plagiarism.PlagiarismUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus; @@ -106,20 +108,20 @@ import de.tum.cit.aet.artemis.programming.dto.ProgrammingExerciseTestCaseDTO; import de.tum.cit.aet.artemis.programming.dto.ProgrammingExerciseTestCaseStateDTO; import de.tum.cit.aet.artemis.programming.repository.AuxiliaryRepositoryRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.service.GitService; import de.tum.cit.aet.artemis.programming.service.UriService; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlRepositoryPermission; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.GitUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; -import de.tum.cit.aet.artemis.util.RequestUtilService; -import de.tum.cit.aet.artemis.util.TestResourceUtils; -import de.tum.cit.aet.artemis.util.ZipFileTestUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.MockDelegate; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; /** * Note: this class should be independent of the actual VCS and CIS and contains common test logic for scenarios: @@ -147,16 +149,16 @@ class ProgrammingExerciseIntegrationTestService { private GitUtilService gitUtilService; @Autowired - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private AuxiliaryRepositoryRepository auxiliaryRepositoryRepository; @@ -169,7 +171,7 @@ class ProgrammingExerciseIntegrationTestService { private GitService gitService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java index 6be28e320fb2..16c1077efd2f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseLocalVCLocalCIIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static de.tum.cit.aet.artemis.core.config.Constants.LOCALCI_RESULTS_DIRECTORY; import static de.tum.cit.aet.artemis.core.config.Constants.LOCALCI_WORKING_DIRECTORY; @@ -30,12 +30,11 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; -import de.tum.cit.aet.artemis.connector.AeolusRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.AeolusRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.AeolusTarget; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; @@ -44,7 +43,10 @@ import de.tum.cit.aet.artemis.programming.domain.TemplateProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.dto.CheckoutDirectoriesDTO; import de.tum.cit.aet.artemis.programming.service.localvc.LocalVCRepositoryUri; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class ProgrammingExerciseLocalVCLocalCIIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseParticipationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseParticipationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java index 3f4d1d3a8eda..fb6d19002d15 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseParticipationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseParticipationIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -25,24 +25,25 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.SolutionProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.TemplateProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.dto.CommitInfoDTO; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseParticipationIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -53,16 +54,16 @@ class ProgrammingExerciseParticipationIntegrationTest extends AbstractSpringInte private final String exercisesBaseUrl = "/api/programming-exercises/"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseRepositoryServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseRepositoryServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseRepositoryServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseRepositoryServiceTest.java index a9110bcdac88..c045fe08c76b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseRepositoryServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseRepositoryServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.never; @@ -12,21 +12,22 @@ import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseRepositoryService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseRepositoryServiceTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "progexreposervice"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseRepositoryService programmingExerciseRepositoryService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseResultJenkinsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseResultJenkinsIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseResultJenkinsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseResultJenkinsIntegrationTest.java index 95d5355726cd..7308c6a6dae5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseResultJenkinsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseResultJenkinsIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory.DEFAULT_BRANCH; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory.DEFAULT_BRANCH; import static org.mockito.Mockito.doReturn; import java.time.ZonedDateTime; @@ -19,12 +19,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.config.Constants; +import de.tum.cit.aet.artemis.core.util.TestConstants; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.CommitDTO; -import de.tum.cit.aet.artemis.util.TestConstants; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseResultTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingExerciseResultJenkinsIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseScheduleServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseScheduleServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseScheduleServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseScheduleServiceTest.java index 291164a34daa..3fd82c87864c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseScheduleServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseScheduleServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.after; @@ -28,31 +28,32 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationGitlabCIGitlabSamlTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.messaging.InstanceMessageReceiveService; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.ExerciseLifecycle; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ParticipationLifecycle; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationGitlabCIGitlabSamlTest; class ProgrammingExerciseScheduleServiceTest extends AbstractSpringIntegrationGitlabCIGitlabSamlTest { @@ -62,19 +63,19 @@ class ProgrammingExerciseScheduleServiceTest extends AbstractSpringIntegrationGi private InstanceMessageReceiveService instanceMessageReceiveService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository participationRepository; + private ProgrammingExerciseStudentParticipationTestRepository participationRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseServiceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseServiceIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseServiceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseServiceIntegrationTest.java index c2a287a67011..a415b8303670 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseServiceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseServiceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; @@ -16,8 +16,9 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseIntegrationTestService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.StaticCodeAnalysisCategory; @@ -26,11 +27,12 @@ import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.LockRepositoryPolicy; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.SubmissionPenaltyPolicy; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.SubmissionPolicy; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseImportBasicService; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseService; -import de.tum.cit.aet.artemis.util.ExerciseIntegrationTestService; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class ProgrammingExerciseServiceIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -45,7 +47,7 @@ class ProgrammingExerciseServiceIntegrationTest extends AbstractSpringIntegratio ProgrammingExerciseImportBasicService programmingExerciseImportBasicService; @Autowired - ProgrammingExerciseRepository programmingExerciseRepository; + ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ExerciseIntegrationTestService exerciseIntegrationTestService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseServiceTest.java similarity index 83% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseServiceTest.java index 8c2240261dbe..028ac2405428 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; @@ -10,19 +10,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.core.repository.ProgrammingExerciseTestRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseServiceTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "progexservice"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTemplateIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTemplateIntegrationTest.java index bb3a3dfd158f..618437fd78b9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTemplateIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.util.TestConstants.COMMIT_HASH_OBJECT_ID; +import static de.tum.cit.aet.artemis.core.util.TestConstants.COMMIT_HASH_OBJECT_ID; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Fail.fail; import static org.mockito.ArgumentMatchers.any; @@ -51,13 +51,15 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.ProjectType; import de.tum.cit.aet.artemis.programming.service.ProgrammingLanguageFeatureService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class ProgrammingExerciseTemplateIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTest.java index 3909abe016c8..587478746a89 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.util.RequestUtilService.deleteProgrammingExerciseParamsFalse; +import static de.tum.cit.aet.artemis.core.util.RequestUtilService.deleteProgrammingExerciseParamsFalse; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.never; @@ -23,40 +23,41 @@ import org.springframework.http.MediaType; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.StudentExam; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingExerciseTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "peinttest"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository participationRepository; + private ProgrammingExerciseStudentParticipationTestRepository participationRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTestCaseServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTestCaseServiceTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTestCaseServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTestCaseServiceTest.java index 244920a008ec..6295e3ea8944 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTestCaseServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingExerciseTestCaseServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -21,28 +21,30 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.security.SecurityUtils; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.dto.ProgrammingExerciseTestCaseDTO; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseFeedbackCreationService; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseTestCaseService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class ProgrammingExerciseTestCaseServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { private static final String TEST_PREFIX = "progextestcase"; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ProgrammingExerciseTestCaseService testCaseService; @@ -51,7 +53,7 @@ class ProgrammingExerciseTestCaseServiceTest extends AbstractSpringIntegrationLo private ProgrammingExerciseFeedbackCreationService feedbackCreationService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest.java index e7ca2712bf24..354a3e9b65c5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.JAVA; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingSubmissionConstants.GITLAB_PUSH_EVENT_REQUEST; import static org.assertj.core.api.Assertions.assertThat; import java.time.ZonedDateTime; @@ -26,12 +26,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; @@ -39,11 +37,16 @@ import de.tum.cit.aet.artemis.programming.domain.build.BuildLogEntry; import de.tum.cit.aet.artemis.programming.repository.BuildLogStatisticsEntryRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.CommitDTO; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestCaseDTO; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestCaseDetailMessageDTO; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestResultsDTO; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingSubmissionAndResultIntegrationTestService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -56,7 +59,7 @@ class ProgrammingSubmissionAndResultGitlabJenkinsIntegrationTest extends Abstrac private ProgrammingSubmissionTestRepository submissionRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingSubmissionIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingSubmissionIntegrationTest.java index a63df7801cdd..3584538982e9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/ProgrammingSubmissionIntegrationTest.java @@ -1,9 +1,9 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static de.tum.cit.aet.artemis.core.config.Constants.NEW_SUBMISSION_TOPIC; import static de.tum.cit.aet.artemis.core.config.Constants.SETUP_COMMIT_MESSAGE; -import static de.tum.cit.aet.artemis.util.TestConstants.COMMIT_HASH_OBJECT_ID; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestConstants.COMMIT_HASH_OBJECT_ID; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.any; @@ -34,7 +34,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; @@ -44,26 +43,28 @@ import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.ContinuousIntegrationException; import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.core.util.TestConstants; +import de.tum.cit.aet.artemis.core.util.TestResourceUtils; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.SubmissionDTO; -import de.tum.cit.aet.artemis.exercise.modeling.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.modeling.domain.ModelingExercise; import de.tum.cit.aet.artemis.modeling.domain.ModelingSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.modeling.util.ModelingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.Commit; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.util.TestConstants; -import de.tum.cit.aet.artemis.util.TestResourceUtils; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class ProgrammingSubmissionIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -76,16 +77,16 @@ class ProgrammingSubmissionIntegrationTest extends AbstractSpringIntegrationJenk private String artemisGitEmail; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingSubmissionTestRepository submissionRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/RepositoryIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/RepositoryIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java index 003e917a1db5..cc602c83f30d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/RepositoryIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; -import static de.tum.cit.aet.artemis.util.RequestUtilService.parameters; +import static de.tum.cit.aet.artemis.core.util.RequestUtilService.parameters; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; import static org.mockito.Mockito.any; @@ -52,21 +52,20 @@ import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.read.ListAppender; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.communication.domain.Post; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.TestConstants; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus; @@ -82,16 +81,18 @@ import de.tum.cit.aet.artemis.programming.domain.build.BuildLogEntry; import de.tum.cit.aet.artemis.programming.dto.FileMove; import de.tum.cit.aet.artemis.programming.dto.RepositoryStatusDTO; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; import de.tum.cit.aet.artemis.programming.service.BuildLogEntryService; import de.tum.cit.aet.artemis.programming.service.GitService; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseParticipationService; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlRepositoryPermission; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.web.repository.FileSubmission; -import de.tum.cit.aet.artemis.util.GitUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; -import de.tum.cit.aet.artemis.util.TestConstants; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class RepositoryIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -102,16 +103,16 @@ class RepositoryIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTe private final String filesContentBaseUrl = "/api/repository-files-content/"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ExamRepository examRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private PlagiarismComparisonRepository plagiarismComparisonRepository; @@ -120,13 +121,13 @@ class RepositoryIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTe private PlagiarismCaseRepository plagiarismCaseRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private BuildLogEntryService buildLogEntryService; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest.java index d41c20c1d1a9..0616cda099c4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -20,21 +20,22 @@ import com.offbytwo.jenkins.model.Build; import com.offbytwo.jenkins.model.JobWithDetails; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; +import de.tum.cit.aet.artemis.core.util.TestConstants; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.build.BuildLogEntry; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.util.TestConstants; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class RepositoryProgrammingExerciseParticipationJenkinsIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "repoprogexpartjenk"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/StaticCodeAnalysisIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/StaticCodeAnalysisIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisIntegrationTest.java index b0ca8f8bf9c4..02b0f6afc7d5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/StaticCodeAnalysisIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -23,7 +23,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.CategoryState; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; @@ -35,10 +34,13 @@ import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.StaticCodeAnalysisCategory; import de.tum.cit.aet.artemis.programming.dto.StaticCodeAnalysisIssue; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.repository.StaticCodeAnalysisCategoryRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseFeedbackCreationService; import de.tum.cit.aet.artemis.programming.service.StaticCodeAnalysisService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class StaticCodeAnalysisIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -48,7 +50,7 @@ class StaticCodeAnalysisIntegrationTest extends AbstractSpringIntegrationLocalCI private StaticCodeAnalysisService staticCodeAnalysisService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private StaticCodeAnalysisCategoryRepository staticCodeAnalysisCategoryRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/staticcodeanalysis/StaticCodeAnalysisParserUnitTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/staticcodeanalysis/StaticCodeAnalysisParserUnitTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java index 0ef968ed73d1..f2519d178e72 100644 --- a/src/test/java/de/tum/cit/aet/artemis/staticcodeanalysis/StaticCodeAnalysisParserUnitTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.staticcodeanalysis; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/SubmissionPolicyIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/SubmissionPolicyIntegrationTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/SubmissionPolicyIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/SubmissionPolicyIntegrationTest.java index da59b229dae1..f7da35caab33 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/SubmissionPolicyIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/SubmissionPolicyIntegrationTest.java @@ -1,7 +1,7 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static de.tum.cit.aet.artemis.assessment.domain.Feedback.SUBMISSION_POLICY_FEEDBACK_IDENTIFIER; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseResultTestService.convertBuildResultToJsonObject; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseResultTestService.convertBuildResultToJsonObject; import static org.assertj.core.api.Assertions.assertThat; import java.util.Collections; @@ -18,12 +18,11 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; @@ -31,16 +30,19 @@ import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.LockRepositoryPolicy; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.SubmissionPenaltyPolicy; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.SubmissionPolicy; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseGradingService; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.CommitDTO; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class SubmissionPolicyIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "submissionpolicyintegration"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseGradingService gradingService; @@ -243,7 +245,7 @@ void test_updateSubmissionPolicy_ok_lockRepositoryPolicy_newLimitGreater() throw programmingExerciseUtilService.addProgrammingSubmissionToResultAndParticipation(new Result().score(25.0), participation2, "commit2"); programmingExerciseUtilService.addProgrammingSubmissionToResultAndParticipation(new Result().score(30.0), participation2, "commit3"); gitlabRequestMockProvider.enableMockingOfRequests(); - mockRepositoryWritePermissionsForStudent(userRepository.getUserByLoginElseThrow(TEST_PREFIX + "student2"), programmingExercise, HttpStatus.OK); + mockRepositoryWritePermissionsForStudent(userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "student2"), programmingExercise, HttpStatus.OK); request.patch(requestUrl(), SubmissionPolicyBuilder.lockRepo().active(true).limit(3).policy(), HttpStatus.OK); } @@ -259,7 +261,7 @@ void test_updateSubmissionPolicy_ok_lockRepositoryPolicy_newLimitSmaller() throw programmingExerciseUtilService.addProgrammingSubmissionToResultAndParticipation(new Result().score(25.0), participation2, TEST_PREFIX + "commit2"); programmingExerciseUtilService.addProgrammingSubmissionToResultAndParticipation(new Result().score(30.0), participation2, TEST_PREFIX + "commit3"); String repositoryName = programmingExercise.getProjectKey().toLowerCase() + "-" + TEST_PREFIX + "student2"; - User student2 = userRepository.getUserByLoginElseThrow(TEST_PREFIX + "student2"); + User student2 = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "student2"); gitlabRequestMockProvider.enableMockingOfRequests(); mockSetRepositoryPermissionsToReadOnly(participation2.getVcsRepositoryUri(), programmingExercise.getProjectKey(), Set.of(student2)); request.patch(requestUrl(), SubmissionPolicyBuilder.lockRepo().active(true).limit(2).policy(), HttpStatus.OK); @@ -504,7 +506,7 @@ void test_getParticipationSubmissionCount() throws Exception { } private void mockGitlabRequests(ProgrammingExerciseParticipation participation) throws Exception { - User student = userRepository.getUserByLoginElseThrow(TEST_PREFIX + "student1"); + User student = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "student1"); gitlabRequestMockProvider.enableMockingOfRequests(); mockSetRepositoryPermissionsToReadOnly(participation.getVcsRepositoryUri(), programmingExercise.getProjectKey(), Set.of(student)); } diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/TestRepositoryResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/TestRepositoryResourceIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/TestRepositoryResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/TestRepositoryResourceIntegrationTest.java index 89402e73f6b2..32b3decaa0cb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/TestRepositoryResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/TestRepositoryResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -31,7 +31,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.programming.domain.File; import de.tum.cit.aet.artemis.programming.domain.FileType; @@ -40,18 +39,20 @@ import de.tum.cit.aet.artemis.programming.dto.FileMove; import de.tum.cit.aet.artemis.programming.dto.RepositoryStatusDTO; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.GitService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; import de.tum.cit.aet.artemis.programming.web.repository.FileSubmission; -import de.tum.cit.aet.artemis.util.GitUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class TestRepositoryResourceIntegrationTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "testrepositoryresourceint"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/CodeHintIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/CodeHintIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/hestia/CodeHintIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/CodeHintIntegrationTest.java index 1329fae3a40f..a4d326fe43a8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/CodeHintIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/CodeHintIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -13,16 +13,16 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.CodeHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseSolutionEntry; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CodeHintRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseSolutionEntryRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class CodeHintIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -32,7 +32,7 @@ class CodeHintIntegrationTest extends AbstractSpringIntegrationIndependentTest { private CodeHintRepository codeHintRepository; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ProgrammingExerciseSolutionEntryRepository solutionEntryRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/CodeHintServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/CodeHintServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/hestia/CodeHintServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/CodeHintServiceTest.java index ff2cac9f0c21..634e86de81b9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/CodeHintServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/CodeHintServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -15,24 +15,24 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.CodeHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseSolutionEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTestCaseType; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CodeHintRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseSolutionEntryRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; import de.tum.cit.aet.artemis.programming.service.hestia.CodeHintService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") class CodeHintServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -49,7 +49,7 @@ class CodeHintServiceTest extends AbstractSpringIntegrationIndependentTest { private ProgrammingExerciseTaskRepository taskRepository; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ProgrammingExerciseSolutionEntryRepository solutionEntryRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ExerciseHintIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ExerciseHintIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ExerciseHintIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ExerciseHintIntegrationTest.java index 793bdfe13ae4..adaa6e600832 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ExerciseHintIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ExerciseHintIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -15,16 +15,13 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; @@ -32,11 +29,14 @@ import de.tum.cit.aet.artemis.programming.domain.hestia.ExerciseHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ExerciseHintActivation; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ExerciseHintActivationRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ExerciseHintRepository; import de.tum.cit.aet.artemis.programming.service.hestia.ProgrammingExerciseTaskService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ExerciseHintIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -46,7 +46,7 @@ class ExerciseHintIntegrationTest extends AbstractSpringIntegrationIndependentTe private ExerciseHintRepository exerciseHintRepository; @Autowired - private ProgrammingExerciseRepository exerciseRepository; + private ProgrammingExerciseTestRepository exerciseRepository; @Autowired private ProgrammingExerciseTaskService programmingExerciseTaskService; @@ -58,7 +58,7 @@ class ExerciseHintIntegrationTest extends AbstractSpringIntegrationIndependentTe private ExerciseHintActivationRepository exerciseHintActivationRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; @@ -105,7 +105,7 @@ void initTestCase() { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void queryAllAvailableHintsForAnExercise() throws Exception { - var user = userRepository.getUserWithGroupsAndAuthorities(); + var user = userTestRepository.getUserWithGroupsAndAuthorities(); studentParticipation = participationUtilService.addStudentParticipationForProgrammingExercise(exercise, user.getLogin()); addResultWithFailedTestCases(exercise.getTestCases()); addResultWithFailedTestCases(exercise.getTestCases()); @@ -119,7 +119,7 @@ void queryAllAvailableHintsForAnExercise() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void queryAllActivatedHintsForAnExercise() throws Exception { - var user = userRepository.getUserWithGroupsAndAuthorities(); + var user = userTestRepository.getUserWithGroupsAndAuthorities(); var ueha = new ExerciseHintActivation(); ueha.setExerciseHint(exerciseHint); ueha.setUser(user); @@ -137,7 +137,7 @@ void queryAllActivatedHintsForAnExercise() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void activateHintForAnExercise() throws Exception { - var user = userRepository.getUserWithGroupsAndAuthorities(); + var user = userTestRepository.getUserWithGroupsAndAuthorities(); studentParticipation = participationUtilService.addStudentParticipationForProgrammingExercise(exercise, user.getLogin()); addResultWithFailedTestCases(exercise.getTestCases()); addResultWithFailedTestCases(exercise.getTestCases()); @@ -156,7 +156,7 @@ void activateHintForAnExercise() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void rateActivatedHintForAnExercise() throws Exception { - var user = userRepository.getUserWithGroupsAndAuthorities(); + var user = userTestRepository.getUserWithGroupsAndAuthorities(); var ueha = new ExerciseHintActivation(); ueha.setExerciseHint(exerciseHint); ueha.setUser(user); @@ -172,7 +172,7 @@ void rateActivatedHintForAnExercise() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void rateActivatedHintForAnExerciseBadRequest() throws Exception { - var user = userRepository.getUserWithGroupsAndAuthorities(); + var user = userTestRepository.getUserWithGroupsAndAuthorities(); var ueha = new ExerciseHintActivation(); ueha.setExerciseHint(exerciseHint); ueha.setUser(user); diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ExerciseHintServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ExerciseHintServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ExerciseHintServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ExerciseHintServiceTest.java index 7ac7404c08e9..69279ac37859 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ExerciseHintServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ExerciseHintServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -12,44 +12,40 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.ExerciseHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ExerciseHintActivation; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ExerciseHintActivationRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ExerciseHintRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; import de.tum.cit.aet.artemis.programming.service.hestia.ExerciseHintService; import de.tum.cit.aet.artemis.programming.service.hestia.ProgrammingExerciseTaskService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ExerciseHintServiceTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "exercisehintservice"; @Autowired - private UserRepository userRepository; - - @Autowired - private ResultRepository resultRepository; + private UserTestRepository userRepository; @Autowired private ExerciseHintService exerciseHintService; @@ -58,7 +54,7 @@ class ExerciseHintServiceTest extends AbstractSpringIntegrationIndependentTest { private ExerciseHintRepository exerciseHintRepository; @Autowired - private ProgrammingExerciseRepository exerciseRepository; + private ProgrammingExerciseTestRepository exerciseRepository; @Autowired private ProgrammingExerciseTaskService programmingExerciseTaskService; @@ -73,7 +69,7 @@ class ExerciseHintServiceTest extends AbstractSpringIntegrationIndependentTest { private ProgrammingExerciseTaskRepository programmingExerciseTaskRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/HestiaDatabaseTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/HestiaDatabaseTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/hestia/HestiaDatabaseTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/HestiaDatabaseTest.java index f85731128db0..2267bf5acaae 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/HestiaDatabaseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/HestiaDatabaseTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -10,21 +10,21 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.CodeHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseSolutionEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CodeHintRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseSolutionEntryRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; /** * This class tests the database relations of the Hestia domain models. @@ -36,10 +36,10 @@ class HestiaDatabaseTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "hestiadatabase"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private ProgrammingExerciseTaskRepository programmingExerciseTaskRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseGitDiffReportIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseGitDiffReportIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseGitDiffReportIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseGitDiffReportIntegrationTest.java index 8efecef86337..5ade087731f1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseGitDiffReportIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseGitDiffReportIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -12,14 +12,14 @@ import org.springframework.security.test.context.support.WithMockUser; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.localvcci.AbstractLocalCILocalVCIntegrationTest; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseGitDiffEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseGitDiffReport; +import de.tum.cit.aet.artemis.programming.hestia.util.HestiaUtilTestService; +import de.tum.cit.aet.artemis.programming.localvcci.AbstractLocalCILocalVCIntegrationTest; import de.tum.cit.aet.artemis.programming.service.hestia.ProgrammingExerciseGitDiffReportService; -import de.tum.cit.aet.artemis.util.HestiaUtilTestService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; /** * Tests for the ProgrammingExerciseGitDiffReportResource diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseGitDiffReportServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseGitDiffReportServiceTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseGitDiffReportServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseGitDiffReportServiceTest.java index a9659c0dda1c..983859d19a09 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseGitDiffReportServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseGitDiffReportServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -13,17 +13,17 @@ import org.springframework.security.test.context.support.WithMockUser; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.localvcci.AbstractLocalCILocalVCIntegrationTest; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseGitDiffEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseGitDiffReport; +import de.tum.cit.aet.artemis.programming.hestia.util.HestiaUtilTestService; +import de.tum.cit.aet.artemis.programming.localvcci.AbstractLocalCILocalVCIntegrationTest; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseGitDiffReportRepository; import de.tum.cit.aet.artemis.programming.service.hestia.ProgrammingExerciseGitDiffReportService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.HestiaUtilTestService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; /** * Tests for the ProgrammingExerciseGitDiffReportService diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseSolutionEntryIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseSolutionEntryIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseSolutionEntryIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseSolutionEntryIntegrationTest.java index b2a3ca490e3d..4bf515d2e4db 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseSolutionEntryIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseSolutionEntryIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -12,17 +12,17 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.CodeHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseSolutionEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CodeHintRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseSolutionEntryRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseSolutionEntryIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -32,7 +32,7 @@ class ProgrammingExerciseSolutionEntryIntegrationTest extends AbstractSpringInte private ProgrammingExerciseSolutionEntryRepository programmingExerciseSolutionEntryRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private ProgrammingExerciseTaskRepository programmingExerciseTaskRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseTaskIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseTaskIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseTaskIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseTaskIntegrationTest.java index c4e4d5693020..c302c5945314 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseTaskIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseTaskIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -14,32 +14,32 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseSolutionEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseSolutionEntryRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; import de.tum.cit.aet.artemis.programming.service.hestia.ProgrammingExerciseTaskService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseTaskIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "progextask"; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseTaskRepository programmingExerciseTaskRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private ProgrammingExerciseSolutionEntryRepository programmingExerciseSolutionEntryRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseTaskServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseTaskServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseTaskServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseTaskServiceTest.java index d41d9f291008..b2fcb4b0bf31 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/ProgrammingExerciseTaskServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/ProgrammingExerciseTaskServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -12,21 +12,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.DomainObject; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.CodeHint; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTask; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CodeHintRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; import de.tum.cit.aet.artemis.programming.service.hestia.ProgrammingExerciseTaskService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseTaskServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -39,10 +39,10 @@ class ProgrammingExerciseTaskServiceTest extends AbstractSpringIntegrationIndepe private ProgrammingExerciseTaskRepository programmingExerciseTaskRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private CodeHintRepository codeHintRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/StructuralTestCaseServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/StructuralTestCaseServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/StructuralTestCaseServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/StructuralTestCaseServiceTest.java index 7ee786c73041..88b8bef4921d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/StructuralTestCaseServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/StructuralTestCaseServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -14,18 +14,18 @@ import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.localvcci.AbstractLocalCILocalVCIntegrationTest; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTestCaseType; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; +import de.tum.cit.aet.artemis.programming.hestia.util.HestiaUtilTestService; +import de.tum.cit.aet.artemis.programming.localvcci.AbstractLocalCILocalVCIntegrationTest; import de.tum.cit.aet.artemis.programming.service.hestia.structural.StructuralSolutionEntryGenerationException; import de.tum.cit.aet.artemis.programming.service.hestia.structural.StructuralTestCaseService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.HestiaUtilTestService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; /** * Tests for the StructuralTestCaseService @@ -52,7 +52,7 @@ class StructuralTestCaseServiceTest extends AbstractLocalCILocalVCIntegrationTes private StructuralTestCaseService structuralTestCaseService; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; private ProgrammingExercise exercise; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/TestwiseCoverageIntegrationTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/TestwiseCoverageIntegrationTest.java index 49c080170e7f..6319f8395fd4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/TestwiseCoverageIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -11,10 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; @@ -22,18 +19,21 @@ import de.tum.cit.aet.artemis.programming.domain.hestia.CoverageFileReport; import de.tum.cit.aet.artemis.programming.domain.hestia.CoverageReport; import de.tum.cit.aet.artemis.programming.domain.hestia.TestwiseCoverageReportEntry; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CoverageFileReportRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CoverageReportRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.TestwiseCoverageReportEntryRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class TestwiseCoverageIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "testwisecoverageint"; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private CoverageReportRepository coverageReportRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageReportServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/TestwiseCoverageReportServiceTest.java similarity index 87% rename from src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageReportServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/TestwiseCoverageReportServiceTest.java index ca8a60171f06..607ecd3c496f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageReportServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/TestwiseCoverageReportServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia; import static org.assertj.core.api.Assertions.assertThat; @@ -14,22 +14,23 @@ import org.springframework.security.test.context.support.WithMockUser; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.localvcci.AbstractLocalCILocalVCIntegrationTest; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.hestia.TestwiseCoverageReportEntry; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; +import de.tum.cit.aet.artemis.programming.hestia.util.HestiaUtilTestService; +import de.tum.cit.aet.artemis.programming.hestia.util.TestwiseCoverageTestUtil; +import de.tum.cit.aet.artemis.programming.localvcci.AbstractLocalCILocalVCIntegrationTest; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CoverageReportRepository; import de.tum.cit.aet.artemis.programming.service.hestia.TestwiseCoverageService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.HestiaUtilTestService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; class TestwiseCoverageReportServiceTest extends AbstractLocalCILocalVCIntegrationTest { @@ -42,10 +43,10 @@ class TestwiseCoverageReportServiceTest extends AbstractLocalCILocalVCIntegratio private CoverageReportRepository coverageReportRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private SolutionProgrammingExerciseParticipationRepository solutionProgrammingExerciseRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/AddUncoveredLinesAsPotentialCodeBlocksTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/AddUncoveredLinesAsPotentialCodeBlocksTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/AddUncoveredLinesAsPotentialCodeBlocksTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/AddUncoveredLinesAsPotentialCodeBlocksTest.java index 0817bf437998..30ab4619e68e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/AddUncoveredLinesAsPotentialCodeBlocksTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/AddUncoveredLinesAsPotentialCodeBlocksTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/BehavioralTestCaseServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/BehavioralTestCaseServiceTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/BehavioralTestCaseServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/BehavioralTestCaseServiceTest.java index ec83f2ffc3ea..76b08ffd4600 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/BehavioralTestCaseServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/BehavioralTestCaseServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; @@ -13,9 +13,8 @@ import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.localvcci.AbstractLocalCILocalVCIntegrationTest; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; @@ -26,16 +25,17 @@ import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseSolutionEntry; import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTestCaseType; import de.tum.cit.aet.artemis.programming.domain.hestia.TestwiseCoverageReportEntry; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; +import de.tum.cit.aet.artemis.programming.hestia.util.HestiaUtilTestService; +import de.tum.cit.aet.artemis.programming.localvcci.AbstractLocalCILocalVCIntegrationTest; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CoverageFileReportRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.CoverageReportRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseGitDiffReportRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.TestwiseCoverageReportEntryRepository; import de.tum.cit.aet.artemis.programming.service.hestia.behavioral.BehavioralTestCaseService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.HestiaUtilTestService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; class BehavioralTestCaseServiceTest extends AbstractLocalCILocalVCIntegrationTest { @@ -50,7 +50,7 @@ class BehavioralTestCaseServiceTest extends AbstractLocalCILocalVCIntegrationTes private HestiaUtilTestService hestiaUtilTestService; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ProgrammingExerciseGitDiffReportRepository programmingExerciseGitDiffReportRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CombineChangeBlocksTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CombineChangeBlocksTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CombineChangeBlocksTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CombineChangeBlocksTest.java index 2c9fd0950c31..a9c8e9689bd7 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CombineChangeBlocksTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CombineChangeBlocksTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CreateCommonChangeBlocksTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CreateCommonChangeBlocksTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CreateCommonChangeBlocksTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CreateCommonChangeBlocksTest.java index 2465f8a19ad0..40feb7c133be 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CreateCommonChangeBlocksTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CreateCommonChangeBlocksTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CreateSolutionEntriesTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CreateSolutionEntriesTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CreateSolutionEntriesTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CreateSolutionEntriesTest.java index 615f37bf5489..20da41c8c3aa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/CreateSolutionEntriesTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/CreateSolutionEntriesTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/DropRemovedGitDiffEntriesTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/DropRemovedGitDiffEntriesTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/DropRemovedGitDiffEntriesTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/DropRemovedGitDiffEntriesTest.java index 42b40860c7c8..450203b02931 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/DropRemovedGitDiffEntriesTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/DropRemovedGitDiffEntriesTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/ExtractChangedLinesTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/ExtractChangedLinesTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/ExtractChangedLinesTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/ExtractChangedLinesTest.java index 3c3a7bf79c38..016c4f5b6f21 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/ExtractChangedLinesTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/ExtractChangedLinesTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/ExtractCoveredLinesTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/ExtractCoveredLinesTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/ExtractCoveredLinesTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/ExtractCoveredLinesTest.java index b15f5a37cbff..2be7206a11ae 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/ExtractCoveredLinesTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/ExtractCoveredLinesTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/FindCommonLinesTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/FindCommonLinesTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/FindCommonLinesTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/FindCommonLinesTest.java index 3b9d00026fdb..e36d44be008a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/FindCommonLinesTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/FindCommonLinesTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest.java index 444f9ab74fe0..1e624e5b130b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/GroupGitDiffAndCoverageEntriesByFilePathAndTestCaseTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/InsertFileContentsTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/InsertFileContentsTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/InsertFileContentsTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/InsertFileContentsTest.java index 5061d14843bb..e0ed10e61fa2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/behavioral/InsertFileContentsTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/behavioral/InsertFileContentsTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia.behavioral; +package de.tum.cit.aet.artemis.programming.hestia.behavioral; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/HestiaUtilTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/util/HestiaUtilTestService.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/util/HestiaUtilTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/util/HestiaUtilTestService.java index deb7be323835..92e857ca6eea 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/HestiaUtilTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/util/HestiaUtilTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.programming.hestia.util; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -18,20 +18,22 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; import de.tum.cit.aet.artemis.programming.domain.Repository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.TemplateProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.service.GitService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; /** * Utility service specifically used for testing Hestia related functionality. @@ -49,7 +51,7 @@ public class HestiaUtilTestService { private GitService gitService; @Autowired - private ProgrammingExerciseRepository exerciseRepository; + private ProgrammingExerciseTestRepository exerciseRepository; @Autowired private ProgrammingSubmissionTestRepository programmingSubmissionRepository; @@ -67,7 +69,7 @@ public class HestiaUtilTestService { private ParticipationUtilService participationUtilService; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageTestUtil.java b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/util/TestwiseCoverageTestUtil.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageTestUtil.java rename to src/test/java/de/tum/cit/aet/artemis/programming/hestia/util/TestwiseCoverageTestUtil.java index f10823de8a2e..4dae98fee0b5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/hestia/TestwiseCoverageTestUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/hestia/util/TestwiseCoverageTestUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.hestia; +package de.tum.cit.aet.artemis.programming.hestia.util; import java.util.Map; import java.util.Set; diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/AbstractLocalCILocalVCIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/AbstractLocalCILocalVCIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/AbstractLocalCILocalVCIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/AbstractLocalCILocalVCIntegrationTest.java index f7de03ae7e54..225208431d5e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/AbstractLocalCILocalVCIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/AbstractLocalCILocalVCIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import java.time.ZonedDateTime; import java.util.List; @@ -13,14 +13,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProjectType; import de.tum.cit.aet.artemis.programming.domain.SolutionProgrammingExerciseParticipation; @@ -28,7 +27,8 @@ import de.tum.cit.aet.artemis.programming.repository.AuxiliaryRepositoryRepository; import de.tum.cit.aet.artemis.programming.service.StaticCodeAnalysisService; import de.tum.cit.aet.artemis.programming.service.aeolus.AeolusTemplateService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; public class AbstractLocalCILocalVCIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -41,7 +41,7 @@ public class AbstractLocalCILocalVCIntegrationTest extends AbstractSpringIntegra protected ExamRepository examRepository; @Autowired - protected StudentExamRepository studentExamRepository; + protected StudentExamTestRepository studentExamRepository; @Autowired protected UserUtilService userUtilService; @@ -129,7 +129,7 @@ void initUsersAndExercise() throws JsonProcessingException { instructor2 = users.stream().filter(user -> instructor2Login.equals(user.getLogin())).findFirst().orElseThrow(); // Remove instructor2 from the instructor group of the course. instructor2.setGroups(Set.of()); - userRepository.save(instructor2); + userTestRepository.save(instructor2); course = programmingExerciseUtilService.addCourseWithOneProgrammingExercise(); programmingExercise = exerciseUtilService.getFirstExerciseWithType(course, ProgrammingExercise.class); diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentConfigurationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentConfigurationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentConfigurationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentConfigurationTest.java index 6e25e8a943e9..4c1ac9044ae9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentConfigurationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentConfigurationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentDockerServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentDockerServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentDockerServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentDockerServiceTest.java index fa31a0eefc30..3b514091deae 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentDockerServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentDockerServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; @@ -28,7 +28,6 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.buildagent.dto.BuildConfig; import de.tum.cit.aet.artemis.buildagent.dto.BuildJobQueueItem; import de.tum.cit.aet.artemis.buildagent.service.BuildAgentDockerService; @@ -36,6 +35,7 @@ import de.tum.cit.aet.artemis.core.exception.LocalCIException; import de.tum.cit.aet.artemis.programming.domain.build.BuildJob; import de.tum.cit.aet.artemis.programming.domain.build.BuildStatus; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class BuildAgentDockerServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentSshAuthenticationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentSshAuthenticationIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentSshAuthenticationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentSshAuthenticationIntegrationTest.java index c0d16101f65d..9caa0bdc3ef9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildAgentSshAuthenticationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildAgentSshAuthenticationIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; @@ -13,10 +13,10 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.buildagent.dto.BuildAgentInformation; import de.tum.cit.aet.artemis.buildagent.service.BuildAgentSshKeyService; import de.tum.cit.aet.artemis.buildagent.service.SharedQueueProcessingService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class BuildAgentSshAuthenticationIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildResultTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildResultTest.java similarity index 78% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/BuildResultTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildResultTest.java index 7b89aec82354..104d6cda1207 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/BuildResultTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/BuildResultTest.java @@ -1,11 +1,11 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.buildagent.dto.BuildResult; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class BuildResultTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIIntegrationTest.java index 684439d104d9..70d024bab294 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static de.tum.cit.aet.artemis.core.config.Constants.LOCALCI_RESULTS_DIRECTORY; import static de.tum.cit.aet.artemis.core.config.Constants.LOCALCI_WORKING_DIRECTORY; @@ -53,7 +53,6 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.buildagent.dto.ResultBuildJob; import de.tum.cit.aet.artemis.core.exception.VersionControlException; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; @@ -64,7 +63,8 @@ import de.tum.cit.aet.artemis.programming.service.BuildLogEntryService; import de.tum.cit.aet.artemis.programming.service.ParticipationVcsAccessTokenService; import de.tum.cit.aet.artemis.programming.service.localvc.LocalVCServletService; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class LocalCIIntegrationTest extends AbstractLocalCILocalVCIntegrationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIResourceIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIResourceIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIResourceIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIResourceIntegrationTest.java index 9c048bb7696a..fe61f9efed96 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIResourceIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIResourceIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; @@ -33,12 +33,12 @@ import de.tum.cit.aet.artemis.buildagent.service.SharedQueueProcessingService; import de.tum.cit.aet.artemis.core.dto.SortingOrder; import de.tum.cit.aet.artemis.core.dto.pageablesearch.PageableSearchDTO; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.programming.domain.RepositoryType; import de.tum.cit.aet.artemis.programming.domain.build.BuildJob; import de.tum.cit.aet.artemis.programming.domain.build.BuildLogEntry; import de.tum.cit.aet.artemis.programming.domain.build.BuildStatus; import de.tum.cit.aet.artemis.programming.service.BuildLogEntryService; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; class LocalCIResourceIntegrationTest extends AbstractLocalCILocalVCIntegrationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIResultServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIResultServiceTest.java similarity index 89% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIResultServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIResultServiceTest.java index 4c0536c082ff..d5d4c75af8fe 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIResultServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIResultServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -9,8 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired; import de.tum.cit.aet.artemis.core.exception.LocalCIException; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; import de.tum.cit.aet.artemis.programming.service.localci.LocalCIResultService; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; class LocalCIResultServiceTest extends AbstractLocalCILocalVCIntegrationTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIServiceTest.java index 7a2e6fe3f578..5c723326dcfb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalCIServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalCIServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; @@ -23,16 +23,14 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.buildagent.dto.BuildConfig; import de.tum.cit.aet.artemis.buildagent.dto.BuildJobQueueItem; import de.tum.cit.aet.artemis.buildagent.dto.JobTimingInfo; import de.tum.cit.aet.artemis.buildagent.dto.RepositoryInfo; import de.tum.cit.aet.artemis.buildagent.service.SharedQueueProcessingService; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; @@ -43,6 +41,8 @@ import de.tum.cit.aet.artemis.programming.service.aeolus.AeolusTemplateService; import de.tum.cit.aet.artemis.programming.service.aeolus.Windfile; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService.BuildStatus; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class LocalCIServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCInfoContributorTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCInfoContributorTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCInfoContributorTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCInfoContributorTest.java index 7180d276e07f..f5e68ec19d27 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCInfoContributorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCInfoContributorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ARTEMIS; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_BUILDAGENT; diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCIntegrationTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCIntegrationTest.java index 7ff35bbb8939..37358ed515a6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCIntegrationTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; -import static de.tum.cit.aet.artemis.user.UserFactory.USER_PASSWORD; +import static de.tum.cit.aet.artemis.core.user.util.UserFactory.USER_PASSWORD; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; @@ -29,10 +29,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.core.service.ldap.LdapUserDto; import de.tum.cit.aet.artemis.programming.service.localvc.LocalVCRepositoryUri; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; /** * This class contains integration tests for edge cases pertaining to the local VC system. diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCIIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCIIntegrationTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCIIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCIIntegrationTest.java index ada7b3c72c8b..c171a3f60cca 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCIIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCIIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static de.tum.cit.aet.artemis.core.config.Constants.LOCALCI_RESULTS_DIRECTORY; import static de.tum.cit.aet.artemis.core.config.Constants.LOCALCI_WORKING_DIRECTORY; @@ -42,10 +42,10 @@ import org.springframework.security.test.context.support.WithMockUser; import de.tum.cit.aet.artemis.core.service.ldap.LdapUserDto; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository; @@ -55,7 +55,7 @@ import de.tum.cit.aet.artemis.programming.domain.build.BuildJob; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.LockRepositoryPolicy; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.SubmissionPolicy; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; /** * This class contains integration tests for the base repositories (template, solution, tests) and the different types of assignment repositories (student assignment, teaching diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCIParticipationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCIParticipationIntegrationTest.java similarity index 92% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCIParticipationIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCIParticipationIntegrationTest.java index 1ac8510ab262..449c56a3003c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCIParticipationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCIParticipationIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; @@ -10,12 +10,10 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.AuthenticationMechanism; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.TemplateProgrammingExerciseParticipation; @@ -23,8 +21,10 @@ import de.tum.cit.aet.artemis.programming.dto.VcsAccessLogDTO; import de.tum.cit.aet.artemis.programming.repository.VcsAccessLogRepository; import de.tum.cit.aet.artemis.programming.service.localvc.LocalVCRepositoryUri; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.web.repository.RepositoryActionType; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class LocalVCLocalCIParticipationIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -90,7 +90,7 @@ void testStartParticipation() throws Exception { @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void testGetVcsAccessLog() throws Exception { var participation = participationUtilService.addStudentParticipationForProgrammingExercise(programmingExercise, TEST_PREFIX + "instructor1"); - var user = userRepository.getUser(); + var user = userTestRepository.getUser(); vcsAccessLogRepository.save(new VcsAccessLog(user, participation, "instructor", "instructorMail@mail.de", RepositoryActionType.READ, AuthenticationMechanism.SSH, "", "")); var li = request.getList("/api/programming-exercise-participations/" + participation.getId() + "/vcs-access-log", HttpStatus.OK, VcsAccessLogDTO.class); assertThat(li.size()).isEqualTo(1); @@ -100,7 +100,7 @@ void testGetVcsAccessLog() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void testGetVcsAccessLogOfTemplateParticipation() throws Exception { - var user = userRepository.getUser(); + var user = userTestRepository.getUser(); vcsAccessLogRepository.save(new VcsAccessLog(user, programmingExercise.getTemplateParticipation(), "instructor", "instructorMail@mail.de", RepositoryActionType.READ, AuthenticationMechanism.SSH, "", "")); var li = request.getList("/api/programming-exercise/" + programmingExercise.getId() + "/vcs-access-log/TEMPLATE", HttpStatus.OK, VcsAccessLogDTO.class); diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCITestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCITestService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCITestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCITestService.java index 43daf2171dbf..313ba5295850 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCLocalCITestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCLocalCITestService.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; -import static de.tum.cit.aet.artemis.user.UserFactory.USER_PASSWORD; +import static de.tum.cit.aet.artemis.core.user.util.UserFactory.USER_PASSWORD; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Fail.fail; @@ -54,21 +54,21 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ParticipationVCSAccessToken; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.service.GitService; import de.tum.cit.aet.artemis.programming.service.ParticipationVcsAccessTokenService; import de.tum.cit.aet.artemis.programming.service.localvc.LocalVCRepositoryUri; -import de.tum.cit.aet.artemis.util.LocalRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.LocalRepository; /** * This class contains helper methods for all tests of the local VC and local CI system.. @@ -80,19 +80,19 @@ public class LocalVCLocalCITestService { private ParticipationUtilService participationUtilService; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ProgrammingSubmissionTestRepository programmingSubmissionRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired private ParticipationVcsAccessTokenService participationVcsAccessTokenService; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Value("${artemis.version-control.url}") private URL localVCBaseUrl; diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCSshIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCSshIntegrationTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCSshIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCSshIntegrationTest.java index 0cd28557c201..419a751e92e3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCSshIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/LocalVCSshIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_LOCALVC; import static org.assertj.core.api.Assertions.assertThat; @@ -60,7 +60,7 @@ void testDirectlyAuthenticateOverSsh() throws IOException, GeneralSecurityExcept localVCLocalCITestService.createParticipation(programmingExercise, student1Login); KeyPair keyPair = setupKeyPairAndAddToUser(); - User user = userRepository.getUser(); + User user = userTestRepository.getUser(); try (SshClient client = SshClient.setUpDefaultClient()) { client.start(); @@ -88,7 +88,7 @@ void testAuthenticationFailure() { localVCLocalCITestService.createParticipation(programmingExercise, student1Login); KeyPair keyPair = generateKeyPair(); - User user = userRepository.getUser(); + User user = userTestRepository.getUser(); assertThatThrownBy(() -> { @@ -149,7 +149,7 @@ private SshClient clientConnectToArtemisSshServer() throws GeneralSecurityExcept var numberOfSessions = serverSessions.size(); localVCLocalCITestService.createParticipation(programmingExercise, student1Login); KeyPair keyPair = setupKeyPairAndAddToUser(); - User user = userRepository.getUser(); + User user = userTestRepository.getUser(); SshClient client = SshClient.setUpDefaultClient(); client.start(); @@ -176,7 +176,7 @@ private SshClient clientConnectToArtemisSshServer() throws GeneralSecurityExcept private KeyPair setupKeyPairAndAddToUser() throws GeneralSecurityException, IOException { - User user = userRepository.getUser(); + User user = userTestRepository.getUser(); KeyPair rsaKeyPair = generateKeyPair(); String sshPublicKey = writePublicKeyToString(rsaKeyPair.getPublic(), user.getLogin() + "@host"); @@ -186,8 +186,8 @@ private KeyPair setupKeyPairAndAddToUser() throws GeneralSecurityException, IOEx PublicKey publicKey = keyEntry.resolvePublicKey(null, null, null); String keyHash = HashUtils.getSha512Fingerprint(publicKey); - userRepository.updateUserSshPublicKeyHash(user.getId(), keyHash, sshPublicKey); - user = userRepository.getUser(); + userTestRepository.updateUserSshPublicKeyHash(user.getId(), keyHash, sshPublicKey); + user = userTestRepository.getUser(); assertThat(user.getSshPublicKey()).isEqualTo(sshPublicKey); return rsaKeyPair; diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/MultipleHostKeyProviderTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/MultipleHostKeyProviderTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/MultipleHostKeyProviderTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/MultipleHostKeyProviderTest.java index fa14a05e9a08..c045a7486981 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/MultipleHostKeyProviderTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/MultipleHostKeyProviderTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_LOCALVC; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/uri/RepositoryUriTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/RepositoryUriTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/uri/RepositoryUriTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/RepositoryUriTest.java index 29919ccded74..ece90eae3ea9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/uri/RepositoryUriTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/RepositoryUriTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.uri; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/SharedQueueManagementServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/SharedQueueManagementServiceTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/SharedQueueManagementServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/SharedQueueManagementServiceTest.java index d8b968be9ed4..23555d8fa783 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/SharedQueueManagementServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/SharedQueueManagementServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci; import static org.assertj.core.api.Assertions.assertThat; @@ -11,9 +11,9 @@ import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.programming.domain.build.BuildJob; import de.tum.cit.aet.artemis.programming.service.localci.SharedQueueManagementService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class SharedQueueManagementServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/util/LocalVCServiceTest.java similarity index 88% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/util/LocalVCServiceTest.java index 9f780f37593e..c0c7481c872e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/LocalVCServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/util/LocalVCServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci.util; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verifyNoInteractions; @@ -8,14 +8,14 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.service.connectors.ConnectorHealth; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class LocalVCServiceTest extends AbstractSpringIntegrationLocalCILocalVCTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/localvcci/TestBuildAgentConfiguration.java b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/util/TestBuildAgentConfiguration.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/localvcci/TestBuildAgentConfiguration.java rename to src/test/java/de/tum/cit/aet/artemis/programming/localvcci/util/TestBuildAgentConfiguration.java index 0053033c9485..936d53302706 100644 --- a/src/test/java/de/tum/cit/aet/artemis/localvcci/TestBuildAgentConfiguration.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/localvcci/util/TestBuildAgentConfiguration.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.localvcci; +package de.tum.cit.aet.artemis.programming.localvcci.util; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -38,7 +38,7 @@ import de.tum.cit.aet.artemis.buildagent.BuildAgentConfiguration; import de.tum.cit.aet.artemis.buildagent.service.BuildAgentDockerService; -import de.tum.cit.aet.artemis.util.FixMissingServletPathProcessor; +import de.tum.cit.aet.artemis.core.util.FixMissingServletPathProcessor; /** * This class is used to overwrite the configuration of the local CI system ({@link BuildAgentConfiguration}). diff --git a/src/test/java/de/tum/cit/aet/artemis/service/BuildLogEntryServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/BuildLogEntryServiceTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/service/BuildLogEntryServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/BuildLogEntryServiceTest.java index 50319d7d03af..04f7854a5b2a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/BuildLogEntryServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/BuildLogEntryServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThat; @@ -14,10 +14,9 @@ import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.build.BuildLogEntry; -import de.tum.cit.aet.artemis.programming.service.BuildLogEntryService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class BuildLogEntryServiceTest extends AbstractSpringIntegrationIndependentTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/ConsistencyCheckTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/ConsistencyCheckTestService.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/service/ConsistencyCheckTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/ConsistencyCheckTestService.java index e3831e7b7016..376fdaaf761e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/ConsistencyCheckTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/ConsistencyCheckTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThat; @@ -13,14 +13,14 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.exercise.programming.MockDelegate; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.dto.ConsistencyErrorDTO; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.RequestUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.MockDelegate; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; /** * Note: this class should be independent of the actual VCS and CIS and contains common test logic for scenarios: @@ -33,10 +33,10 @@ public class ConsistencyCheckTestService { private RequestUtilService request; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/GitlabCIServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/GitlabCIServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/GitlabCIServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/GitlabCIServiceTest.java index e224abafd0fa..e91e0d1fdb83 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/GitlabCIServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/GitlabCIServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -27,14 +27,13 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationGitlabCIGitlabSamlTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.exception.GitLabCIException; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; @@ -44,10 +43,11 @@ import de.tum.cit.aet.artemis.programming.repository.BuildLogStatisticsEntryRepository; import de.tum.cit.aet.artemis.programming.repository.BuildPlanRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.ci.ContinuousIntegrationService; import de.tum.cit.aet.artemis.programming.service.gitlabci.GitLabCIResultService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationGitlabCIGitlabSamlTest; class GitlabCIServiceTest extends AbstractSpringIntegrationGitlabCIGitlabSamlTest { @@ -57,13 +57,13 @@ class GitlabCIServiceTest extends AbstractSpringIntegrationGitlabCIGitlabSamlTes private URL gitlabServerUrl; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired private BuildPlanRepository buildPlanRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsAuthorizationInterceptorTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsAuthorizationInterceptorTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/service/JenkinsAuthorizationInterceptorTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsAuthorizationInterceptorTest.java index 53c33512d950..bd42466d4c6c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsAuthorizationInterceptorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsAuthorizationInterceptorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.doReturn; @@ -30,8 +30,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.programming.service.jenkins.JenkinsAuthorizationInterceptor; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class JenkinsAuthorizationInterceptorTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsInternalUriServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsInternalUriServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/JenkinsInternalUriServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsInternalUriServiceTest.java index 3cdbda0029b6..404051085bda 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsInternalUriServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsInternalUriServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.any; @@ -17,9 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.util.ReflectionTestUtils; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; import de.tum.cit.aet.artemis.programming.service.jenkins.JenkinsInternalUrlService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class JenkinsInternalUriServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsJobPermissionServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsJobPermissionServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/service/JenkinsJobPermissionServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsJobPermissionServiceTest.java index b5cc173d97ec..c6db962e6c5f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsJobPermissionServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsJobPermissionServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThatIOException; import static org.mockito.ArgumentMatchers.any; @@ -17,10 +17,10 @@ import org.w3c.dom.DOMException; import org.w3c.dom.Document; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.programming.service.jenkins.jobs.JenkinsJobPermission; import de.tum.cit.aet.artemis.programming.service.jenkins.jobs.JenkinsJobPermissionsService; import de.tum.cit.aet.artemis.programming.service.jenkins.jobs.JenkinsJobPermissionsUtils; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class JenkinsJobPermissionServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsJobServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsJobServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/JenkinsJobServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsJobServiceTest.java index 699ce3f666fb..738312ba6ecd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsJobServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsJobServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static de.tum.cit.aet.artemis.programming.service.jenkins.JenkinsXmlFileUtils.getDocumentBuilderFactory; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -27,11 +27,11 @@ import com.offbytwo.jenkins.model.FolderJob; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.exception.JenkinsException; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.programming.service.jenkins.JenkinsXmlFileUtils; import de.tum.cit.aet.artemis.programming.service.jenkins.jobs.JenkinsJobService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class JenkinsJobServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/JenkinsServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsServiceTest.java index 372b9f679ed3..fa7183716ec8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/JenkinsServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/JenkinsServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; import static de.tum.cit.aet.artemis.core.config.Constants.ASSIGNMENT_REPO_NAME; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.SOLUTION; @@ -31,21 +31,20 @@ import com.offbytwo.jenkins.model.JobWithDetails; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.exception.JenkinsException; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.ContinuousIntegrationTestService; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.programming.ContinuousIntegrationTestService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.build.BuildPlan; import de.tum.cit.aet.artemis.programming.repository.BuildPlanRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseImportService; import de.tum.cit.aet.artemis.programming.service.jenkins.build_plan.JenkinsBuildPlanUtils; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class JenkinsServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -55,7 +54,7 @@ class JenkinsServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { private ContinuousIntegrationTestService continuousIntegrationTestService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/programming/ProgrammingExerciseFeedbackCreationServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseFeedbackCreationServiceTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/service/programming/ProgrammingExerciseFeedbackCreationServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseFeedbackCreationServiceTest.java index 2042a1fc8d91..a8e26befb1d3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/programming/ProgrammingExerciseFeedbackCreationServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseFeedbackCreationServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.programming; +package de.tum.cit.aet.artemis.programming.service; import static org.assertj.core.api.Assertions.assertThat; @@ -12,15 +12,12 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; @@ -31,9 +28,11 @@ import de.tum.cit.aet.artemis.programming.dto.StaticCodeAnalysisIssue; import de.tum.cit.aet.artemis.programming.dto.StaticCodeAnalysisReportDTO; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; -import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseFeedbackCreationService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class ProgrammingExerciseFeedbackCreationServiceTest extends AbstractSpringIntegrationIndependentTest { @@ -41,13 +40,13 @@ class ProgrammingExerciseFeedbackCreationServiceTest extends AbstractSpringInteg private ProgrammingExerciseFeedbackCreationService feedbackCreationService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private ProgrammingExerciseUtilService programmingExerciseUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/RepositoryAccessServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/RepositoryAccessServiceTest.java similarity index 83% rename from src/test/java/de/tum/cit/aet/artemis/service/RepositoryAccessServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/RepositoryAccessServiceTest.java index 5b3469528876..8d5106407a89 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/RepositoryAccessServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/RepositoryAccessServiceTest.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.programming.service; -import static de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseResultTestService.convertBuildResultToJsonObject; +import static de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseResultTestService.convertBuildResultToJsonObject; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.catchThrowableOfType; @@ -18,33 +18,31 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.AccessForbiddenException; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.TestConstants; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.submissionpolicy.LockRepositoryPolicy; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseGradingService; -import de.tum.cit.aet.artemis.programming.service.RepositoryAccessService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseFactory; +import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; import de.tum.cit.aet.artemis.programming.web.repository.RepositoryActionType; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.TestConstants; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class RepositoryAccessServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { private static final String TEST_PREFIX = "rastest"; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private RepositoryAccessService repositoryAccessService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/gitlab/GitLabPersonalAccessTokenManagementServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/gitlab/GitLabPersonalAccessTokenManagementServiceTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/gitlab/GitLabPersonalAccessTokenManagementServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/gitlab/GitLabPersonalAccessTokenManagementServiceTest.java index 6a21f767586c..e6a8ed1e7eb8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/gitlab/GitLabPersonalAccessTokenManagementServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/gitlab/GitLabPersonalAccessTokenManagementServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.gitlab; +package de.tum.cit.aet.artemis.programming.service.connectors.gitlab; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; @@ -29,13 +29,13 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabException; import de.tum.cit.aet.artemis.programming.service.gitlab.GitLabPersonalAccessTokenManagementService; import de.tum.cit.aet.artemis.programming.service.gitlab.dto.GitLabPersonalAccessTokenListResponseDTO; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class GitLabPersonalAccessTokenManagementServiceTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -45,7 +45,7 @@ class GitLabPersonalAccessTokenManagementServiceTest extends AbstractSpringInteg private GitLabPersonalAccessTokenManagementService gitLabPersonalAccessTokenManagementService; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/jenkins/build_plan/JenkinsPipelineScriptCreatorTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/build_plan/JenkinsPipelineScriptCreatorTest.java similarity index 91% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/jenkins/build_plan/JenkinsPipelineScriptCreatorTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/build_plan/JenkinsPipelineScriptCreatorTest.java index a4e63e9d095d..81110e30059c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/jenkins/build_plan/JenkinsPipelineScriptCreatorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/build_plan/JenkinsPipelineScriptCreatorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.jenkins.build_plan; +package de.tum.cit.aet.artemis.programming.service.connectors.jenkins.build_plan; import static org.assertj.core.api.Assertions.assertThat; @@ -8,8 +8,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationJenkinsGitlabTest; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; @@ -17,8 +16,9 @@ import de.tum.cit.aet.artemis.programming.domain.build.BuildPlan; import de.tum.cit.aet.artemis.programming.repository.BuildPlanRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; import de.tum.cit.aet.artemis.programming.service.jenkins.build_plan.JenkinsPipelineScriptCreator; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationJenkinsGitlabTest; class JenkinsPipelineScriptCreatorTest extends AbstractSpringIntegrationJenkinsGitlabTest { @@ -29,7 +29,7 @@ class JenkinsPipelineScriptCreatorTest extends AbstractSpringIntegrationJenkinsG private JenkinsPipelineScriptCreator jenkinsPipelineScriptCreator; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/jenkins/jobs/JenkinsJobPermissionsUtilsTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/jobs/JenkinsJobPermissionsUtilsTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/jenkins/jobs/JenkinsJobPermissionsUtilsTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/jobs/JenkinsJobPermissionsUtilsTest.java index d8489aefbe8a..d0034223ee10 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/jenkins/jobs/JenkinsJobPermissionsUtilsTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/jobs/JenkinsJobPermissionsUtilsTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.jenkins.jobs; +package de.tum.cit.aet.artemis.programming.service.connectors.jenkins.jobs; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/service/connectors/vcs/VcsTokenRenewalServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/vcs/VcsTokenRenewalServiceTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/service/connectors/vcs/VcsTokenRenewalServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/vcs/VcsTokenRenewalServiceTest.java index 14a7e31c8b12..038e927b64f1 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/connectors/vcs/VcsTokenRenewalServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/service/connectors/jenkins/vcs/VcsTokenRenewalServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service.connectors.vcs; +package de.tum.cit.aet.artemis.programming.service.connectors.jenkins.vcs; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; @@ -23,7 +23,7 @@ import org.mockito.Mockito; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.UserRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; import de.tum.cit.aet.artemis.programming.service.vcs.VcsTokenManagementService; import de.tum.cit.aet.artemis.programming.service.vcs.VcsTokenRenewalService; @@ -31,12 +31,12 @@ class VcsTokenRenewalServiceTest { private VcsTokenManagementService vcsTokenManagementService; - private UserRepository userRepository; + private UserTestRepository userRepository; @BeforeEach void setUp() { vcsTokenManagementService = Mockito.mock(VcsTokenManagementService.class); - userRepository = Mockito.mock(UserRepository.class); + userRepository = Mockito.mock(UserTestRepository.class); } @AfterEach diff --git a/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/BuildJobTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/BuildJobTestRepository.java new file mode 100644 index 000000000000..353f9769776a --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/BuildJobTestRepository.java @@ -0,0 +1,19 @@ +package de.tum.cit.aet.artemis.programming.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.assessment.domain.Result; +import de.tum.cit.aet.artemis.programming.domain.build.BuildJob; +import de.tum.cit.aet.artemis.programming.repository.BuildJobRepository; + +@Repository +@Primary +public interface BuildJobTestRepository extends BuildJobRepository { + + Optional findBuildJobByResult(Result result); + + Optional findFirstByParticipationIdOrderByBuildStartDateDesc(Long participationId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingExerciseStudentParticipationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseStudentParticipationTestRepository.java similarity index 71% rename from src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingExerciseStudentParticipationTestRepository.java rename to src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseStudentParticipationTestRepository.java index ed19d94e1983..f534e7eca3f4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingExerciseStudentParticipationTestRepository.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseStudentParticipationTestRepository.java @@ -1,19 +1,23 @@ -package de.tum.cit.aet.artemis.core.repository; +package de.tum.cit.aet.artemis.programming.test_repository; +import java.util.List; + +import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; -import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; +import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; /** * Spring Data JPA testing repository for the ProgrammingExerciseStudentParticipation entity. */ @Repository -public interface ProgrammingExerciseStudentParticipationTestRepository extends ArtemisJpaRepository { +@Primary +public interface ProgrammingExerciseStudentParticipationTestRepository extends ProgrammingExerciseStudentParticipationRepository { /** * updates the build plan id of all programming exercise student participations @@ -28,4 +32,5 @@ public interface ProgrammingExerciseStudentParticipationTestRepository extends A """) void updateBuildPlanIdOfAll(@Param("buildPlanId") Long buildPlanId); + List findByExerciseId(long exerciseId); } diff --git a/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseTestCaseTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseTestCaseTestRepository.java new file mode 100644 index 000000000000..da42f6d383d3 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseTestCaseTestRepository.java @@ -0,0 +1,33 @@ +package de.tum.cit.aet.artemis.programming.test_repository; + +import java.util.Optional; +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; +import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; + +@Repository +@Primary +public interface ProgrammingExerciseTestCaseTestRepository extends ProgrammingExerciseTestCaseRepository { + + Optional findByExerciseIdAndTestName(long exerciseId, String testName); + + /** + * Returns all test cases with the associated solution entries for a programming exercise + * + * @param exerciseId of the exercise + * @return all test cases with the associated solution entries + */ + @Query(""" + SELECT DISTINCT tc + FROM ProgrammingExerciseTestCase tc + LEFT JOIN FETCH tc.solutionEntries se + WHERE tc.exercise.id = :exerciseId + """) + Set findByExerciseIdWithSolutionEntries(@Param("exerciseId") long exerciseId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingExerciseTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseTestRepository.java similarity index 55% rename from src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingExerciseTestRepository.java rename to src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseTestRepository.java index 3a3cb2dd016b..dba45e8f6298 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingExerciseTestRepository.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingExerciseTestRepository.java @@ -1,21 +1,28 @@ -package de.tum.cit.aet.artemis.core.repository; +package de.tum.cit.aet.artemis.programming.test_repository; import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; import java.time.ZonedDateTime; import java.util.List; +import java.util.Optional; import java.util.Set; +import jakarta.validation.constraints.NotNull; + +import org.hibernate.Hibernate; +import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; +import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; +import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; @Repository -public interface ProgrammingExerciseTestRepository extends ArtemisJpaRepository { +@Primary +public interface ProgrammingExerciseTestRepository extends ProgrammingExerciseRepository { @Query(""" SELECT p @@ -76,4 +83,43 @@ default List findAllWithBuildAndTestAfterDueDateInFuture() @EntityGraph(type = LOAD, attributePaths = { "templateParticipation", "solutionParticipation" }) List findAllWithTemplateAndSolutionParticipationByIdIn(Set exerciseIds); + + List findAllByCourse_InstructorGroupNameIn(Set groupNames); + + List findAllByCourse_EditorGroupNameIn(Set groupNames); + + List findAllByCourse_TeachingAssistantGroupNameIn(Set groupNames); + + @NotNull + default ProgrammingExercise findByIdWithBuildConfigElseThrow(long programmingExerciseId) throws EntityNotFoundException { + return getValueElseThrow(findWithBuildConfigById(programmingExerciseId), programmingExerciseId); + } + + @EntityGraph(type = LOAD, attributePaths = { "templateParticipation", "solutionParticipation", "studentParticipations.team.students", "buildConfig" }) + Optional findWithAllParticipationsAndBuildConfigById(long exerciseId); + + @Query(""" + SELECT DISTINCT pe + FROM ProgrammingExercise pe + LEFT JOIN FETCH pe.templateParticipation + LEFT JOIN FETCH pe.solutionParticipation + WHERE pe.id = :exerciseId + """) + Optional findWithEagerTemplateAndSolutionParticipationsById(@Param("exerciseId") long exerciseId); + + @EntityGraph(type = LOAD, attributePaths = { "buildConfig" }) + Optional findWithBuildConfigById(long exerciseId); + + /** + * Fetch the programming exercise with the build config, or throw an EntityNotFoundException if it cannot be found. + * + * @param programmingExercise The programming exercise to fetch the build config for. + * @return The programming exercise with the build config. + */ + default ProgrammingExercise getProgrammingExerciseWithBuildConfigElseThrow(ProgrammingExercise programmingExercise) { + if (programmingExercise.getBuildConfig() == null || !Hibernate.isInitialized(programmingExercise.getBuildConfig())) { + return getValueElseThrow(findWithBuildConfigById(programmingExercise.getId()), programmingExercise.getId()); + } + return programmingExercise; + } } diff --git a/src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingSubmissionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingSubmissionTestRepository.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingSubmissionTestRepository.java rename to src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingSubmissionTestRepository.java index 6573757e1fab..ac76366e75ff 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/repository/ProgrammingSubmissionTestRepository.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/test_repository/ProgrammingSubmissionTestRepository.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.core.repository; +package de.tum.cit.aet.artemis.programming.test_repository; import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; @@ -7,20 +7,22 @@ import jakarta.validation.constraints.NotNull; +import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; +import de.tum.cit.aet.artemis.programming.repository.ProgrammingSubmissionRepository; /** * Spring Data JPA repository for the ProgrammingSubmission entity tests. */ @Repository -public interface ProgrammingSubmissionTestRepository extends ArtemisJpaRepository { +@Primary +public interface ProgrammingSubmissionTestRepository extends ProgrammingSubmissionRepository { @EntityGraph(type = LOAD, attributePaths = "results") @Query(""" diff --git a/src/test/java/de/tum/cit/aet/artemis/theia/TheiaInfoContributorTest.java b/src/test/java/de/tum/cit/aet/artemis/programming/theia/TheiaInfoContributorTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/theia/TheiaInfoContributorTest.java rename to src/test/java/de/tum/cit/aet/artemis/programming/theia/TheiaInfoContributorTest.java index bb1160555967..6fea8d87da45 100644 --- a/src/test/java/de/tum/cit/aet/artemis/theia/TheiaInfoContributorTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/theia/TheiaInfoContributorTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.theia; +package de.tum.cit.aet.artemis.programming.theia; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_THEIA; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ArgumentSources.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ArgumentSources.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ArgumentSources.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ArgumentSources.java index f16380e47e40..c8b66beb167f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ArgumentSources.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ArgumentSources.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.ASSEMBLER; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.OCAML; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/GitUtilService.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/GitUtilService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/util/GitUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/GitUtilService.java index afda253a9b0e..c68c5d5cf5d6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/GitUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/GitUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.programming.util; import static org.assertj.core.api.Fail.fail; @@ -24,10 +24,9 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; -import de.tum.cit.aet.artemis.exercise.programming.ProgrammingExerciseFactory; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.Repository; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/LocalRepository.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/LocalRepository.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/util/LocalRepository.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/LocalRepository.java index 978282c30044..da3e022b0a98 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/LocalRepository.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/LocalRepository.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util; +package de.tum.cit.aet.artemis.programming.util; import java.io.File; import java.io.IOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/MockDelegate.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/MockDelegate.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/MockDelegate.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/MockDelegate.java index 2950d971ba6e..89b745f66689 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/MockDelegate.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/MockDelegate.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; import java.io.IOException; import java.net.MalformedURLException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseFactory.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java index 076826603971..e01c45a01b9e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java @@ -1,6 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; -import static de.tum.cit.aet.artemis.exercise.ExerciseFactory.populateExerciseForExam; +import static de.tum.cit.aet.artemis.exercise.util.ExerciseFactory.populateExerciseForExam; import static java.time.ZonedDateTime.now; import java.time.ZonedDateTime; @@ -16,10 +16,11 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; +import de.tum.cit.aet.artemis.core.util.TestConstants; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.ExerciseFactory; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; +import de.tum.cit.aet.artemis.exercise.util.ExerciseFactory; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseBuildConfig; import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; @@ -34,7 +35,6 @@ import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestCaseDetailMessageDTO; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestResultsDTO; import de.tum.cit.aet.artemis.programming.service.ci.notification.dto.TestSuiteDTO; -import de.tum.cit.aet.artemis.util.TestConstants; /** * Factory for creating ProgrammingExercises and related objects. diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseResultTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseResultTestService.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseResultTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseResultTestService.java index 2bf82cd237ad..1ad25c969e6c 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseResultTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseResultTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; import static de.tum.cit.aet.artemis.core.config.Constants.NEW_RESULT_TOPIC; import static java.util.Comparator.comparing; @@ -38,15 +38,16 @@ import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Visibility; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.communication.service.WebsocketMessagingService; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; import de.tum.cit.aet.artemis.core.service.messaging.InstanceMessageSendService; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.hestia.TestwiseCoverageTestUtil; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; +import de.tum.cit.aet.artemis.core.util.TestConstants; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; @@ -57,18 +58,17 @@ import de.tum.cit.aet.artemis.programming.domain.hestia.ProgrammingExerciseTestCaseType; import de.tum.cit.aet.artemis.programming.dto.AbstractBuildResultNotificationDTO; import de.tum.cit.aet.artemis.programming.dto.ResultDTO; +import de.tum.cit.aet.artemis.programming.hestia.util.TestwiseCoverageTestUtil; import de.tum.cit.aet.artemis.programming.repository.ParticipationVCSAccessTokenRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.service.GitService; import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseGradingService; import de.tum.cit.aet.artemis.programming.service.StaticCodeAnalysisService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.RequestUtilService; -import de.tum.cit.aet.artemis.util.TestConstants; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; /** * Note: this class should be independent of the actual VCS and CIS and contains common test logic for both scenarios: @@ -81,7 +81,7 @@ public class ProgrammingExerciseResultTestService { private String ARTEMIS_AUTHENTICATION_TOKEN_VALUE; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @@ -99,16 +99,16 @@ public class ProgrammingExerciseResultTestService { private StaticCodeAnalysisService staticCodeAnalysisService; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private FeedbackRepository feedbackRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository participationRepository; + private ProgrammingExerciseStudentParticipationTestRepository participationRepository; @Autowired - private ResultRepository resultRepository; + private ResultTestRepository resultRepository; @Autowired private GitService gitService; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseTestService.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseTestService.java index f3b63117216d..1914e2b533f4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseTestService.java @@ -1,5 +1,6 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; +import static de.tum.cit.aet.artemis.core.util.TestConstants.COMMIT_HASH_OBJECT_ID; import static de.tum.cit.aet.artemis.exercise.domain.ExerciseMode.INDIVIDUAL; import static de.tum.cit.aet.artemis.exercise.domain.ExerciseMode.TEAM; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.C; @@ -8,7 +9,6 @@ import static de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseExportService.BUILD_PLAN_FILE_NAME; import static de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseExportService.EXPORTED_EXERCISE_DETAILS_FILE_PREFIX; import static de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseExportService.EXPORTED_EXERCISE_PROBLEM_STATEMENT_FILE_PREFIX; -import static de.tum.cit.aet.artemis.util.TestConstants.COMMIT_HASH_OBJECT_ID; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.within; @@ -78,26 +78,29 @@ import de.tum.cit.aet.artemis.core.dto.CourseForDashboardDTO; import de.tum.cit.aet.artemis.core.exception.GitException; import de.tum.cit.aet.artemis.core.exception.VersionControlException; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.ProgrammingExerciseStudentParticipationTestRepository; -import de.tum.cit.aet.artemis.core.repository.ProgrammingExerciseTestRepository; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.security.Role; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.core.service.export.CourseExamExportService; import de.tum.cit.aet.artemis.core.service.user.PasswordService; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; +import de.tum.cit.aet.artemis.core.util.TestConstants; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExamUser; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.domain.StudentExam; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExamUserRepository; -import de.tum.cit.aet.artemis.exam.repository.StudentExamRepository; import de.tum.cit.aet.artemis.exam.service.ExamImportService; +import de.tum.cit.aet.artemis.exam.test_repository.StudentExamTestRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exam.util.ExamPrepareExercisesTestUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; @@ -105,12 +108,13 @@ import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.TeamAssignmentConfig; import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; import de.tum.cit.aet.artemis.exercise.service.ParticipationService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.fileupload.util.ZipFileTestUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismDetectionConfig; import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; @@ -131,9 +135,6 @@ import de.tum.cit.aet.artemis.programming.repository.BuildLogStatisticsEntryRepository; import de.tum.cit.aet.artemis.programming.repository.BuildPlanRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.StaticCodeAnalysisCategoryRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; import de.tum.cit.aet.artemis.programming.service.AutomaticProgrammingExerciseCleanupService; @@ -146,15 +147,11 @@ import de.tum.cit.aet.artemis.programming.service.jenkins.build_plan.JenkinsBuildPlanUtils; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlRepositoryPermission; import de.tum.cit.aet.artemis.programming.service.vcs.VersionControlService; -import de.tum.cit.aet.artemis.user.UserFactory; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.ExamPrepareExercisesTestUtil; -import de.tum.cit.aet.artemis.util.GitUtilService.MockFileRepositoryUri; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; -import de.tum.cit.aet.artemis.util.LocalRepository; -import de.tum.cit.aet.artemis.util.RequestUtilService; -import de.tum.cit.aet.artemis.util.TestConstants; -import de.tum.cit.aet.artemis.util.ZipFileTestUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; +import de.tum.cit.aet.artemis.programming.util.GitUtilService.MockFileRepositoryUri; /** * Note: this class should be independent of the actual VCS and CIS and contains common test logic for scenarios: @@ -177,16 +174,16 @@ public class ProgrammingExerciseTestService { private GitService gitService; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private TeamRepository teamRepository; @Autowired - private UserRepository userRepo; + private UserTestRepository userRepo; @Autowired - private CourseRepository courseRepository; + private CourseTestRepository courseRepository; @Autowired private ExamRepository examRepository; @@ -198,10 +195,10 @@ public class ProgrammingExerciseTestService { private ParticipationService participationService; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private ProgrammingSubmissionTestRepository programmingSubmissionRepository; @@ -234,7 +231,7 @@ public class ProgrammingExerciseTestService { private ProgrammingExerciseTaskRepository programmingExerciseTaskRepository; @Autowired - private ProgrammingExerciseTestCaseRepository programmingExerciseTestCaseRepository; + private ProgrammingExerciseTestCaseTestRepository programmingExerciseTestCaseRepository; @Autowired private UriService uriService; @@ -243,10 +240,10 @@ public class ProgrammingExerciseTestService { private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseParticipationTestRepository; @Autowired - private ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + private ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired - private StudentExamRepository studentExamRepository; + private StudentExamTestRepository studentExamRepository; @Autowired private ExamUserRepository examUserRepository; @@ -467,7 +464,7 @@ public void setupRepositoryMocksParticipant(ProgrammingExercise exercise, String } // TEST - void createProgrammingExercise_sequential_validExercise_created(ProgrammingLanguage programmingLanguage) throws Exception { + public void createProgrammingExercise_sequential_validExercise_created(ProgrammingLanguage programmingLanguage) throws Exception { exercise = ProgrammingExerciseFactory.generateProgrammingExercise(ZonedDateTime.now().minusDays(1), ZonedDateTime.now().plusDays(7), course, programmingLanguage); exercise.getBuildConfig().setSequentialTestRuns(true); exercise.setChannelName("testchannel-pe"); @@ -477,7 +474,7 @@ void createProgrammingExercise_sequential_validExercise_created(ProgrammingLangu } // TEST - void createProgrammingExercise_custom_build_plan_validExercise_created(ProgrammingLanguage programmingLanguage, boolean customBuildPlanWorks) throws Exception { + public void createProgrammingExercise_custom_build_plan_validExercise_created(ProgrammingLanguage programmingLanguage, boolean customBuildPlanWorks) throws Exception { exercise = ProgrammingExerciseFactory.generateProgrammingExercise(ZonedDateTime.now().minusDays(1), ZonedDateTime.now().plusDays(7), course, programmingLanguage); String validWindfile = """ { @@ -518,7 +515,7 @@ void createProgrammingExercise_custom_build_plan_validExercise_created(Programmi } // TEST - void createProgrammingExercise_mode_validExercise_created(ExerciseMode mode) throws Exception { + public void createProgrammingExercise_mode_validExercise_created(ExerciseMode mode) throws Exception { exercise.setMode(mode); exercise.setChannelName("testchannel-pe"); mockDelegate.mockConnectorRequestsForSetup(exercise, false, false, false); @@ -526,7 +523,8 @@ void createProgrammingExercise_mode_validExercise_created(ExerciseMode mode) thr } // TEST - void createProgrammingExercise_programmingLanguage_validExercise_created(ProgrammingLanguage language, ProgrammingLanguageFeature programmingLanguageFeature) throws Exception { + public void createProgrammingExercise_programmingLanguage_validExercise_created(ProgrammingLanguage language, ProgrammingLanguageFeature programmingLanguageFeature) + throws Exception { exercise.setProgrammingLanguage(language); if (language == SWIFT) { exercise.setPackageName("swiftTest"); @@ -538,7 +536,7 @@ void createProgrammingExercise_programmingLanguage_validExercise_created(Program } // TEST - void createProgrammingExercise_validExercise_bonusPointsIsNull() throws Exception { + public void createProgrammingExercise_validExercise_bonusPointsIsNull() throws Exception { exercise.setBonusPoints(null); mockDelegate.mockConnectorRequestsForSetup(exercise, false, false, false); exercise.setChannelName("testchannel-pe"); @@ -548,7 +546,7 @@ void createProgrammingExercise_validExercise_bonusPointsIsNull() throws Exceptio assertThat(savedExercise.getBonusPoints()).isZero(); } - void importFromFile_validJavaExercise_isSuccessfullyImported(boolean scaEnabled) throws Exception { + public void importFromFile_validJavaExercise_isSuccessfullyImported(boolean scaEnabled) throws Exception { mockDelegate.mockConnectorRequestForImportFromFile(exercise); Resource resource = new ClassPathResource("test-data/import-from-file/valid-import.zip"); if (scaEnabled) { @@ -584,7 +582,7 @@ void importFromFile_validJavaExercise_isSuccessfullyImported(boolean scaEnabled) assertThat(importedExercise.getCourseViaExerciseGroupOrCourseMember()).isEqualTo(course); } - void importFromFile_validExercise_isSuccessfullyImported(ProgrammingLanguage language) throws Exception { + public void importFromFile_validExercise_isSuccessfullyImported(ProgrammingLanguage language) throws Exception { mockDelegate.mockConnectorRequestForImportFromFile(exercise); Resource resource = null; exercise.programmingLanguage(language); @@ -606,7 +604,7 @@ void importFromFile_validExercise_isSuccessfullyImported(ProgrammingLanguage lan ProgrammingExercise.class, HttpStatus.OK); } - void importFromFile_embeddedFiles_embeddedFilesCopied() throws Exception { + public void importFromFile_embeddedFiles_embeddedFilesCopied() throws Exception { String embeddedFileName1 = "Markdown_2023-05-06T16-17-46-410_ad323711.jpg"; String embeddedFileName2 = "Markdown_2023-05-06T16-17-46-822_b921f475.jpg"; Path fileSystemPathEmbeddedFile1 = FilePathService.getMarkdownFilePath().resolve(embeddedFileName1); @@ -631,7 +629,7 @@ void importFromFile_embeddedFiles_embeddedFilesCopied() throws Exception { } - void importFromFile_buildPlanPresent_buildPlanUsed() throws Exception { + public void importFromFile_buildPlanPresent_buildPlanUsed() throws Exception { mockDelegate.mockConnectorRequestForImportFromFile(exercise); var resource = new ClassPathResource("test-data/import-from-file/import-with-build-plan.zip"); var file = new MockMultipartFile("file", "test.zip", "application/zip", resource.getInputStream()); @@ -644,21 +642,21 @@ void importFromFile_buildPlanPresent_buildPlanUsed() throws Exception { } - void importFromFile_missingExerciseDetailsJson_badRequest() throws Exception { + public void importFromFile_missingExerciseDetailsJson_badRequest() throws Exception { Resource resource = new ClassPathResource("test-data/import-from-file/missing-json.zip"); var file = new MockMultipartFile("file", "test.zip", "application/zip", resource.getInputStream()); request.postWithMultipartFile("/api/courses/" + course.getId() + "/programming-exercises/import-from-file", exercise, "programmingExercise", file, ProgrammingExercise.class, HttpStatus.BAD_REQUEST); } - void importFromFile_fileNoZip_badRequest() throws Exception { + public void importFromFile_fileNoZip_badRequest() throws Exception { Resource resource = new ClassPathResource("test-data/import-from-file/valid-import.zip"); var file = new MockMultipartFile("file", "test.txt", "application/zip", resource.getInputStream()); request.postWithMultipartFile("/api/courses/" + course.getId() + "/programming-exercises/import-from-file", exercise, "programmingExercise", file, ProgrammingExercise.class, HttpStatus.BAD_REQUEST); } - void importFromFile_tutor_forbidden() throws Exception { + public void importFromFile_tutor_forbidden() throws Exception { course.setInstructorGroupName("test"); courseRepository.save(course); var file = new MockMultipartFile("file", "test.zip", "application/zip", new byte[0]); @@ -666,7 +664,7 @@ void importFromFile_tutor_forbidden() throws Exception { ProgrammingExercise.class, HttpStatus.FORBIDDEN); } - void importFromFile_missingRepository_BadRequest() throws Exception { + public void importFromFile_missingRepository_BadRequest() throws Exception { Resource resource = new ClassPathResource("test-data/import-from-file/missing-repository.zip"); var file = new MockMultipartFile("file", "test.zip", "application/zip", resource.getInputStream()); request.postWithMultipartFile("/api/courses/" + course.getId() + "/programming-exercises/import-from-file", exercise, "programmingExercise", file, @@ -685,7 +683,8 @@ public void importFromFile_exception_DirectoryDeleted() throws Exception { } // TEST - void createProgrammingExercise_validExercise_withStaticCodeAnalysis(ProgrammingLanguage language, ProgrammingLanguageFeature programmingLanguageFeature) throws Exception { + public void createProgrammingExercise_validExercise_withStaticCodeAnalysis(ProgrammingLanguage language, ProgrammingLanguageFeature programmingLanguageFeature) + throws Exception { exercise.setStaticCodeAnalysisEnabled(true); exercise.setProgrammingLanguage(language); if (language == SWIFT) { @@ -715,7 +714,7 @@ void createProgrammingExercise_validExercise_withStaticCodeAnalysis(ProgrammingL } // TEST - void createProgrammingExercise_failToCreateProjectInCi() throws Exception { + public void createProgrammingExercise_failToCreateProjectInCi() throws Exception { exercise.setMode(ExerciseMode.INDIVIDUAL); exercise.setChannelName("testchannel-pe"); mockDelegate.mockConnectorRequestsForSetup(exercise, true, false, false); @@ -724,7 +723,7 @@ void createProgrammingExercise_failToCreateProjectInCi() throws Exception { } // TEST - void createProgrammingExerciseForExam_validExercise_created() throws Exception { + public void createProgrammingExerciseForExam_validExercise_created() throws Exception { setupRepositoryMocks(examExercise, exerciseRepo, solutionRepo, testRepo, auxRepo); mockDelegate.mockConnectorRequestsForSetup(examExercise, false, false, false); @@ -737,7 +736,7 @@ void createProgrammingExerciseForExam_validExercise_created() throws Exception { } // TEST - void createProgrammingExerciseForExam_invalidExercise_dates(InvalidExamExerciseDateConfiguration dates) throws Exception { + public void createProgrammingExerciseForExam_invalidExercise_dates(InvalidExamExerciseDateConfiguration dates) throws Exception { setupRepositoryMocks(examExercise, exerciseRepo, solutionRepo, testRepo, auxRepo); mockDelegate.mockConnectorRequestsForSetup(examExercise, false, false, false); @@ -745,7 +744,7 @@ void createProgrammingExerciseForExam_invalidExercise_dates(InvalidExamExerciseD } // TEST - void createProgrammingExerciseForExam_DatesSet() throws Exception { + public void createProgrammingExerciseForExam_DatesSet() throws Exception { setupRepositoryMocks(examExercise, exerciseRepo, solutionRepo, testRepo, auxRepo); mockDelegate.mockConnectorRequestsForSetup(examExercise, false, false, false); ZonedDateTime someMoment = ZonedDateTime.of(2000, 6, 15, 0, 0, 0, 0, ZoneId.of("Z")); @@ -762,7 +761,7 @@ private AuxiliaryRepository addAuxiliaryRepositoryToProgrammingExercise(Programm } // TEST - void createAndImportJavaProgrammingExercise(boolean staticCodeAnalysisEnabled) throws Exception { + public void createAndImportJavaProgrammingExercise(boolean staticCodeAnalysisEnabled) throws Exception { setupRepositoryMocks(exercise, sourceExerciseRepo, sourceSolutionRepo, sourceTestRepo, sourceAuxRepo); mockDelegate.mockConnectorRequestsForSetup(exercise, false, false, false); exercise.setProjectType(ProjectType.MAVEN_MAVEN); @@ -823,7 +822,7 @@ void createAndImportJavaProgrammingExercise(boolean staticCodeAnalysisEnabled) t } // TEST - void importExercise_created(ProgrammingLanguage programmingLanguage, boolean recreateBuildPlans, boolean addAuxRepos) throws Exception { + public void importExercise_created(ProgrammingLanguage programmingLanguage, boolean recreateBuildPlans, boolean addAuxRepos) throws Exception { boolean staticCodeAnalysisEnabled = programmingLanguage == JAVA || programmingLanguage == SWIFT; // Setup exercises for import ProgrammingExercise sourceExercise = programmingExerciseUtilService.addCourseWithOneProgrammingExerciseAndStaticCodeAnalysisCategories(programmingLanguage); @@ -883,7 +882,7 @@ void importExercise_created(ProgrammingLanguage programmingLanguage, boolean rec assertThat(importedExercise.getTemplateParticipation().getBuildPlanId()).isNotBlank().isNotEqualTo(sourceExercise.getTemplateParticipation().getBuildPlanId()); } - void updateBuildPlanURL() throws Exception { + public void updateBuildPlanURL() throws Exception { try (MockedStatic mockedUtils = mockStatic(JenkinsBuildPlanUtils.class)) { ArgumentCaptor toBeReplacedCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor replacementCaptor = ArgumentCaptor.forClass(String.class); @@ -929,7 +928,7 @@ void updateBuildPlanURL() throws Exception { } // TEST - void importExercise_enablePlanFails() throws Exception { + public void importExercise_enablePlanFails() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = programmingExerciseUtilService.addCourseWithOneProgrammingExerciseAndStaticCodeAnalysisCategories(); // programmingExerciseUtilService.addTestCasesToProgrammingExercise(sourceExercise); @@ -952,7 +951,7 @@ void importExercise_enablePlanFails() throws Exception { } // TEST - void importExercise_planDoesntExist() throws Exception { + public void importExercise_planDoesntExist() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = programmingExerciseUtilService.addCourseWithOneProgrammingExerciseAndStaticCodeAnalysisCategories(); sourceExercise = programmingExerciseUtilService.loadProgrammingExerciseWithEagerReferences(sourceExercise); @@ -974,7 +973,7 @@ void importExercise_planDoesntExist() throws Exception { } // TEST - void testImportProgrammingExercise_team_modeChange() throws Exception { + public void testImportProgrammingExercise_team_modeChange() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = programmingExerciseUtilService.addCourseWithOneProgrammingExerciseAndStaticCodeAnalysisCategories(); sourceExercise.setMode(ExerciseMode.INDIVIDUAL); @@ -1014,7 +1013,7 @@ void testImportProgrammingExercise_team_modeChange() throws Exception { } // TEST - void testImportProgrammingExercise_individual_modeChange() throws Exception { + public void testImportProgrammingExercise_individual_modeChange() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = programmingExerciseUtilService.addCourseWithOneProgrammingExerciseAndStaticCodeAnalysisCategories(); sourceExercise.setMode(TEAM); @@ -1056,7 +1055,7 @@ void testImportProgrammingExercise_individual_modeChange() throws Exception { } // TEST - void testImportProgrammingExercise_scaChange() throws Exception { + public void testImportProgrammingExercise_scaChange() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = programmingExerciseUtilService.addCourseWithOneProgrammingExerciseAndStaticCodeAnalysisCategories(); programmingExerciseUtilService.addTestCasesToProgrammingExercise(sourceExercise); @@ -1083,7 +1082,7 @@ void testImportProgrammingExercise_scaChange() throws Exception { assertThat(exerciseToBeImported.getMaxStaticCodeAnalysisPenalty()).isNull(); } - void testImportProgrammingExercise_scaChange_activated() throws Exception { + public void testImportProgrammingExercise_scaChange_activated() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = (ProgrammingExercise) programmingExerciseUtilService.addCourseWithOneProgrammingExercise(false).getExercises().iterator().next(); programmingExerciseUtilService.addTestCasesToProgrammingExercise(sourceExercise); @@ -1117,7 +1116,7 @@ void testImportProgrammingExercise_scaChange_activated() throws Exception { assertThat(exerciseToBeImported.getMaxStaticCodeAnalysisPenalty()).isEqualTo(80); } - void testImportProgrammingExerciseLockRepositorySubmissionPolicyChange() throws Exception { + public void testImportProgrammingExerciseLockRepositorySubmissionPolicyChange() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = (ProgrammingExercise) programmingExerciseUtilService.addCourseWithOneProgrammingExercise(false).getExercises().iterator().next(); programmingExerciseUtilService.addTestCasesToProgrammingExercise(sourceExercise); @@ -1145,7 +1144,7 @@ void testImportProgrammingExerciseLockRepositorySubmissionPolicyChange() throws assertThat(sourceExercise.getSubmissionPolicy()).isNull(); } - void testImportProgrammingExerciseNoneSubmissionPolicyChange() throws Exception { + public void testImportProgrammingExerciseNoneSubmissionPolicyChange() throws Exception { // Setup exercises for import ProgrammingExercise sourceExercise = (ProgrammingExercise) programmingExerciseUtilService.addCourseWithOneProgrammingExercise(false).getExercises().iterator().next(); programmingExerciseUtilService.addTestCasesToProgrammingExercise(sourceExercise); @@ -1243,7 +1242,7 @@ public void importProgrammingExerciseAsPartOfExamImport() throws Exception { } // TEST - void createProgrammingExercise_validExercise_structureOracle() throws Exception { + public void createProgrammingExercise_validExercise_structureOracle() throws Exception { mockDelegate.mockConnectorRequestsForSetup(exercise, false, false, false); exercise.setChannelName("testchannel-pe"); @@ -1270,7 +1269,7 @@ void createProgrammingExercise_validExercise_structureOracle() throws Exception } // TEST - void createProgrammingExercise_noTutors_created() throws Exception { + public void createProgrammingExercise_noTutors_created() throws Exception { course.setTeachingAssistantGroupName(null); courseRepository.save(course); mockDelegate.mockConnectorRequestsForSetup(exercise, false, false, false); @@ -1280,7 +1279,7 @@ void createProgrammingExercise_noTutors_created() throws Exception { } // TEST - void startProgrammingExercise_correctInitializationState(ExerciseMode exerciseMode) throws Exception { + public void startProgrammingExercise_correctInitializationState(ExerciseMode exerciseMode) throws Exception { setupCourseWithProgrammingExercise(exerciseMode); var user = userRepo.findOneByLogin(userPrefix + STUDENT_LOGIN).orElseThrow(); Participant participant = user; @@ -1294,7 +1293,7 @@ void startProgrammingExercise_correctInitializationState(ExerciseMode exerciseMo } // TEST - void startProgrammingExercise_correctInitializationState() throws Exception { + public void startProgrammingExercise_correctInitializationState() throws Exception { var user = userUtilService.createAndSaveUser("edx_student1"); user.setInternal(true); user = userRepo.save(user); @@ -1311,7 +1310,7 @@ void startProgrammingExercise_correctInitializationState() throws Exception { assertThat(participation.getInitializationState()).as("Participation should be initialized").isEqualTo(InitializationState.INITIALIZED); } - void startProgrammingExercise(Boolean offlineIde) throws Exception { + public void startProgrammingExercise(Boolean offlineIde) throws Exception { exercise.setAllowOnlineEditor(true); exercise.setAllowOfflineIde(offlineIde); exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig())); @@ -1343,14 +1342,14 @@ private Course setupCourseWithProgrammingExercise(ExerciseMode exerciseMode) { } // TEST - void resumeProgrammingExercise_doesNotExist(ExerciseMode exerciseMode) throws Exception { + public void resumeProgrammingExercise_doesNotExist(ExerciseMode exerciseMode) throws Exception { setupCourseWithProgrammingExercise(exerciseMode); request.putWithResponseBody("/api/exercises/" + exercise.getId() + "/resume-programming-participation/" + -1, null, ProgrammingExerciseStudentParticipation.class, HttpStatus.NOT_FOUND); } // TEST - void resumeProgrammingExercise_correctInitializationState(ExerciseMode exerciseMode) throws Exception { + public void resumeProgrammingExercise_correctInitializationState(ExerciseMode exerciseMode) throws Exception { var participation = createStudentParticipationWithSubmission(exerciseMode); // These will be updated when the participation is resumed. @@ -1370,7 +1369,7 @@ void resumeProgrammingExercise_correctInitializationState(ExerciseMode exerciseM } // TEST - void resumeProgrammingExerciseByPushingIntoRepo_correctInitializationState(ExerciseMode exerciseMode, Object body) throws Exception { + public void resumeProgrammingExerciseByPushingIntoRepo_correctInitializationState(ExerciseMode exerciseMode, Object body) throws Exception { var participation = createStudentParticipationWithSubmission(exerciseMode); var participant = participation.getParticipant(); @@ -1393,7 +1392,7 @@ void resumeProgrammingExerciseByPushingIntoRepo_correctInitializationState(Exerc } // TEST - void resumeProgrammingExerciseByTriggeringBuild_correctInitializationState(ExerciseMode exerciseMode, SubmissionType submissionType) throws Exception { + public void resumeProgrammingExerciseByTriggeringBuild_correctInitializationState(ExerciseMode exerciseMode, SubmissionType submissionType) throws Exception { var participation = createStudentParticipationWithSubmission(exerciseMode); var participant = participation.getParticipant(); @@ -1426,7 +1425,7 @@ void resumeProgrammingExerciseByTriggeringBuild_correctInitializationState(Exerc } // TEST - void resumeProgrammingExerciseByTriggeringFailedBuild_correctInitializationState(ExerciseMode exerciseMode, boolean buildPlanExists) throws Exception { + public void resumeProgrammingExerciseByTriggeringFailedBuild_correctInitializationState(ExerciseMode exerciseMode, boolean buildPlanExists) throws Exception { var participation = createStudentParticipationWithSubmission(exerciseMode); var participant = participation.getParticipant(); @@ -1463,7 +1462,7 @@ void resumeProgrammingExerciseByTriggeringFailedBuild_correctInitializationState } // TEST - void resumeProgrammingExerciseByTriggeringInstructorBuild_correctInitializationState(ExerciseMode exerciseMode) throws Exception { + public void resumeProgrammingExerciseByTriggeringInstructorBuild_correctInitializationState(ExerciseMode exerciseMode) throws Exception { var participation = createStudentParticipationWithSubmission(exerciseMode); var participant = participation.getParticipant(); @@ -1497,7 +1496,7 @@ void resumeProgrammingExerciseByTriggeringInstructorBuild_correctInitializationS } // Test - void exportInstructorRepositories_shouldReturnFile() throws Exception { + public void exportInstructorRepositories_shouldReturnFile() throws Exception { String zip = exportInstructorRepository(RepositoryType.TEMPLATE, exerciseRepo, HttpStatus.OK); assertThat(zip).isNotNull(); @@ -1508,7 +1507,7 @@ void exportInstructorRepositories_shouldReturnFile() throws Exception { assertThat(zip).isNotNull(); } - void exportInstructorAuxiliaryRepository_shouldReturnFile() throws Exception { + public void exportInstructorAuxiliaryRepository_shouldReturnFile() throws Exception { generateProgrammingExerciseForExport(); var auxRepo = addAuxiliaryRepositoryToProgrammingExercise(exercise); setupAuxRepoMock(auxRepo); @@ -1524,7 +1523,7 @@ private void setupAuxRepoMock(AuxiliaryRepository auxiliaryRepository) throws Gi doReturn(repository).when(gitService).getOrCheckoutRepository(eq(auxiliaryRepository.getVcsRepositoryUri()), (Path) any(), anyBoolean()); } - void exportInstructorAuxiliaryRepository_forbidden() throws Exception { + public void exportInstructorAuxiliaryRepository_forbidden() throws Exception { generateProgrammingExerciseForExport(); var auxRepo = addAuxiliaryRepositoryToProgrammingExercise(exercise); var url = "/api/programming-exercises/" + exercise.getId() + "/export-instructor-auxiliary-repository/" + auxRepo.getId(); @@ -1532,7 +1531,7 @@ void exportInstructorAuxiliaryRepository_forbidden() throws Exception { } // Test - void exportInstructorRepositories_forbidden() throws Exception { + public void exportInstructorRepositories_forbidden() throws Exception { // change the group name to enforce a HttpStatus forbidden after having accessed the endpoint course.setInstructorGroupName("test"); courseRepository.save(course); @@ -1567,7 +1566,7 @@ private String exportStudentRequestedRepository(HttpStatus expectedStatus, boole * * @param authorized Whether to expect that the user is authorized. */ - void exportStudentRepository(boolean authorized) throws Exception { + public void exportStudentRepository(boolean authorized) throws Exception { HttpStatus expectedStatus = authorized ? HttpStatus.OK : HttpStatus.FORBIDDEN; generateProgrammingExerciseForExport(); var participation = createStudentParticipationWithSubmission(INDIVIDUAL); @@ -1588,7 +1587,7 @@ void exportStudentRepository(boolean authorized) throws Exception { * * @throws Exception if the export fails */ - void exportProgrammingExerciseInstructorMaterial_shouldReturnFileWithBuildplan() throws Exception { + public void exportProgrammingExerciseInstructorMaterial_shouldReturnFileWithBuildplan() throws Exception { exportProgrammingExerciseInstructorMaterial_shouldReturnFile(false, true); } @@ -1598,7 +1597,7 @@ void exportProgrammingExerciseInstructorMaterial_shouldReturnFileWithBuildplan() * @param saveEmbeddedFiles whether embedded files should be saved or not, not saving them simulates that embedded files are no longer stored on the file system * @throws Exception if the export fails */ - void exportProgrammingExerciseInstructorMaterial_shouldReturnFile(boolean saveEmbeddedFiles, boolean shouldIncludeBuildplan) throws Exception { + public void exportProgrammingExerciseInstructorMaterial_shouldReturnFile(boolean saveEmbeddedFiles, boolean shouldIncludeBuildplan) throws Exception { var zipFile = exportProgrammingExerciseInstructorMaterial(HttpStatus.OK, false, true, saveEmbeddedFiles, shouldIncludeBuildplan); // Assure, that the zip folder is already created and not 'in creation' which would lead to a failure when extracting it in the next step await().until(zipFile::exists); @@ -1643,7 +1642,7 @@ void exportProgrammingExerciseInstructorMaterial_shouldReturnFile(boolean saveEm FileUtils.delete(zipFile); } - void exportProgrammingExerciseInstructorMaterial_withTeamConfig() throws Exception { + public void exportProgrammingExerciseInstructorMaterial_withTeamConfig() throws Exception { TeamAssignmentConfig teamAssignmentConfig = new TeamAssignmentConfig(); teamAssignmentConfig.setExercise(exercise); teamAssignmentConfig.setMinTeamSize(1); @@ -1676,7 +1675,7 @@ void exportProgrammingExerciseInstructorMaterial_withTeamConfig() throws Excepti FileUtils.delete(zipFile); } - void exportProgrammingExerciseInstructorMaterial_problemStatementNull_success() throws Exception { + public void exportProgrammingExerciseInstructorMaterial_problemStatementNull_success() throws Exception { var zipFile = exportProgrammingExerciseInstructorMaterial(HttpStatus.OK, true, true, false, false); await().until(zipFile::exists); assertThat(zipFile).isNotNull(); @@ -1696,7 +1695,7 @@ void exportProgrammingExerciseInstructorMaterial_problemStatementNull_success() } // Test - void exportProgrammingExerciseInstructorMaterial_problemStatementShouldContainTestNames() throws Exception { + public void exportProgrammingExerciseInstructorMaterial_problemStatementShouldContainTestNames() throws Exception { exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig())); programmingExerciseRepository.save(exercise); var tests = programmingExerciseUtilService.addTestCasesToProgrammingExercise(exercise); @@ -1723,7 +1722,7 @@ void exportProgrammingExerciseInstructorMaterial_problemStatementShouldContainTe } // Test - void exportProgrammingExerciseInstructorMaterial_forbidden() throws Exception { + public void exportProgrammingExerciseInstructorMaterial_forbidden() throws Exception { // change the group name to enforce a HttpStatus forbidden after having accessed the endpoint course.setInstructorGroupName("test"); courseRepository.save(course); @@ -1741,7 +1740,7 @@ void exportProgrammingExerciseInstructorMaterial_forbidden() throws Exception { * @return the zip file * @throws Exception if the export fails */ - File exportProgrammingExerciseInstructorMaterial(HttpStatus expectedStatus, boolean problemStatementNull, boolean mockRepos, boolean saveEmbeddedFiles, + public File exportProgrammingExerciseInstructorMaterial(HttpStatus expectedStatus, boolean problemStatementNull, boolean mockRepos, boolean saveEmbeddedFiles, boolean shouldIncludeBuildplan) throws Exception { if (problemStatementNull) { generateProgrammingExerciseWithProblemStatementNullForExport(); @@ -1822,7 +1821,7 @@ private void setupMockRepo(LocalRepository localRepo, RepositoryType repoType, S } // Test - void testArchiveCourseWithProgrammingExercise() throws Exception { + public void testArchiveCourseWithProgrammingExercise() throws Exception { course.setEndDate(ZonedDateTime.now().minusMinutes(4)); course.setCourseArchivePath(null); course.setExercises(Set.of(exercise)); @@ -1878,19 +1877,19 @@ void testArchiveCourseWithProgrammingExercise() throws Exception { } // Test - void testExportCourseCannotExportSingleParticipationCanceledException() throws Exception { + public void testExportCourseCannotExportSingleParticipationCanceledException() throws Exception { createCourseWithProgrammingExerciseAndParticipationWithFiles(); testExportCourseWithFaultyParticipationCannotGetOrCheckoutRepository(new CanceledException("Checkout canceled")); } // Test - void testExportCourseCannotExportSingleParticipationGitApiException() throws Exception { + public void testExportCourseCannotExportSingleParticipationGitApiException() throws Exception { createCourseWithProgrammingExerciseAndParticipationWithFiles(); testExportCourseWithFaultyParticipationCannotGetOrCheckoutRepository(new InvalidRemoteException("InvalidRemoteException")); } // Test - void testExportCourseCannotExportSingleParticipationGitException() throws Exception { + public void testExportCourseCannotExportSingleParticipationGitException() throws Exception { createCourseWithProgrammingExerciseAndParticipationWithFiles(); testExportCourseWithFaultyParticipationCannotGetOrCheckoutRepository(new GitException("GitException")); } @@ -2039,7 +2038,7 @@ private void createAndCommitDummyFileInLocalRepository(LocalRepository localRepo } // Test - void testDownloadCourseArchiveAsInstructor() throws Exception { + public void testDownloadCourseArchiveAsInstructor() throws Exception { // Archive the course and wait until it's complete testArchiveCourseWithProgrammingExercise(); @@ -2099,7 +2098,7 @@ private Team setupTeam(User user) { } // TEST - void startProgrammingExerciseStudentRetrieveEmptyArtifactPage() throws Exception { + public void startProgrammingExerciseStudentRetrieveEmptyArtifactPage() throws Exception { persistProgrammingExercise(); User user = userRepo.findOneByLogin(userPrefix + STUDENT_LOGIN).orElseThrow(); mockDelegate.mockConnectorRequestsForStartParticipation(exercise, user.getParticipantIdentifier(), Set.of(user), true); @@ -2119,7 +2118,7 @@ void startProgrammingExerciseStudentRetrieveEmptyArtifactPage() throws Exception } // TEST - void repositoryAccessIsAdded_whenStudentIsAddedToTeam() throws Exception { + public void repositoryAccessIsAdded_whenStudentIsAddedToTeam() throws Exception { setupTeamExercise(); // Create a team with students @@ -2151,7 +2150,7 @@ void repositoryAccessIsAdded_whenStudentIsAddedToTeam() throws Exception { } // TEST - void repositoryAccessIsRemoved_whenStudentIsRemovedFromTeam() throws Exception { + public void repositoryAccessIsRemoved_whenStudentIsRemovedFromTeam() throws Exception { setupTeamExercise(); // Create a team with students @@ -2180,7 +2179,7 @@ void repositoryAccessIsRemoved_whenStudentIsRemovedFromTeam() throws Exception { } // TEST - void configureRepository_throwExceptionWhenLtiUserIsNotExistent() throws Exception { + public void configureRepository_throwExceptionWhenLtiUserIsNotExistent() throws Exception { setupTeamExercise(); // create a team for the user (necessary condition before starting an exercise) @@ -2203,7 +2202,7 @@ void configureRepository_throwExceptionWhenLtiUserIsNotExistent() throws Excepti } // TEST - void copyRepository_testNotCreatedError() throws Exception { + public void copyRepository_testNotCreatedError() throws Exception { Team team = setupTeamForBadRequestForStartExercise(); var participantRepoTestUrl = ParticipationFactory.getMockFileRepositoryUri(studentTeamRepo); @@ -2249,7 +2248,7 @@ private void setupTeamExercise() { } // TEST - void configureRepository_testBadRequestError() throws Exception { + public void configureRepository_testBadRequestError() throws Exception { Team team = setupTeamForBadRequestForStartExercise(); // Start participation @@ -2259,7 +2258,7 @@ void configureRepository_testBadRequestError() throws Exception { } // TEST - void automaticCleanupBuildPlans() throws Exception { + public void automaticCleanupBuildPlans() throws Exception { String testPrefix = "cleanup"; userUtilService.addUsers(userPrefix + testPrefix, 12, 0, 0, 0); @@ -2355,7 +2354,7 @@ private ProgrammingExerciseStudentParticipation createProgrammingParticipationWi } // TEST - void automaticCleanupGitRepositories() { + public void automaticCleanupGitRepositories() { var startDate = ZonedDateTime.now().minusWeeks(15L); var endDate = startDate.plusDays(5L); exercise.setReleaseDate(startDate); @@ -2436,7 +2435,7 @@ private List getChanges(Repository repository, RevCommit commit) thro } // TEST - void importProgrammingExerciseFromCourseToCourse_exampleSolutionPublicationDate() throws Exception { + public void importProgrammingExerciseFromCourseToCourse_exampleSolutionPublicationDate() throws Exception { Course course1 = courseUtilService.addEmptyCourse(); Course course2 = courseUtilService.addEmptyCourse(); @@ -2463,7 +2462,7 @@ void importProgrammingExerciseFromCourseToCourse_exampleSolutionPublicationDate( } // TEST - void createProgrammingExercise_setInvalidExampleSolutionPublicationDate_badRequest() throws Exception { + public void createProgrammingExercise_setInvalidExampleSolutionPublicationDate_badRequest() throws Exception { final var baseTime = ZonedDateTime.now(); exercise.setAssessmentDueDate(null); @@ -2484,7 +2483,7 @@ void createProgrammingExercise_setInvalidExampleSolutionPublicationDate_badReque } // TEST - void createProgrammingExercise_setValidExampleSolutionPublicationDate() throws Exception { + public void createProgrammingExercise_setValidExampleSolutionPublicationDate() throws Exception { final var baseTime = ZonedDateTime.now(); exercise.setAssessmentDueDate(null); @@ -2501,7 +2500,7 @@ void createProgrammingExercise_setValidExampleSolutionPublicationDate() throws E } // TEST - void testGetProgrammingExercise_exampleSolutionVisibility(boolean isStudent, String username) throws Exception { + public void testGetProgrammingExercise_exampleSolutionVisibility(boolean isStudent, String username) throws Exception { if (isStudent) { assertThat(username).as("The setup is done according to studentLogin value, another username may not work as expected").isEqualTo(userPrefix + STUDENT_LOGIN); @@ -2548,7 +2547,7 @@ void testGetProgrammingExercise_exampleSolutionVisibility(boolean isStudent, Str } // TEST - void exportSolutionRepository_shouldReturnFileOrForbidden() throws Exception { + public void exportSolutionRepository_shouldReturnFileOrForbidden() throws Exception { // Test example solution publication date not set. exercise.setExampleSolutionPublicationDate(null); exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig())); @@ -2581,7 +2580,7 @@ void exportSolutionRepository_shouldReturnFileOrForbidden() throws Exception { } // TEST - void exportExamSolutionRepository_shouldReturnFileOrForbidden() throws Exception { + public void exportExamSolutionRepository_shouldReturnFileOrForbidden() throws Exception { Exam exam = examExercise.getExerciseGroup().getExam(); examUtilService.addStudentExamWithUser(exam, userRepo.getUser()); exercise = examExercise; @@ -2618,7 +2617,7 @@ void exportExamSolutionRepository_shouldReturnFileOrForbidden() throws Exception } // TEST - void buildLogStatistics_unauthorized() throws Exception { + public void buildLogStatistics_unauthorized() throws Exception { exercise = ProgrammingExerciseFactory.generateProgrammingExercise(ZonedDateTime.now().minusDays(1), ZonedDateTime.now().plusDays(7), course); exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig())); exercise = programmingExerciseRepository.save(exercise); @@ -2626,7 +2625,7 @@ void buildLogStatistics_unauthorized() throws Exception { } // TEST - void buildLogStatistics_noStatistics() throws Exception { + public void buildLogStatistics_noStatistics() throws Exception { exercise = ProgrammingExerciseFactory.generateProgrammingExercise(ZonedDateTime.now().minusDays(1), ZonedDateTime.now().plusDays(7), course); exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig())); exercise = programmingExerciseRepository.save(exercise); @@ -2640,7 +2639,7 @@ void buildLogStatistics_noStatistics() throws Exception { } // TEST - void buildLogStatistics() throws Exception { + public void buildLogStatistics() throws Exception { exercise = ProgrammingExerciseFactory.generateProgrammingExercise(ZonedDateTime.now().minusDays(1), ZonedDateTime.now().plusDays(7), course); exercise.setBuildConfig(programmingExerciseBuildConfigRepository.save(exercise.getBuildConfig())); exercise = programmingExerciseRepository.save(exercise); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseUtilService.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseUtilService.java index 15c74ce9a77e..984ca2f5ae26 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingExerciseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -30,25 +30,25 @@ import de.tum.cit.aet.artemis.assessment.domain.CategoryState; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.domain.Visibility; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.ProgrammingExerciseTestRepository; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.TestConstants; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.AuxiliaryRepository; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseTestCase; @@ -67,8 +67,6 @@ import de.tum.cit.aet.artemis.programming.repository.AuxiliaryRepositoryRepository; import de.tum.cit.aet.artemis.programming.repository.BuildPlanRepository; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseTestCaseRepository; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.StaticCodeAnalysisCategoryRepository; import de.tum.cit.aet.artemis.programming.repository.SubmissionPolicyRepository; @@ -78,9 +76,9 @@ import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseSolutionEntryRepository; import de.tum.cit.aet.artemis.programming.repository.hestia.ProgrammingExerciseTaskRepository; import de.tum.cit.aet.artemis.programming.service.GitService; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.LocalRepository; -import de.tum.cit.aet.artemis.util.TestConstants; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestCaseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; /** * Service responsible for initializing the database with specific testdata related to programming exercises for use in integration tests. @@ -99,7 +97,7 @@ public class ProgrammingExerciseUtilService { private TemplateProgrammingExerciseParticipationRepository templateProgrammingExerciseParticipationRepo; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @@ -111,13 +109,13 @@ public class ProgrammingExerciseUtilService { private ExamRepository examRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired - private ProgrammingExerciseTestCaseRepository testCaseRepository; + private ProgrammingExerciseTestCaseTestRepository testCaseRepository; @Autowired private StaticCodeAnalysisCategoryRepository staticCodeAnalysisCategoryRepository; @@ -135,10 +133,10 @@ public class ProgrammingExerciseUtilService { private ProgrammingSubmissionTestRepository programmingSubmissionRepo; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired private ExerciseHintRepository exerciseHintRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionAndResultIntegrationTestService.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingSubmissionAndResultIntegrationTestService.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionAndResultIntegrationTestService.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingSubmissionAndResultIntegrationTestService.java index 91becee79787..3a53d1b77ada 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionAndResultIntegrationTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingSubmissionAndResultIntegrationTestService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; import static de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage.JAVA; import static org.assertj.core.api.Assertions.assertThat; @@ -15,15 +15,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.ProgrammingSubmissionTestRepository; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; import de.tum.cit.aet.artemis.exercise.domain.Submission; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.util.RequestUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingSubmissionTestRepository; /** * Note: this class should be independent of the actual VCS and CIS and contains common test logic for scenarios: @@ -36,7 +36,7 @@ public class ProgrammingSubmissionAndResultIntegrationTestService { private ProgrammingSubmissionTestRepository programmingSubmissionRepository; @Autowired - private ProgrammingExerciseRepository programmingExerciseRepository; + private ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired private RequestUtilService request; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionConstants.java b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingSubmissionConstants.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionConstants.java rename to src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingSubmissionConstants.java index ec3f964a40bc..72f10e0887f8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/programming/ProgrammingSubmissionConstants.java +++ b/src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingSubmissionConstants.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.programming; +package de.tum.cit.aet.artemis.programming.util; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizComparisonTest.java b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizComparisonTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizComparisonTest.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/QuizComparisonTest.java index 2cc6c432b9ae..c06a75db6efe 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizComparisonTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizComparisonTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.quiz; +package de.tum.cit.aet.artemis.quiz; import static de.tum.cit.aet.artemis.exam.service.StudentExamService.isContentEqualTo; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -14,10 +14,10 @@ import org.junit.jupiter.api.Test; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.domain.Exam; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; import de.tum.cit.aet.artemis.quiz.domain.AnswerOption; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropMapping; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; @@ -36,6 +36,7 @@ import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSubmittedText; import de.tum.cit.aet.artemis.quiz.domain.compare.DnDMapping; import de.tum.cit.aet.artemis.quiz.domain.compare.SAMapping; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; class QuizComparisonTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java index 36e6bdf7bd6e..b11c688358fa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.quiz; +package de.tum.cit.aet.artemis.quiz; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.byLessThan; @@ -41,25 +41,26 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.dto.SearchResultPageDTO; import de.tum.cit.aet.artemis.core.security.SecurityUtils; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.TeamAssignmentConfig; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; import de.tum.cit.aet.artemis.exercise.service.ExerciseService; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseIntegrationTestService; import de.tum.cit.aet.artemis.quiz.domain.AnswerOption; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestionStatistic; @@ -80,12 +81,13 @@ import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSolution; import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSpot; import de.tum.cit.aet.artemis.quiz.dto.QuizBatchJoinDTO; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; -import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; import de.tum.cit.aet.artemis.quiz.repository.SubmittedAnswerRepository; import de.tum.cit.aet.artemis.quiz.service.QuizExerciseService; -import de.tum.cit.aet.artemis.util.ExerciseIntegrationTestService; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizSubmissionTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; class QuizExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -97,13 +99,13 @@ class QuizExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTe private QuizExerciseService quizExerciseService; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseTestRepository; @Autowired - private QuizSubmissionRepository quizSubmissionRepository; + private QuizSubmissionTestRepository quizSubmissionTestRepository; @Autowired private SubmittedAnswerRepository submittedAnswerRepository; @@ -479,9 +481,9 @@ private void addFilesToBuilderAndModifyExercise(MockMultipartHttpServletRequestB void testDeleteQuizExercise(QuizMode quizMode) throws Exception { QuizExercise quizExercise = quizExerciseUtilService.createAndSaveQuiz(ZonedDateTime.now().plusHours(5), null, quizMode); - assertThat(quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is created correctly").isNotNull(); + assertThat(quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is created correctly").isNotNull(); request.delete("/api/quiz-exercises/" + quizExercise.getId(), OK); - assertThat(quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is deleted correctly").isNull(); + assertThat(quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is deleted correctly").isNull(); } @Test @@ -502,7 +504,7 @@ void testDeleteQuizExerciseWithChannel() throws Exception { @EnumSource(QuizMode.class) void testDeleteQuizExerciseWithSubmittedAnswers(QuizMode quizMode) throws Exception { QuizExercise quizExercise = quizExerciseUtilService.createAndSaveQuiz(ZonedDateTime.now(), ZonedDateTime.now().plusMinutes(1), quizMode); - assertThat(quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is created correctly").isNotNull(); + assertThat(quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is created correctly").isNotNull(); QuizSubmission quizSubmission = QuizExerciseFactory.generateSubmissionForThreeQuestions(quizExercise, 1, true, null); quizSubmission.submitted(true); @@ -510,10 +512,10 @@ void testDeleteQuizExerciseWithSubmittedAnswers(QuizMode quizMode) throws Except participationUtilService.addResultToSubmission(quizSubmission, AssessmentType.AUTOMATIC, null, quizExercise.getScoreForSubmission(quizSubmission), true); // Quiz submissions are now in database - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExercise.getId())).hasSize(1); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExercise.getId())).hasSize(1); request.delete("/api/quiz-exercises/" + quizExercise.getId(), OK); - assertThat(quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is deleted correctly").isNull(); + assertThat(quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId())).as("Exercise is deleted correctly").isNull(); } @Test @@ -755,7 +757,7 @@ void testReevaluateStatistics() throws Exception { assertThat(studentParticipationRepository.findByExerciseId(quizExercise.getId())).hasSize(numberOfParticipants); assertThat(resultRepository.findAllByParticipationExerciseId(quizExercise.getId())).hasSize(numberOfParticipants); - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExercise.getId())).hasSize(numberOfParticipants); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExercise.getId())).hasSize(numberOfParticipants); assertThat(submittedAnswerRepository.findBySubmission(quizSubmission)).hasSize(3); // calculate statistics @@ -1244,7 +1246,7 @@ void importQuizExerciseToSameCourse() throws Exception { new MockMultipartFile("files", "dragItemImage4.png", MediaType.IMAGE_PNG_VALUE, "dragItemImage".getBytes()))); quizExerciseService.save(quizExercise); - QuizExercise changedQuiz = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + QuizExercise changedQuiz = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(changedQuiz).isNotNull(); changedQuiz.setTitle("New title"); changedQuiz.setReleaseDate(now); @@ -1390,7 +1392,7 @@ void testImportQuizExercise_team_modeChange() throws Exception { new MockMultipartFile("files", "dragItemImage4.png", MediaType.IMAGE_PNG_VALUE, "dragItemImage".getBytes()))); quizExerciseService.save(quizExercise); - QuizExercise changedQuiz = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + QuizExercise changedQuiz = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(changedQuiz).isNotNull(); Course course = courseUtilService.addEmptyCourse(); @@ -1405,7 +1407,7 @@ void testImportQuizExercise_team_modeChange() throws Exception { assertThat(changedQuiz.getTeamAssignmentConfig().getMaxTeamSize()).isEqualTo(10); assertThat(teamRepository.findAllByExerciseIdWithEagerStudents(changedQuiz, null)).isEmpty(); - quizExercise = quizExerciseRepository.findByIdElseThrow(quizExercise.getId()); + quizExercise = quizExerciseTestRepository.findByIdElseThrow(quizExercise.getId()); assertThat(quizExercise.getMode()).isEqualTo(ExerciseMode.INDIVIDUAL); assertThat(quizExercise.getTeamAssignmentConfig()).isNull(); @@ -1435,7 +1437,7 @@ void testImportQuizExercise_individual_modeChange() throws Exception { team.setShortName(TEST_PREFIX + "testImportQuizExercise_individual_modeChange"); teamRepository.save(quizExercise, team); - QuizExercise changedQuiz = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + QuizExercise changedQuiz = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(changedQuiz).isNotNull(); changedQuiz.setMode(ExerciseMode.INDIVIDUAL); @@ -1449,7 +1451,7 @@ void testImportQuizExercise_individual_modeChange() throws Exception { assertThat(changedQuiz.getTeamAssignmentConfig()).isNull(); assertThat(teamRepository.findAllByExerciseIdWithEagerStudents(changedQuiz, null)).isEmpty(); - quizExercise = quizExerciseRepository.findByIdElseThrow(quizExercise.getId()); + quizExercise = quizExerciseTestRepository.findByIdElseThrow(quizExercise.getId()); assertThat(quizExercise.getMode()).isEqualTo(ExerciseMode.TEAM); assertThat(teamRepository.findAllByExerciseIdWithEagerStudents(quizExercise, null)).hasSize(1); } @@ -1466,7 +1468,7 @@ void testImportQuizExerciseChangeQuizMode() throws Exception { new MockMultipartFile("files", "dragItemImage4.png", MediaType.IMAGE_PNG_VALUE, "dragItemImage".getBytes()))); quizExerciseService.save(quizExercise); - QuizExercise changedQuiz = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + QuizExercise changedQuiz = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(changedQuiz).isNotNull(); changedQuiz.setQuizMode(QuizMode.INDIVIDUAL); @@ -1570,7 +1572,7 @@ void testReset() throws Exception { } request.delete("/api/exercises/" + quizExercise.getId() + "/reset", OK); - quizExercise = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + quizExercise = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(quizExercise).isNotNull(); assertThat(quizExercise.isIsOpenForPractice()).as("Quiz Question is open for practice has been set to false").isFalse(); assertThat(quizExercise.getReleaseDate()).as("Quiz Question is released").isBeforeOrEqualTo(ZonedDateTime.now()); @@ -1653,7 +1655,7 @@ private QuizExercise createQuizOnServer(ZonedDateTime releaseDate, ZonedDateTime quizExercise.setDuration(3600); QuizExercise quizExerciseServer = createQuizExerciseWithFiles(quizExercise, HttpStatus.CREATED, true); - QuizExercise quizExerciseDatabase = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExerciseServer.getId()); + QuizExercise quizExerciseDatabase = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExerciseServer.getId()); assertThat(quizExerciseServer).isNotNull(); assertThat(quizExerciseDatabase).isNotNull(); @@ -1686,7 +1688,7 @@ private QuizExercise createQuizOnServerForExam() throws Exception { quizExercise.setDuration(3600); QuizExercise quizExerciseServer = createQuizExerciseWithFiles(quizExercise, HttpStatus.CREATED, true); - QuizExercise quizExerciseDatabase = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExerciseServer.getId()); + QuizExercise quizExerciseDatabase = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExerciseServer.getId()); assertThat(quizExerciseServer).isNotNull(); assertThat(quizExerciseDatabase).isNotNull(); diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizSubmissionIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java index 95b58dce37ef..5a56c62d5273 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizSubmissionIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.quiz; +package de.tum.cit.aet.artemis.quiz; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -33,17 +33,16 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.web.multipart.MultipartFile; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.quiz.domain.AnswerOption; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropMapping; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; @@ -64,11 +63,14 @@ import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSubmittedText; import de.tum.cit.aet.artemis.quiz.domain.SubmittedAnswer; import de.tum.cit.aet.artemis.quiz.dto.QuizBatchJoinDTO; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; -import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; import de.tum.cit.aet.artemis.quiz.service.QuizBatchService; import de.tum.cit.aet.artemis.quiz.service.QuizExerciseService; import de.tum.cit.aet.artemis.quiz.service.QuizStatisticService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizSubmissionTestRepository; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseFactory; +import de.tum.cit.aet.artemis.quiz.util.QuizExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; class QuizSubmissionIntegrationTest extends AbstractSpringIntegrationLocalCILocalVCTest { @@ -84,16 +86,16 @@ class QuizSubmissionIntegrationTest extends AbstractSpringIntegrationLocalCILoca private QuizExerciseService quizExerciseService; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseTestRepository; @Autowired - private QuizSubmissionRepository quizSubmissionRepository; + private QuizSubmissionTestRepository quizSubmissionTestRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired private QuizBatchService quizBatchService; @@ -151,7 +153,7 @@ void testQuizSubmit_CalculateScore() { assertThat(submissionRepository.countByExerciseIdSubmitted(quizExercise.getId())).isEqualTo(NUMBER_OF_STUDENTS); // update the statistics - QuizExercise quizExerciseWithStatistic = quizExerciseRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); + QuizExercise quizExerciseWithStatistic = quizExerciseTestRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); quizStatisticService.recalculateStatistics(quizExerciseWithStatistic); // Test the statistics @@ -263,7 +265,7 @@ void testQuizSubmit_partial_points() { } // update the statistics - QuizExercise quizExerciseWithStatistic = quizExerciseRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); + QuizExercise quizExerciseWithStatistic = quizExerciseTestRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); quizStatisticService.recalculateStatistics(quizExerciseWithStatistic); var quizPointStatistic = quizExerciseWithStatistic.getQuizPointStatistic(); @@ -324,7 +326,7 @@ void testQuizSubmitPractice(QuizMode quizMode) throws Exception { quizExerciseService.save(quizExercise); // at the beginning there are no submissions and participants - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExercise.getId())).isEmpty(); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExercise.getId())).isEmpty(); assertThat(participationRepository.findByExerciseId(quizExercise.getId())).isEmpty(); // submit 10 times for 10 different students @@ -337,11 +339,11 @@ void testQuizSubmitPractice(QuizMode quizMode) throws Exception { } // all submission are saved to the database - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExercise.getId())).hasSize(NUMBER_OF_STUDENTS); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExercise.getId())).hasSize(NUMBER_OF_STUDENTS); assertThat(participationRepository.findByExerciseId(quizExercise.getId())).hasSize(NUMBER_OF_STUDENTS); // update the statistics - QuizExercise quizExerciseWithStatistic = quizExerciseRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); + QuizExercise quizExerciseWithStatistic = quizExerciseTestRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); quizStatisticService.recalculateStatistics(quizExerciseWithStatistic); // Test the statistics @@ -395,7 +397,7 @@ void testQuizSubmitPractice_badRequest() throws Exception { quizExerciseServer.setIsOpenForPractice(false); quizExerciseService.save(quizExerciseServer); - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExerciseServer.getId())).isEmpty(); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExerciseServer.getId())).isEmpty(); QuizSubmission quizSubmission = new QuizSubmission(); for (var question : quizExerciseServer.getQuizQuestions()) { @@ -422,7 +424,7 @@ void testQuizSubmitPractice_badRequest_exam() throws Exception { QuizExercise quizExerciseServer = QuizExerciseFactory.createQuizForExam(exerciseGroup); quizExerciseService.save(quizExerciseServer); - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExerciseServer.getId())).isEmpty(); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExerciseServer.getId())).isEmpty(); QuizSubmission quizSubmission = QuizExerciseFactory.generateSubmissionForThreeQuestions(quizExerciseServer, 1, true, null); // exam quiz not open for practice --> bad request expected @@ -512,10 +514,10 @@ void testQuizSubmitPreview(QuizMode quizMode) throws Exception { } // in the preview the submission will not be saved to the database - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExercise.getId())).isEmpty(); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExercise.getId())).isEmpty(); // update the statistics - QuizExercise quizExerciseWithStatistic = quizExerciseRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); + QuizExercise quizExerciseWithStatistic = quizExerciseTestRepository.findByIdWithQuestionsAndStatisticsElseThrow(quizExercise.getId()); quizStatisticService.recalculateStatistics(quizExerciseWithStatistic); // all stats must be 0 because we have a preview here @@ -582,7 +584,7 @@ void testQuizSubmitScheduledAndDeleted() throws Exception { // set the quiz end to now and ... log.debug("// End the quiz and delete it"); - quizExercise = quizExerciseRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); + quizExercise = quizExerciseTestRepository.findOneWithQuestionsAndStatistics(quizExercise.getId()); assertThat(quizExercise).isNotNull(); quizExercise.setDuration((int) Duration.between(quizExercise.getReleaseDate(), ZonedDateTime.now()).getSeconds() - Constants.QUIZ_GRACE_PERIOD_IN_SECONDS); quizExercise = exerciseRepository.saveAndFlush(quizExercise); @@ -614,7 +616,7 @@ void testQuizScoringTypes() throws IOException { participationUtilService.addResultToSubmission(quizSubmission, AssessmentType.AUTOMATIC, null, quizExercise.getScoreForSubmission(quizSubmission), true); quizExerciseService.reEvaluate(quizExercise, quizExercise, generateMultipartFilesFromQuizExercise(quizExercise)); - assertThat(quizSubmissionRepository.findByQuizExerciseId(quizExercise.getId())).isPresent(); + assertThat(quizSubmissionTestRepository.findByQuizExerciseId(quizExercise.getId())).isPresent(); List results = resultRepository.findByParticipationExerciseIdOrderByCompletionDateAsc(quizExercise.getId()); assertThat(results).hasSize(1); @@ -622,7 +624,7 @@ void testQuizScoringTypes() throws IOException { assertThat(result.getScore()).isEqualTo(11.1); - quizSubmission = quizSubmissionRepository.findWithEagerSubmittedAnswersById(result.getSubmission().getId()); + quizSubmission = quizSubmissionTestRepository.findWithEagerSubmittedAnswersById(result.getSubmission().getId()); for (SubmittedAnswer submittedAnswer : quizSubmission.getSubmittedAnswers()) { // MC submitted answers 0 points as one correct and one false -> ALL_OR_NOTHING // or @@ -768,7 +770,7 @@ void testQuizSubmitLiveMode(QuizMode quizMode) throws Exception { quizExercise = quizExerciseService.save(quizExercise); // at the beginning there are no submissions and no participants - assertThat(quizSubmissionRepository.findByParticipation_Exercise_Id(quizExercise.getId())).isEmpty(); + assertThat(quizSubmissionTestRepository.findByParticipation_Exercise_Id(quizExercise.getId())).isEmpty(); assertThat(participationRepository.findByExerciseId(quizExercise.getId())).isEmpty(); request.postWithResponseBody("/api/quiz-exercises/" + quizExercise.getId() + "/start-participation", null, StudentParticipation.class, HttpStatus.OK); diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/ShortAnswerQuestionTest.java b/src/test/java/de/tum/cit/aet/artemis/quiz/ShortAnswerQuestionTest.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/domain/ShortAnswerQuestionTest.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/ShortAnswerQuestionTest.java index faa696137306..93c6c03d71bb 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/ShortAnswerQuestionTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/ShortAnswerQuestionTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.quiz; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/ShortAnswerSubmittedTextTest.java b/src/test/java/de/tum/cit/aet/artemis/quiz/ShortAnswerSubmittedTextTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/domain/ShortAnswerSubmittedTextTest.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/ShortAnswerSubmittedTextTest.java index 9368b6b0e1cb..ece5f58e9d77 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/ShortAnswerSubmittedTextTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/ShortAnswerSubmittedTextTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.quiz; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/de/tum/cit/aet/artemis/quiz/test_repository/QuizExerciseTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/quiz/test_repository/QuizExerciseTestRepository.java new file mode 100644 index 000000000000..7450be8bff51 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/test_repository/QuizExerciseTestRepository.java @@ -0,0 +1,25 @@ +package de.tum.cit.aet.artemis.quiz.test_repository; + +import jakarta.annotation.Nullable; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.quiz.domain.QuizExercise; +import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; + +@Repository +@Primary +public interface QuizExerciseTestRepository extends QuizExerciseRepository { + + /** + * Get one quiz exercise by id and eagerly load questions and statistics + * + * @param quizExerciseId the id of the entity + * @return the quiz exercise entity + */ + @Nullable + default QuizExercise findOneWithQuestionsAndStatistics(Long quizExerciseId) { + return findWithEagerQuestionsAndStatisticsById(quizExerciseId).orElse(null); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/quiz/test_repository/QuizSubmissionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/quiz/test_repository/QuizSubmissionTestRepository.java new file mode 100644 index 000000000000..25405c20623d --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/test_repository/QuizSubmissionTestRepository.java @@ -0,0 +1,28 @@ +package de.tum.cit.aet.artemis.quiz.test_repository; + +import java.util.Optional; +import java.util.Set; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.quiz.domain.QuizSubmission; +import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; + +@Repository +@Primary +public interface QuizSubmissionTestRepository extends QuizSubmissionRepository { + + Set findByParticipation_Exercise_Id(long exerciseId); + + @Query(""" + SELECT submission + FROM QuizSubmission submission + JOIN submission.participation participation + JOIN participation.exercise exercise + WHERE exercise.id = :quizExerciseId + """) + Optional findByQuizExerciseId(@Param("quizExerciseId") long quizExerciseId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseFactory.java b/src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java index 21f4119ea8bd..0716df3ea73d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.quiz; +package de.tum.cit.aet.artemis.quiz.util; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; @@ -17,8 +17,8 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.service.FilePathService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.ExerciseFactory; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.util.ExerciseFactory; import de.tum.cit.aet.artemis.quiz.domain.AnswerOption; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropMapping; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseUtilService.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseUtilService.java index daba9493edea..261ac6f912b0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/quiz/QuizExerciseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/util/QuizExerciseUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.quiz; +package de.tum.cit.aet.artemis.quiz.util; import static org.assertj.core.api.Assertions.assertThat; @@ -16,23 +16,24 @@ import org.springframework.util.ResourceUtils; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; import de.tum.cit.aet.artemis.core.service.FilePathService; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.course.CourseUtilService; -import de.tum.cit.aet.artemis.exam.ExamFactory; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; +import de.tum.cit.aet.artemis.exam.util.ExamFactory; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.SubmissionType; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.TeamAssignmentConfig; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropMapping; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropQuestion; import de.tum.cit.aet.artemis.quiz.domain.DragAndDropSubmittedAnswer; @@ -47,12 +48,11 @@ import de.tum.cit.aet.artemis.quiz.domain.ShortAnswerSubmittedText; import de.tum.cit.aet.artemis.quiz.repository.DragAndDropMappingRepository; import de.tum.cit.aet.artemis.quiz.repository.QuizBatchRepository; -import de.tum.cit.aet.artemis.quiz.repository.QuizExerciseRepository; import de.tum.cit.aet.artemis.quiz.repository.QuizQuestionRepository; -import de.tum.cit.aet.artemis.quiz.repository.QuizSubmissionRepository; import de.tum.cit.aet.artemis.quiz.repository.SubmittedAnswerRepository; import de.tum.cit.aet.artemis.quiz.service.QuizScheduleService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; +import de.tum.cit.aet.artemis.quiz.test_repository.QuizSubmissionTestRepository; /** * Service responsible for initializing the database with specific testdata related to quiz exercises for use in integration tests. @@ -67,16 +67,16 @@ public class QuizExerciseUtilService { private static final ZonedDateTime FUTURE_FUTURE_TIMESTAMP = ZonedDateTime.now().plusDays(2); @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired private ExerciseRepository exerciseRepo; @Autowired - private QuizSubmissionRepository quizSubmissionRepository; + private QuizSubmissionTestRepository quizSubmissionRepository; @Autowired - private QuizExerciseRepository quizExerciseRepository; + private QuizExerciseTestRepository quizExerciseRepository; @Autowired private TeamRepository teamRepo; @@ -103,7 +103,7 @@ public class QuizExerciseUtilService { private QuizQuestionRepository quizQuestionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private UserUtilService userUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/ObjectMethodTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/ObjectMethodTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/domain/ObjectMethodTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/ObjectMethodTest.java index e6077c2d3a5e..55c9b29af5f6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/ObjectMethodTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/ObjectMethodTest.java @@ -1,14 +1,14 @@ -package de.tum.cit.aet.artemis.domain; - -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.ALL_TESTS; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.ENUM_TOSTRING_NAME_EQUALITY; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.ID_EQUALS; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.ID_GET_AND_SET; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.ID_HASHCODE; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.ID_RELATED_TESTS; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.INSTANCE_TESTS; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.isClassExcludedFrom; -import static de.tum.cit.aet.artemis.domain.ObjectMethodTestExclusions.isClassNotExcludedFrom; +package de.tum.cit.aet.artemis.shared; + +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.ALL_TESTS; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.ENUM_TOSTRING_NAME_EQUALITY; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.ID_EQUALS; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.ID_GET_AND_SET; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.ID_HASHCODE; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.ID_RELATED_TESTS; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.INSTANCE_TESTS; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.isClassExcludedFrom; +import static de.tum.cit.aet.artemis.shared.ObjectMethodTestExclusions.isClassNotExcludedFrom; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatNoException; import static org.assertj.core.api.AssertionsForClassTypes.fail; @@ -29,9 +29,9 @@ import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; import de.tum.cit.aet.artemis.programming.domain.ide.UserIdeMapping; -import de.tum.cit.aet.artemis.util.classpath.ClassNode; -import de.tum.cit.aet.artemis.util.classpath.ClassPathNode; -import de.tum.cit.aet.artemis.util.classpath.ClassPathUtil; +import de.tum.cit.aet.artemis.shared.architecture.util.ClassNode; +import de.tum.cit.aet.artemis.shared.architecture.util.ClassPathNode; +import de.tum.cit.aet.artemis.shared.architecture.util.ClassPathUtil; import io.github.classgraph.ClassInfo; /** diff --git a/src/test/java/de/tum/cit/aet/artemis/domain/ObjectMethodTestExclusions.java b/src/test/java/de/tum/cit/aet/artemis/shared/ObjectMethodTestExclusions.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/domain/ObjectMethodTestExclusions.java rename to src/test/java/de/tum/cit/aet/artemis/shared/ObjectMethodTestExclusions.java index 8a6db18d47f6..e504e068f0d6 100644 --- a/src/test/java/de/tum/cit/aet/artemis/domain/ObjectMethodTestExclusions.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/ObjectMethodTestExclusions.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.domain; +package de.tum.cit.aet.artemis.shared; import java.util.EnumSet; import java.util.List; diff --git a/src/test/java/de/tum/cit/aet/artemis/shared/TestRepositoryConfiguration.java b/src/test/java/de/tum/cit/aet/artemis/shared/TestRepositoryConfiguration.java new file mode 100644 index 000000000000..c5a605642d8e --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/shared/TestRepositoryConfiguration.java @@ -0,0 +1,27 @@ +package de.tum.cit.aet.artemis.shared; + +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import de.tum.cit.aet.artemis.core.repository.base.RepositoryImpl; + +/** + * Test configuration to enable JPA repositories for the respective test-only repositories. + * This configuration is used to not rely on the scanned package paths in the main application + * {@link de.tum.cit.aet.artemis.core.config.DatabaseConfiguration}. + *
+ * Important* You need to annotate every TestRepository with {@link org.springframework.context.annotation.Primary} + * to override the production repository beans. + */ +@TestConfiguration +@EnableJpaRepositories(basePackages = { "de.tum.cit.aet.artemis.assessment.test_repository", "de.tum.cit.aet.artemis.atlas.test_repository", + "de.tum.cit.aet.artemis.communication.test_repository", "de.tum.cit.aet.artemis.core.test_repository", "de.tum.cit.aet.artemis.exam.test_repository", + "de.tum.cit.aet.artemis.exercise.test_repository", "de.tum.cit.aet.artemis.lecture.test_repository", "de.tum.cit.aet.artemis.lti.test_repository", + "de.tum.cit.aet.artemis.modeling.test_repository", "de.tum.cit.aet.artemis.programming.test_repository", "de.tum.cit.aet.artemis.quiz.test_repository", + "de.tum.cit.aet.artemis.text.test_repository", "de.tum.cit.aet.artemis.tutorialgroups.test_repository" }, repositoryBaseClass = RepositoryImpl.class) +@EnableJpaAuditing(auditorAwareRef = "springSecurityAuditorAware") +@EnableTransactionManagement +public class TestRepositoryConfiguration { +} diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/AbstractArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/AbstractArchitectureTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/architecture/AbstractArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/AbstractArchitectureTest.java index 206384351d9c..17b0e435b831 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/AbstractArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/AbstractArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.base.DescribedPredicate.equalTo; import static com.tngtech.archunit.base.DescribedPredicate.not; diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/ArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/ArchitectureTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/architecture/ArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/ArchitectureTest.java index 302e18788eec..424f5e68b6ac 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/ArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/ArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.base.DescribedPredicate.and; import static com.tngtech.archunit.base.DescribedPredicate.not; @@ -71,13 +71,13 @@ import com.tngtech.archunit.lang.SimpleConditionEvent; import com.tngtech.archunit.library.GeneralCodingRules; -import de.tum.cit.aet.artemis.AbstractArtemisIntegrationTest; -import de.tum.cit.aet.artemis.authorization.AuthorizationTestService; import de.tum.cit.aet.artemis.communication.service.WebsocketMessagingService; +import de.tum.cit.aet.artemis.core.authorization.AuthorizationTestService; import de.tum.cit.aet.artemis.core.config.ApplicationConfiguration; import de.tum.cit.aet.artemis.core.config.ConditionalMetricsExclusionConfiguration; import de.tum.cit.aet.artemis.programming.service.GitService; import de.tum.cit.aet.artemis.programming.web.repository.RepositoryResource; +import de.tum.cit.aet.artemis.shared.base.AbstractArtemisIntegrationTest; /** * This class contains architecture tests that apply for the whole project. diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/EnforceRoleInResourceArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/EnforceRoleInResourceArchitectureTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/architecture/EnforceRoleInResourceArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/EnforceRoleInResourceArchitectureTest.java index b2bee939a393..2a7424108144 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/EnforceRoleInResourceArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/EnforceRoleInResourceArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.lang.SimpleConditionEvent.violated; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods; diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/FeedbackArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/FeedbackArchitectureTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/architecture/FeedbackArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/FeedbackArchitectureTest.java index 9bd71d8ca7e8..d39c9fbf67ce 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/FeedbackArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/FeedbackArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.base.DescribedPredicate.not; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.assignableFrom; @@ -29,7 +29,7 @@ void testGetLongFeedbackTextNotUsed() { // internal usage for the Feedback and its tests okay, the service needs it for Hibernate lazy initialisation checks final JavaClasses classesToCheck = allClasses - .that(are(not(assignableFrom(Feedback.class).or(assignableFrom("de.tum.cit.aet.artemis.domain.FeedbackTest")).or(assignableFrom(FeedbackService.class))))); + .that(are(not(assignableFrom(Feedback.class).or(assignableFrom("de.tum.cit.aet.artemis.assessment.FeedbackTest")).or(assignableFrom(FeedbackService.class))))); getLongFeedbackTextUsage.check(classesToCheck); } diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/RepositoryArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/RepositoryArchitectureTest.java similarity index 55% rename from src/test/java/de/tum/cit/aet/artemis/architecture/RepositoryArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/RepositoryArchitectureTest.java index a0eef2d483cb..91355aa292ca 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/RepositoryArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/RepositoryArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.base.DescribedPredicate.and; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.INTERFACES; @@ -15,9 +15,11 @@ import java.util.Optional; import java.util.Set; import java.util.function.Supplier; +import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; @@ -26,8 +28,11 @@ import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; +import com.tngtech.archunit.base.DescribedPredicate; +import com.tngtech.archunit.core.domain.JavaClass; +import com.tngtech.archunit.core.domain.JavaField; import com.tngtech.archunit.core.domain.JavaMethod; -import com.tngtech.archunit.core.domain.JavaMethodCall; +import com.tngtech.archunit.core.domain.JavaType; import com.tngtech.archunit.lang.ArchCondition; import com.tngtech.archunit.lang.ArchRule; import com.tngtech.archunit.lang.ConditionEvents; @@ -90,18 +95,18 @@ public void check(JavaMethod item, ConditionEvents events) { @Test void testNoUnusedRepositoryMethods() { - ArchRule unusedMethods = noMethods().that().areAnnotatedWith(Query.class).and().areDeclaredInClassesThat().areInterfaces().and().areDeclaredInClassesThat() - .areAnnotatedWith(Repository.class).should(new ArchCondition<>("not be referenced") { + ArchRule unusedMethods = noMethods().that().areDeclaredInClassesThat().areInterfaces().and().areDeclaredInClassesThat().areAnnotatedWith(Repository.class) + .should(new ArchCondition<>("not be referenced") { @Override public void check(JavaMethod javaMethod, ConditionEvents conditionEvents) { - Set calls = javaMethod.getCallsOfSelf(); + var calls = javaMethod.getAccessesToSelf(); if (calls.isEmpty()) { conditionEvents.add(SimpleConditionEvent.violated(javaMethod, "Method is not used")); } } }).because("unused methods should be removed from repositories to keep a clean code base."); - unusedMethods.check(productionClasses); + unusedMethods.check(allClasses); } @Test @@ -160,4 +165,110 @@ void orElseThrowShouldNotBeCalled() { .callMethod(Optional.class, "orElseThrow", Supplier.class).because("ArtemisJpaRepository offers the method getValueElseThrow for this use case").check(allClasses); } + + @Test + void usedInProductionCode() { + var excludedMethods = Set.of("de.tum.cit.aet.artemis.core.repository.CustomAuditEventRepository.find(java.lang.String, java.time.Instant, java.lang.String)"); + methods().that().areDeclaredInClassesThat().areAnnotatedWith(Repository.class).and().areDeclaredInClassesThat(new DescribedPredicate<>("") { + + @Override + public boolean test(JavaClass javaClass) { + return productionClasses.contain(javaClass.getName()); + } + }).should(new ArchCondition<>("be used by production code") { + + @Override + public void check(JavaMethod javaMethod, ConditionEvents conditionEvents) { + if (excludedMethods.contains(javaMethod.getFullName())) { + return; + } + + var calls = javaMethod.getAccessesToSelf(); + var productionCalls = calls.stream().filter(call -> productionClasses.contain(call.getOriginOwner().getName())).collect(Collectors.toSet()); + if (productionCalls.isEmpty() && !calls.isEmpty()) { + conditionEvents.add(SimpleConditionEvent.violated(javaMethod, "Method " + javaMethod.getFullName() + " is not used in production code")); + } + } + }).because("methods that are not used in production code should be moved to test repositories").check(allClasses); + } + + @Test + void enforcePrimaryBeanAnnotationOnTestRepositories() { + classes().that().resideInAPackage("..test_repository..").should().beAnnotatedWith(Primary.class) + .because("Test repositories should be annotated with @Primary to override the production repository beans").check(testClasses); + } + + @Test + void enforceUsageOfTestRepository() { + classes().should(notUseRepositoriesWithSubclasses()).because("Test Repositories should be used over production repositories, if such a repository exist.") + .check(testClasses); + } + + @Test + void enforceStructureOfTestRepositories() { + var excludedRepositories = Set.of("de.tum.cit.aet.artemis.lti.test_repository.OnlineCourseConfigurationTestRepository"); // OnlineCourseConfigurationTestRepository does not + // have an accompanying production repository + classes().that().resideInAPackage("..test_repository..").should().beInterfaces().andShould().beAssignableTo(JpaRepository.class) + .andShould(new ArchCondition<>("extend a repository from production code with matching name excluding last 'Test'") { + + @Override + public void check(JavaClass javaClass, ConditionEvents events) { + if (excludedRepositories.contains(javaClass.getName())) { + return; + } + String testClassName = javaClass.getSimpleName(); + String productionClassName = replaceLast(testClassName, "Test", ""); + boolean matchesProductionClass = productionClasses.stream().anyMatch(productionClass -> productionClass.getSimpleName().equals(productionClassName)); + if (!matchesProductionClass) { + events.add(SimpleConditionEvent.violated(javaClass, "Test repository " + testClassName + " does not match any production repository class name")); + } + var interfaces = javaClass.getRawInterfaces().stream().map(JavaClass::getSimpleName).collect(Collectors.toSet()); + if (!interfaces.contains(productionClassName)) { + events.add( + SimpleConditionEvent.violated(javaClass, "Test repository " + testClassName + " does not extend production repository " + productionClassName)); + } + } + }).check(testClasses); + } + + // Utility method to replace the last occurrence of a substring + private String replaceLast(String string, String substring, String replacement) { + int lastIndex = string.lastIndexOf(substring); + if (lastIndex == -1) { + return string; + } + StringBuilder sb = new StringBuilder(string); + sb.replace(lastIndex, lastIndex + substring.length(), replacement); + return sb.toString(); + } + + private ArchCondition notUseRepositoriesWithSubclasses() { + return new ArchCondition<>("not use repositories with subclasses") { + + @Override + public void check(JavaClass testClass, ConditionEvents events) { + for (JavaField field : testClass.getAllFields()) { + JavaType fieldType = field.getRawType(); + + if (isRepository(fieldType)) { + JavaClass repositoryClass = fieldType.toErasure(); + + if (!repositoryClass.getSubclasses().isEmpty()) { + String message = String.format("Test class %s uses repository %s which has subclasses: %s", testClass.getName(), repositoryClass.getName(), + repositoryClass.getSubclasses()); + events.add(SimpleConditionEvent.violated(testClass, message)); + } + } + } + } + + private boolean isRepository(JavaType javaType) { + JavaClass javaClass = javaType.toErasure(); + // Check if the type is a repository by seeing if it implements JpaRepository + return javaClass.isAssignableTo(JpaRepository.class); + // Alternatively, if your repositories are in a specific package, you can use: + // return javaClass.getPackageName().startsWith("com.yourapp.repositories"); + } + }; + } } diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/ResourceArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/ResourceArchitectureTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/architecture/ResourceArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/ResourceArchitectureTest.java index 44d348678d91..a098dbde4535 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/ResourceArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/ResourceArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.lang.ConditionEvent.createMessage; import static com.tngtech.archunit.lang.SimpleConditionEvent.violated; diff --git a/src/test/java/de/tum/cit/aet/artemis/architecture/ServiceArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/ServiceArchitectureTest.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/architecture/ServiceArchitectureTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/ServiceArchitectureTest.java index 80ebc5e038f3..32d955cc8a32 100644 --- a/src/test/java/de/tum/cit/aet/artemis/architecture/ServiceArchitectureTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/ServiceArchitectureTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.architecture; +package de.tum.cit.aet.artemis.shared.architecture; import static com.tngtech.archunit.core.domain.JavaModifier.ABSTRACT; import static com.tngtech.archunit.core.domain.JavaModifier.FINAL; @@ -53,7 +53,7 @@ void testNoWrongServiceImports() { @Test void testCorrectServiceAnnotation() { - classes().that().resideInAPackage("de.tum.cit.aet.artemis.service..").and().haveSimpleNameEndingWith("Service").and().areNotInterfaces().and().doNotHaveModifier(ABSTRACT) + classes().that().resideInAPackage("de.tum.cit.aet.artemis.*.service..").and().haveSimpleNameEndingWith("Service").and().areNotInterfaces().and().doNotHaveModifier(ABSTRACT) .should().beAnnotatedWith(org.springframework.stereotype.Service.class) .because("services should be consistently managed by Spring's dependency injection container.").check(allClasses); diff --git a/src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassNode.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassNode.java similarity index 96% rename from src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassNode.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassNode.java index 26179c778511..62cda11eb32b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassNode.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassNode.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.classpath; +package de.tum.cit.aet.artemis.shared.architecture.util; import java.util.Objects; import java.util.function.Function; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassPathNode.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassPathNode.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassPathNode.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassPathNode.java index 4f41a71a24a2..ddc092c6a0f4 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassPathNode.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassPathNode.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.classpath; +package de.tum.cit.aet.artemis.shared.architecture.util; import java.util.Iterator; import java.util.Objects; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassPathUtil.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassPathUtil.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassPathUtil.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassPathUtil.java index 950c03b05faa..35f37766850a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/classpath/ClassPathUtil.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/ClassPathUtil.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.classpath; +package de.tum.cit.aet.artemis.shared.architecture.util; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/classpath/PackageNode.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/PackageNode.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/util/classpath/PackageNode.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/PackageNode.java index 43b4fa0ba77a..1bdc0a160af9 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/classpath/PackageNode.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/PackageNode.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.classpath; +package de.tum.cit.aet.artemis.shared.architecture.util; import java.util.Collection; import java.util.Collections; diff --git a/src/test/java/de/tum/cit/aet/artemis/util/classpath/RootNode.java b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/RootNode.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/util/classpath/RootNode.java rename to src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/RootNode.java index 8240255519f5..7cc233f386d2 100644 --- a/src/test/java/de/tum/cit/aet/artemis/util/classpath/RootNode.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/architecture/util/RootNode.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.util.classpath; +package de.tum.cit.aet.artemis.shared.architecture.util; import java.util.Collection; import java.util.List; diff --git a/src/test/java/de/tum/cit/aet/artemis/AbstractArtemisIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java similarity index 90% rename from src/test/java/de/tum/cit/aet/artemis/AbstractArtemisIntegrationTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java index 14a7ed09cb02..57706d00e482 100644 --- a/src/test/java/de/tum/cit/aet/artemis/AbstractArtemisIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractArtemisIntegrationTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.shared.base; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; @@ -20,11 +20,12 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.context.annotation.Import; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.test.context.junit.jupiter.SpringExtension; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.atlas.service.competency.CompetencyProgressService; import de.tum.cit.aet.artemis.communication.service.WebsocketMessagingService; import de.tum.cit.aet.artemis.communication.service.notifications.ConversationNotificationService; @@ -36,17 +37,22 @@ import de.tum.cit.aet.artemis.communication.service.notifications.push_notifications.ApplePushNotificationService; import de.tum.cit.aet.artemis.communication.service.notifications.push_notifications.FirebasePushNotificationService; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; import de.tum.cit.aet.artemis.core.service.FileService; import de.tum.cit.aet.artemis.core.service.ScheduleService; import de.tum.cit.aet.artemis.core.service.ZipFileService; import de.tum.cit.aet.artemis.core.service.messaging.InstanceMessageSendService; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.core.util.HibernateQueryInterceptor; +import de.tum.cit.aet.artemis.core.util.QueryCountAssert; +import de.tum.cit.aet.artemis.core.util.RequestUtilService; +import de.tum.cit.aet.artemis.core.util.ThrowingProducer; import de.tum.cit.aet.artemis.exam.service.ExamAccessService; -import de.tum.cit.aet.artemis.exercise.ExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.programming.MockDelegate; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseUtilService; import de.tum.cit.aet.artemis.lti.service.Lti13Service; import de.tum.cit.aet.artemis.modeling.service.ModelingSubmissionService; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; @@ -56,14 +62,10 @@ import de.tum.cit.aet.artemis.programming.service.ProgrammingExerciseScheduleService; import de.tum.cit.aet.artemis.programming.service.ProgrammingTriggerService; import de.tum.cit.aet.artemis.programming.service.UriService; +import de.tum.cit.aet.artemis.programming.util.MockDelegate; +import de.tum.cit.aet.artemis.shared.TestRepositoryConfiguration; import de.tum.cit.aet.artemis.text.service.TextBlockService; import de.tum.cit.aet.artemis.text.service.TextSubmissionService; -import de.tum.cit.aet.artemis.user.UserFactory; -import de.tum.cit.aet.artemis.user.UserUtilService; -import de.tum.cit.aet.artemis.util.HibernateQueryInterceptor; -import de.tum.cit.aet.artemis.util.QueryCountAssert; -import de.tum.cit.aet.artemis.util.RequestUtilService; -import de.tum.cit.aet.artemis.util.ThrowingProducer; import io.zonky.test.db.AutoConfigureEmbeddedDatabase; /** @@ -73,6 +75,7 @@ @AutoConfigureMockMvc @ExtendWith(SpringExtension.class) @Execution(ExecutionMode.CONCURRENT) +@Import(TestRepositoryConfiguration.class) @AutoConfigureEmbeddedDatabase public abstract class AbstractArtemisIntegrationTest implements MockDelegate { @@ -180,16 +183,16 @@ public abstract class AbstractArtemisIntegrationTest implements MockDelegate { protected ExerciseUtilService exerciseUtilService; @Autowired - protected UserRepository userRepository; + protected UserTestRepository userTestRepository; @Autowired protected ExerciseRepository exerciseRepository; @Autowired - protected ResultRepository resultRepository; + protected ResultTestRepository resultRepository; @Autowired - protected CourseRepository courseRepository; + protected CourseTestRepository courseRepository; @BeforeEach void mockMailService() { diff --git a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java similarity index 99% rename from src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java index 67581e24e939..9de675fa0d7d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationGitlabCIGitlabSamlTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.shared.base; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ARTEMIS; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; @@ -31,7 +31,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; -import de.tum.cit.aet.artemis.connector.GitlabRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.GitlabRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.exception.ContinuousIntegrationException; diff --git a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationIndependentTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationIndependentTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationIndependentTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationIndependentTest.java index 0195a773f956..06d39f233939 100644 --- a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationIndependentTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationIndependentTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.shared.base; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_AEOLUS; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_APOLLON; @@ -28,8 +28,8 @@ import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exam.service.ExamLiveEventsService; import de.tum.cit.aet.artemis.exercise.domain.Team; -import de.tum.cit.aet.artemis.lti.repository.LtiPlatformConfigurationRepository; import de.tum.cit.aet.artemis.lti.service.OAuth2JWKSService; +import de.tum.cit.aet.artemis.lti.test_repository.LtiPlatformConfigurationTestRepository; import de.tum.cit.aet.artemis.programming.domain.AbstractBaseProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; @@ -52,7 +52,7 @@ public abstract class AbstractSpringIntegrationIndependentTest extends AbstractA protected OAuth2JWKSService oAuth2JWKSService; @SpyBean - protected LtiPlatformConfigurationRepository ltiPlatformConfigurationRepository; + protected LtiPlatformConfigurationTestRepository ltiPlatformConfigurationRepository; @SpyBean protected ExamLiveEventsService examLiveEventsService; diff --git a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationJenkinsGitlabTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationJenkinsGitlabTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationJenkinsGitlabTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationJenkinsGitlabTest.java index 4e4141543b32..8db77872f646 100644 --- a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationJenkinsGitlabTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationJenkinsGitlabTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.shared.base; import static de.tum.cit.aet.artemis.core.config.Constants.ASSIGNMENT_REPO_NAME; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_AEOLUS; @@ -9,9 +9,9 @@ import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_LTI; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_SCHEDULING; import static de.tum.cit.aet.artemis.core.config.Constants.TEST_REPO_NAME; +import static de.tum.cit.aet.artemis.core.util.TestConstants.COMMIT_HASH_OBJECT_ID; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.SOLUTION; import static de.tum.cit.aet.artemis.programming.domain.build.BuildPlanType.TEMPLATE; -import static de.tum.cit.aet.artemis.util.TestConstants.COMMIT_HASH_OBJECT_ID; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; import static tech.jhipster.config.JHipsterConstants.SPRING_PROFILE_TEST; @@ -36,9 +36,9 @@ import de.tum.cit.aet.artemis.assessment.web.ResultWebsocketService; import de.tum.cit.aet.artemis.communication.service.notifications.GroupNotificationScheduleService; -import de.tum.cit.aet.artemis.connector.AeolusRequestMockProvider; -import de.tum.cit.aet.artemis.connector.GitlabRequestMockProvider; -import de.tum.cit.aet.artemis.connector.JenkinsRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.AeolusRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.GitlabRequestMockProvider; +import de.tum.cit.aet.artemis.core.connector.JenkinsRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exam.service.ExamLiveEventsService; diff --git a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationLocalCILocalVCTest.java b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.java similarity index 95% rename from src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationLocalCILocalVCTest.java rename to src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.java index 1dbc2e1f73a9..41a1f1436619 100644 --- a/src/test/java/de/tum/cit/aet/artemis/AbstractSpringIntegrationLocalCILocalVCTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis; +package de.tum.cit.aet.artemis.shared.base; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_AEOLUS; import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_ARTEMIS; @@ -37,25 +37,25 @@ import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.service.ResourceLoaderService; import de.tum.cit.aet.artemis.core.service.ldap.LdapUserService; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; import de.tum.cit.aet.artemis.exam.service.ExamLiveEventsService; import de.tum.cit.aet.artemis.exercise.domain.Team; -import de.tum.cit.aet.artemis.localvcci.LocalVCLocalCITestService; -import de.tum.cit.aet.artemis.localvcci.TestBuildAgentConfiguration; import de.tum.cit.aet.artemis.programming.domain.AbstractBaseProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseParticipation; import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation; import de.tum.cit.aet.artemis.programming.domain.VcsRepositoryUri; -import de.tum.cit.aet.artemis.programming.repository.BuildJobRepository; +import de.tum.cit.aet.artemis.programming.localvcci.LocalVCLocalCITestService; +import de.tum.cit.aet.artemis.programming.localvcci.util.TestBuildAgentConfiguration; import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseBuildConfigRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository; -import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.SolutionProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.repository.TemplateProgrammingExerciseParticipationRepository; import de.tum.cit.aet.artemis.programming.service.ProgrammingMessagingService; import de.tum.cit.aet.artemis.programming.service.localci.LocalCIService; import de.tum.cit.aet.artemis.programming.service.localvc.LocalVCService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.programming.test_repository.BuildJobTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseStudentParticipationTestRepository; +import de.tum.cit.aet.artemis.programming.test_repository.ProgrammingExerciseTestRepository; // Must start up an actual web server such that the tests can communicate with the ArtemisGitServlet using JGit. // Otherwise, only MockMvc requests could be used. The port this runs on is defined at server.port (see @TestPropertySource). @@ -94,7 +94,7 @@ public abstract class AbstractSpringIntegrationLocalCILocalVCTest extends Abstra protected LocalCIService continuousIntegrationService; @Autowired - protected ProgrammingExerciseRepository programmingExerciseRepository; + protected ProgrammingExerciseTestRepository programmingExerciseRepository; @Autowired protected ProgrammingExerciseBuildConfigRepository programmingExerciseBuildConfigRepository; @@ -106,13 +106,13 @@ public abstract class AbstractSpringIntegrationLocalCILocalVCTest extends Abstra protected SolutionProgrammingExerciseParticipationRepository solutionProgrammingExerciseParticipationRepository; @Autowired - protected ProgrammingExerciseStudentParticipationRepository programmingExerciseStudentParticipationRepository; + protected ProgrammingExerciseStudentParticipationTestRepository programmingExerciseStudentParticipationRepository; @Autowired protected UserUtilService userUtilService; @Autowired - protected BuildJobRepository buildJobRepository; + protected BuildJobTestRepository buildJobRepository; /** * This is the mock(DockerClient.class) provided by the {@link TestBuildAgentConfiguration}. diff --git a/src/test/java/de/tum/cit/aet/artemis/config/HibernatePropertiesConfig.java b/src/test/java/de/tum/cit/aet/artemis/shared/config/HibernatePropertiesConfig.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/config/HibernatePropertiesConfig.java rename to src/test/java/de/tum/cit/aet/artemis/shared/config/HibernatePropertiesConfig.java index b05ebfd4a013..282ea9a99ee0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/config/HibernatePropertiesConfig.java +++ b/src/test/java/de/tum/cit/aet/artemis/shared/config/HibernatePropertiesConfig.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.config; +package de.tum.cit.aet.artemis.shared.config; import org.hibernate.cfg.AvailableSettings; import org.hibernate.resource.jdbc.spi.StatementInspector; diff --git a/src/test/java/de/tum/cit/aet/artemis/text/AssessmentEventIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/text/AssessmentEventIntegrationTest.java index a4c6d6432d79..c7d873d7de6a 100644 --- a/src/test/java/de/tum/cit/aet/artemis/text/AssessmentEventIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/AssessmentEventIntegrationTest.java @@ -10,28 +10,28 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.repository.TextAssessmentEventRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextAssessmentEvent; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class AssessmentEventIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "assessmentevent"; @Autowired - private TextSubmissionRepository textSubmissionRepository; + private TextSubmissionTestRepository textSubmissionTestRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private TextAssessmentEventRepository textAssessmentEventRepository; @@ -56,11 +56,11 @@ class AssessmentEventIntegrationTest extends AbstractSpringIntegrationIndependen void initTestCase() { userUtilService.addUsers(TEST_PREFIX, 0, 1, 1, 1); course = courseUtilService.createCourseWithTextExerciseAndTutor(TEST_PREFIX + "tutor1"); - tutor = userRepository.getUserByLoginElseThrow(TEST_PREFIX + "tutor1"); + tutor = userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "tutor1"); // we exactly create 1 exercise, 1 participation and 1 submission (which was submitted), so the following code should be fine exercise = course.getExercises().iterator().next(); studentParticipation = studentParticipationRepository.findByExerciseId(exercise.getId()).iterator().next(); - textSubmission = textSubmissionRepository.findByParticipation_ExerciseIdAndSubmittedIsTrue(exercise.getId()).iterator().next(); + textSubmission = textSubmissionTestRepository.findByParticipation_ExerciseIdAndSubmittedIsTrue(exercise.getId()).iterator().next(); } /** @@ -125,7 +125,7 @@ void testAddSingleCompleteAssessmentEvent_withNotNullEventId() throws Exception @WithMockUser(username = TEST_PREFIX + "tutor1", roles = "TA") void testAddSingleCompleteAssessmentEvent_withExampleSubmission() throws Exception { textSubmission.setExampleSubmission(true); - textSubmissionRepository.saveAndFlush(textSubmission); + textSubmissionTestRepository.saveAndFlush(textSubmission); TextAssessmentEvent event = textExerciseUtilService.createSingleTextAssessmentEvent(course.getId(), tutor.getId(), exercise.getId(), studentParticipation.getId(), textSubmission.getId()); request.post("/api/event-insights/text-assessment/events", event, HttpStatus.BAD_REQUEST); diff --git a/src/test/java/de/tum/cit/aet/artemis/text/TextAssessmentIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/text/TextAssessmentIntegrationTest.java index 89f95b8bd92e..22b66b7057a0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/text/TextAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/TextAssessmentIntegrationTest.java @@ -1,6 +1,6 @@ package de.tum.cit.aet.artemis.text; -import static de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; +import static de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider.ATHENA_MODULE_TEXT_TEST; import static java.time.ZonedDateTime.now; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; @@ -34,8 +34,6 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; -import de.tum.cit.aet.artemis.assessment.ComplaintUtilService; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.Complaint; import de.tum.cit.aet.artemis.assessment.domain.ComplaintResponse; @@ -44,42 +42,44 @@ import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.dto.AssessmentUpdateDTO; import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.repository.TextBlockRepository; -import de.tum.cit.aet.artemis.connector.AthenaRequestMockProvider; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; +import de.tum.cit.aet.artemis.assessment.util.ComplaintUtilService; import de.tum.cit.aet.artemis.core.config.Constants; +import de.tum.cit.aet.artemis.core.connector.AthenaRequestMockProvider; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.exam.ExamUtilService; import de.tum.cit.aet.artemis.exam.domain.Exam; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; import de.tum.cit.aet.artemis.exam.repository.ExamRepository; import de.tum.cit.aet.artemis.exam.repository.ExerciseGroupRepository; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Submission; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseFactory; -import de.tum.cit.aet.artemis.exercise.fileupload.FileUploadExerciseUtilService; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadExercise; import de.tum.cit.aet.artemis.fileupload.domain.FileUploadSubmission; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseFactory; +import de.tum.cit.aet.artemis.fileupload.util.FileUploadExerciseUtilService; import de.tum.cit.aet.artemis.programming.dto.ResultDTO; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.dto.TextAssessmentDTO; import de.tum.cit.aet.artemis.text.dto.TextAssessmentUpdateDTO; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; import de.tum.cit.aet.artemis.text.service.TextAssessmentService; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class TextAssessmentIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -98,16 +98,16 @@ class TextAssessmentIntegrationTest extends AbstractSpringIntegrationIndependent private TextExerciseRepository textExerciseRepository; @Autowired - private TextSubmissionRepository textSubmissionRepository; + private TextSubmissionTestRepository textSubmissionRepository; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepository; + private ExampleSubmissionTestRepository exampleSubmissionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ExerciseGroupRepository exerciseGroupRepository; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/text/TextComparisonTest.java b/src/test/java/de/tum/cit/aet/artemis/text/TextComparisonTest.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/exercise/text/TextComparisonTest.java rename to src/test/java/de/tum/cit/aet/artemis/text/TextComparisonTest.java index 26c909175646..e4864a7a2443 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/text/TextComparisonTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/TextComparisonTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.text; +package de.tum.cit.aet.artemis.text; import static org.assertj.core.api.Assertions.assertThat; @@ -8,10 +8,11 @@ import org.junit.jupiter.api.Test; import de.tum.cit.aet.artemis.core.domain.Course; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.service.StudentExamService; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; class TextComparisonTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java index 78204f1541c3..cbcd54bb78f3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/TextExerciseIntegrationTest.java @@ -1,9 +1,9 @@ package de.tum.cit.aet.artemis.text; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus.CONFIRMED; import static de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus.DENIED; import static de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus.NONE; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -34,38 +34,39 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.assessment.domain.ExampleSubmission; import de.tum.cit.aet.artemis.assessment.domain.Feedback; import de.tum.cit.aet.artemis.assessment.domain.GradingCriterion; import de.tum.cit.aet.artemis.assessment.domain.GradingInstruction; import de.tum.cit.aet.artemis.assessment.domain.Result; -import de.tum.cit.aet.artemis.assessment.repository.ExampleSubmissionRepository; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; import de.tum.cit.aet.artemis.assessment.repository.GradingCriterionRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ExampleSubmissionTestRepository; +import de.tum.cit.aet.artemis.assessment.util.GradingCriterionUtil; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; import de.tum.cit.aet.artemis.atlas.domain.competency.Competency; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; -import de.tum.cit.aet.artemis.competency.CompetencyUtilService; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.dto.CourseForDashboardDTO; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.GradingCriterionUtil; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider; +import de.tum.cit.aet.artemis.exam.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; import de.tum.cit.aet.artemis.exercise.domain.DifficultyLevel; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.IncludedInOverallScore; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.TeamAssignmentConfig; import de.tum.cit.aet.artemis.exercise.domain.participation.Participation; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.util.ExerciseIntegrationTestService; import de.tum.cit.aet.artemis.plagiarism.PlagiarismUtilService; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismStatus; @@ -74,15 +75,14 @@ import de.tum.cit.aet.artemis.plagiarism.dto.PlagiarismComparisonStatusDTO; import de.tum.cit.aet.artemis.plagiarism.dto.PlagiarismResultDTO; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismComparisonRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; -import de.tum.cit.aet.artemis.util.ExerciseIntegrationTestService; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider; -import de.tum.cit.aet.artemis.util.InvalidExamExerciseDatesArgumentProvider.InvalidExamExerciseDateConfiguration; -import de.tum.cit.aet.artemis.util.PageableSearchUtilService; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class TextExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTest { @@ -95,10 +95,10 @@ class TextExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTe private TextExerciseUtilService textExerciseUtilService; @Autowired - private TextSubmissionRepository textSubmissionRepository; + private TextSubmissionTestRepository textSubmissionRepository; @Autowired - private ExampleSubmissionRepository exampleSubmissionRepo; + private ExampleSubmissionTestRepository exampleSubmissionRepo; @Autowired private TeamRepository teamRepository; @@ -113,7 +113,7 @@ class TextExerciseIntegrationTest extends AbstractSpringIntegrationIndependentTe private GradingCriterionRepository gradingCriterionRepository; @Autowired - private StudentParticipationRepository studentParticipationRepository; + private StudentParticipationTestRepository studentParticipationRepository; @Autowired private ExerciseIntegrationTestService exerciseIntegrationTestService; diff --git a/src/test/java/de/tum/cit/aet/artemis/text/TextSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/text/TextSubmissionIntegrationTest.java index bcf8827a3d81..c66b8e10736e 100644 --- a/src/test/java/de/tum/cit/aet/artemis/text/TextSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/TextSubmissionIntegrationTest.java @@ -1,6 +1,6 @@ package de.tum.cit.aet.artemis.text; -import static de.tum.cit.aet.artemis.util.TestResourceUtils.HalfSecond; +import static de.tum.cit.aet.artemis.core.util.TestResourceUtils.HalfSecond; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.within; @@ -18,10 +18,9 @@ import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.assessment.domain.AssessmentType; import de.tum.cit.aet.artemis.communication.domain.Post; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; import de.tum.cit.aet.artemis.core.config.Constants; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; @@ -33,13 +32,11 @@ import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; import de.tum.cit.aet.artemis.exercise.dto.ExerciseDetailsDTO; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.SubmissionVersionRepository; import de.tum.cit.aet.artemis.exercise.repository.TeamRepository; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseUtilService; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismCase; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismComparison; import de.tum.cit.aet.artemis.plagiarism.domain.PlagiarismSubmission; @@ -47,22 +44,25 @@ import de.tum.cit.aet.artemis.plagiarism.domain.text.TextSubmissionElement; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismCaseRepository; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismComparisonRepository; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; import de.tum.cit.aet.artemis.text.domain.TextExercise; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; +import de.tum.cit.aet.artemis.text.util.TextExerciseUtilService; class TextSubmissionIntegrationTest extends AbstractSpringIntegrationIndependentTest { private static final String TEST_PREFIX = "textsubmissionintegration"; @Autowired - private TextSubmissionRepository submissionRepository; + private TextSubmissionTestRepository testSubmissionTestRepository; @Autowired private SubmissionVersionRepository submissionVersionRepository; @Autowired - private StudentParticipationRepository participationRepository; + private StudentParticipationTestRepository participationRepository; @Autowired private PlagiarismComparisonRepository plagiarismComparisonRepository; @@ -74,7 +74,7 @@ class TextSubmissionIntegrationTest extends AbstractSpringIntegrationIndependent private PlagiarismCaseRepository plagiarismCaseRepository; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; @Autowired private TextExerciseUtilService textExerciseUtilService; @@ -118,12 +118,14 @@ void initTestCase() { @Test @WithMockUser(username = TEST_PREFIX + "student3") void testRepositoryMethods() { - assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> submissionRepository.findByIdWithParticipationExerciseResultAssessorElseThrow(Long.MAX_VALUE)); + assertThatExceptionOfType(EntityNotFoundException.class) + .isThrownBy(() -> testSubmissionTestRepository.findByIdWithParticipationExerciseResultAssessorElseThrow(Long.MAX_VALUE)); - assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> submissionRepository.findByIdWithEagerResultsAndFeedbackAndTextBlocksElseThrow(Long.MAX_VALUE)); + assertThatExceptionOfType(EntityNotFoundException.class) + .isThrownBy(() -> testSubmissionTestRepository.findByIdWithEagerResultsAndFeedbackAndTextBlocksElseThrow(Long.MAX_VALUE)); assertThatExceptionOfType(EntityNotFoundException.class) - .isThrownBy(() -> submissionRepository.getTextSubmissionWithResultAndTextBlocksAndFeedbackByResultIdElseThrow(Long.MAX_VALUE)); + .isThrownBy(() -> testSubmissionTestRepository.getTextSubmissionWithResultAndTextBlocksAndFeedbackByResultIdElseThrow(Long.MAX_VALUE)); } @Test @@ -153,7 +155,7 @@ void getTextSubmissionWithResult_involved_allowed() throws Exception { plagiarismCase.setExercise(finishedTextExercise); plagiarismCase = plagiarismCaseRepository.save(plagiarismCase); Post post = new Post(); - post.setAuthor(userRepository.getUserByLoginElseThrow(TEST_PREFIX + "instructor1")); + post.setAuthor(userTestRepository.getUserByLoginElseThrow(TEST_PREFIX + "instructor1")); post.setTitle("Title Plagiarism Case Post"); post.setContent("Content Plagiarism Case Post"); post.setVisibleForStudents(true); @@ -359,8 +361,8 @@ void submitExercise_beforeDueDate_isTeamMode() throws Exception { team.setName("Team"); team.setShortName("team"); team.setExercise(releasedTextExercise); - team.addStudents(userRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); - team.addStudents(userRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow()); + team.addStudents(userTestRepository.findOneByLogin(TEST_PREFIX + "student1").orElseThrow()); + team.addStudents(userTestRepository.findOneByLogin(TEST_PREFIX + "student2").orElseThrow()); teamRepository.save(releasedTextExercise, team); StudentParticipation participation = participationUtilService.addTeamParticipationForExercise(releasedTextExercise, team.getId()); @@ -432,7 +434,7 @@ void submitExercise_beforeDueDateWithTwoSubmissions_allowed() throws Exception { textSubmission.setText(newSubmissionText); request.put(submitPath, textSubmission, HttpStatus.OK); - final var submissionInDb = submissionRepository.findById(textSubmission.getId()); + final var submissionInDb = testSubmissionTestRepository.findById(textSubmission.getId()); assertThat(submissionInDb).isPresent(); assertThat(submissionInDb.get().getText()).isEqualTo(newSubmissionText); } @@ -476,7 +478,7 @@ void submitExercise_notStudentInCourse() throws Exception { @Test @WithMockUser(username = TEST_PREFIX + "student1", roles = "USER") void submitExercise_submissionIsAlreadyCreated_badRequest() throws Exception { - textSubmission = submissionRepository.save(textSubmission); + textSubmission = testSubmissionTestRepository.save(textSubmission); request.post("/api/exercises/" + releasedTextExercise.getId() + "/text-submissions", textSubmission, HttpStatus.BAD_REQUEST); } diff --git a/src/test/java/de/tum/cit/aet/artemis/service/TextBlockServiceTest.java b/src/test/java/de/tum/cit/aet/artemis/text/service/TextBlockServiceTest.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/service/TextBlockServiceTest.java rename to src/test/java/de/tum/cit/aet/artemis/text/service/TextBlockServiceTest.java index 02e1ebb866f6..aaea0eda5bdd 100644 --- a/src/test/java/de/tum/cit/aet/artemis/service/TextBlockServiceTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/service/TextBlockServiceTest.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.service; +package de.tum.cit.aet.artemis.text.service; import static org.assertj.core.api.Assertions.assertThat; @@ -11,7 +11,6 @@ import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextSubmission; -import de.tum.cit.aet.artemis.text.service.TextBlockService; class TextBlockServiceTest { diff --git a/src/test/java/de/tum/cit/aet/artemis/text/test_repository/TextSubmissionTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/text/test_repository/TextSubmissionTestRepository.java new file mode 100644 index 000000000000..90771221879b --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/text/test_repository/TextSubmissionTestRepository.java @@ -0,0 +1,33 @@ +package de.tum.cit.aet.artemis.text.test_repository; + +import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD; + +import java.util.Set; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.text.domain.TextSubmission; +import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; + +@Repository +@Primary +public interface TextSubmissionTestRepository extends TextSubmissionRepository { + + /** + * Gets all TextSubmissions which are submitted and loads all blocks + * + * @param exerciseId the ID of the exercise + * @return Set of Text Submissions + */ + @EntityGraph(type = LOAD, attributePaths = { "blocks" }) + Set findByParticipation_ExerciseIdAndSubmittedIsTrue(long exerciseId); + + @NotNull + default TextSubmission findByIdWithParticipationExerciseResultAssessorElseThrow(long submissionId) { + return getValueElseThrow(findWithEagerParticipationExerciseResultAssessorById(submissionId), submissionId); + } +} diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/text/TextExerciseFactory.java b/src/test/java/de/tum/cit/aet/artemis/text/util/TextExerciseFactory.java similarity index 98% rename from src/test/java/de/tum/cit/aet/artemis/exercise/text/TextExerciseFactory.java rename to src/test/java/de/tum/cit/aet/artemis/text/util/TextExerciseFactory.java index e3d2246d38e0..9721ab093241 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/text/TextExerciseFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/util/TextExerciseFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.text; +package de.tum.cit.aet.artemis.text.util; import java.time.ZonedDateTime; import java.util.ArrayList; @@ -9,8 +9,8 @@ import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; -import de.tum.cit.aet.artemis.exercise.ExerciseFactory; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.util.ExerciseFactory; import de.tum.cit.aet.artemis.text.domain.TextAssessmentEvent; import de.tum.cit.aet.artemis.text.domain.TextBlock; import de.tum.cit.aet.artemis.text.domain.TextBlockType; diff --git a/src/test/java/de/tum/cit/aet/artemis/exercise/text/TextExerciseUtilService.java b/src/test/java/de/tum/cit/aet/artemis/text/util/TextExerciseUtilService.java similarity index 94% rename from src/test/java/de/tum/cit/aet/artemis/exercise/text/TextExerciseUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/text/util/TextExerciseUtilService.java index cef17c586a3d..fb1effac7c64 100644 --- a/src/test/java/de/tum/cit/aet/artemis/exercise/text/TextExerciseUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/text/util/TextExerciseUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.exercise.text; +package de.tum.cit.aet.artemis.text.util; import static org.assertj.core.api.Assertions.assertThat; @@ -15,28 +15,29 @@ import de.tum.cit.aet.artemis.assessment.domain.FeedbackType; import de.tum.cit.aet.artemis.assessment.domain.Result; import de.tum.cit.aet.artemis.assessment.repository.FeedbackRepository; -import de.tum.cit.aet.artemis.assessment.repository.ResultRepository; import de.tum.cit.aet.artemis.assessment.repository.TextBlockRepository; +import de.tum.cit.aet.artemis.assessment.test_repository.ResultTestRepository; import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; -import de.tum.cit.aet.artemis.exam.ExamUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.exam.domain.ExerciseGroup; +import de.tum.cit.aet.artemis.exam.util.ExamUtilService; import de.tum.cit.aet.artemis.exercise.domain.Exercise; import de.tum.cit.aet.artemis.exercise.domain.ExerciseMode; import de.tum.cit.aet.artemis.exercise.domain.InitializationState; import de.tum.cit.aet.artemis.exercise.domain.Team; import de.tum.cit.aet.artemis.exercise.domain.participation.Participant; import de.tum.cit.aet.artemis.exercise.domain.participation.StudentParticipation; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationFactory; +import de.tum.cit.aet.artemis.exercise.participation.util.ParticipationUtilService; import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; -import de.tum.cit.aet.artemis.exercise.repository.ParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.StudentParticipationRepository; -import de.tum.cit.aet.artemis.exercise.repository.SubmissionRepository; -import de.tum.cit.aet.artemis.participation.ParticipationFactory; -import de.tum.cit.aet.artemis.participation.ParticipationUtilService; +import de.tum.cit.aet.artemis.exercise.test_repository.ParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.StudentParticipationTestRepository; +import de.tum.cit.aet.artemis.exercise.test_repository.SubmissionTestRepository; import de.tum.cit.aet.artemis.plagiarism.domain.text.TextPlagiarismResult; import de.tum.cit.aet.artemis.plagiarism.repository.PlagiarismResultRepository; import de.tum.cit.aet.artemis.text.domain.TextAssessmentEvent; @@ -46,8 +47,7 @@ import de.tum.cit.aet.artemis.text.domain.TextSubmission; import de.tum.cit.aet.artemis.text.dto.TextAssessmentEventType; import de.tum.cit.aet.artemis.text.repository.TextExerciseRepository; -import de.tum.cit.aet.artemis.text.repository.TextSubmissionRepository; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.text.test_repository.TextSubmissionTestRepository; /** * Service responsible for initializing the database with specific testdata related to text exercises for use in integration tests. @@ -65,19 +65,19 @@ public class TextExerciseUtilService { private ExerciseRepository exerciseRepo; @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired - private TextSubmissionRepository textSubmissionRepo; + private TextSubmissionTestRepository textSubmissionRepo; @Autowired - private SubmissionRepository submissionRepository; + private SubmissionTestRepository submissionRepository; @Autowired - private ResultRepository resultRepo; + private ResultTestRepository resultRepo; @Autowired - private StudentParticipationRepository studentParticipationRepo; + private StudentParticipationTestRepository studentParticipationRepo; @Autowired private FeedbackRepository feedbackRepo; @@ -92,10 +92,10 @@ public class TextExerciseUtilService { private TextExerciseRepository textExerciseRepository; @Autowired - private UserRepository userRepository; + private UserTestRepository userRepository; @Autowired - private ParticipationRepository participationRepository; + private ParticipationTestRepository participationRepository; @Autowired private ExamUtilService examUtilService; diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java index c6e912c73a4f..fb830564f00b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/AbstractTutorialGroupIntegrationTest.java @@ -21,17 +21,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import de.tum.cit.aet.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.communication.domain.ConversationParticipant; import de.tum.cit.aet.artemis.communication.domain.conversation.Channel; -import de.tum.cit.aet.artemis.communication.repository.ConversationParticipantRepository; import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; +import de.tum.cit.aet.artemis.communication.test_repository.ConversationParticipantTestRepository; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.core.repository.UserRepository; -import de.tum.cit.aet.artemis.course.CourseTestService; -import de.tum.cit.aet.artemis.course.CourseUtilService; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.test_repository.UserTestRepository; +import de.tum.cit.aet.artemis.core.user.util.UserUtilService; +import de.tum.cit.aet.artemis.core.util.CourseTestService; +import de.tum.cit.aet.artemis.core.util.CourseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistration; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSchedule; @@ -39,15 +40,14 @@ import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSessionStatus; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupsConfiguration; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupFreePeriodRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupNotificationRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRegistrationRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupScheduleRepository; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupSessionRepository; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupsConfigurationRepository; import de.tum.cit.aet.artemis.tutorialgroup.service.TutorialGroupChannelManagementService; import de.tum.cit.aet.artemis.tutorialgroup.service.TutorialGroupService; -import de.tum.cit.aet.artemis.user.UserUtilService; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupRegistrationTestRepository; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupScheduleTestRepository; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupTestRepository; +import de.tum.cit.aet.artemis.tutorialgroups.util.TutorialGroupUtilService; /** * Contains useful methods for testing the tutorial groups feature. @@ -58,19 +58,19 @@ abstract class AbstractTutorialGroupIntegrationTest extends AbstractSpringIntegr CourseTestService courseTestService; @Autowired - UserRepository userRepository; + UserTestRepository userRepository; @Autowired - CourseRepository courseRepository; + CourseTestRepository courseRepository; @Autowired - TutorialGroupRepository tutorialGroupRepository; + TutorialGroupTestRepository tutorialGroupTestRepository; @Autowired TutorialGroupSessionRepository tutorialGroupSessionRepository; @Autowired - TutorialGroupScheduleRepository tutorialGroupScheduleRepository; + TutorialGroupScheduleTestRepository tutorialGroupScheduleTestRepository; @Autowired TutorialGroupFreePeriodRepository tutorialGroupFreePeriodRepository; @@ -79,10 +79,7 @@ abstract class AbstractTutorialGroupIntegrationTest extends AbstractSpringIntegr TutorialGroupsConfigurationRepository tutorialGroupsConfigurationRepository; @Autowired - TutorialGroupRegistrationRepository tutorialGroupRegistrationRepository; - - @Autowired - TutorialGroupNotificationRepository tutorialGroupNotificationRepository; + TutorialGroupRegistrationTestRepository tutorialGroupRegistrationTestRepository; @Autowired TutorialGroupService tutorialGroupService; @@ -91,7 +88,7 @@ abstract class AbstractTutorialGroupIntegrationTest extends AbstractSpringIntegr ChannelRepository channelRepository; @Autowired - ConversationParticipantRepository conversationParticipantRepository; + ConversationParticipantTestRepository conversationParticipantRepository; @Autowired TutorialGroupChannelManagementService tutorialGroupChannelManagementService; @@ -269,7 +266,7 @@ TutorialGroup setUpTutorialGroupWithSchedule(Long courseId, String tutorLogin) t var scheduleToCreate = newTutorialGroup.getTutorialGroupSchedule(); var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(courseId), newTutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); - newTutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + newTutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); this.assertTutorialGroupPersistedWithSchedule(newTutorialGroup, scheduleToCreate); return newTutorialGroup; } @@ -352,9 +349,9 @@ Channel asserTutorialGroupChannelIsCorrectlyConfigured(TutorialGroup tutorialGro var cleanedTitle = tg.getTitle().replaceAll("\\s", "-").toLowerCase(); return "tutorgroup-" + cleanedTitle.substring(0, Math.min(cleanedTitle.length(), 18)); }; - var tutorialGroupFromDb = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsElseThrow(tutorialGroup.getId()); + var tutorialGroupFromDb = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsElseThrow(tutorialGroup.getId()); - var channelOptional = tutorialGroupRepository.getTutorialGroupChannel(tutorialGroupFromDb.getId()); + var channelOptional = tutorialGroupTestRepository.getTutorialGroupChannel(tutorialGroupFromDb.getId()); assertThat(channelOptional).isPresent(); var channel = channelOptional.get(); assertThat(channel.getName()).isEqualTo(expectedTutorialGroupName.apply(tutorialGroupFromDb)); @@ -385,7 +382,7 @@ Channel asserTutorialGroupChannelIsCorrectlyConfigured(TutorialGroup tutorialGro } void assertTutorialGroupChannelDoesNotExist(TutorialGroup tutorialGroup) { - var channelOptional = tutorialGroupRepository.getTutorialGroupChannel(tutorialGroup.getId()); + var channelOptional = tutorialGroupTestRepository.getTutorialGroupChannel(tutorialGroup.getId()); assertThat(channelOptional).isEmpty(); } diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFreePeriodIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFreePeriodIntegrationTest.java index ef357016efb8..5b750a73f558 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFreePeriodIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFreePeriodIntegrationTest.java @@ -17,11 +17,11 @@ import org.springframework.web.client.HttpClientErrorException; import de.tum.cit.aet.artemis.core.domain.Language; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupFreePeriod; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSession; import de.tum.cit.aet.artemis.tutorialgroup.dto.TutorialGroupFreePeriodDTO; -import de.tum.cit.aet.artemis.user.UserFactory; class TutorialGroupFreePeriodIntegrationTest extends AbstractTutorialGroupIntegrationTest { @@ -119,7 +119,7 @@ void create_asInstructor_shouldCreateTutorialGroupFreePeriod() throws Exception void create_overlapsWithExistingScheduledSession_shouldCancelSession() throws Exception { // given TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var dto = createTutorialGroupFreePeriodDTO(FIRST_AUGUST_MONDAY_00_00, FIRST_AUGUST_MONDAY_23_59, "Holiday"); // when @@ -139,7 +139,7 @@ void create_overlapsWithExistingScheduledSession_shouldCancelSession() throws Ex void create_startDateIsAfterEndDate_shouldNotCreateFreePeriod() throws Exception { // given TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var dto = createTutorialGroupFreePeriodDTO(FIRST_AUGUST_MONDAY_23_59, FIRST_AUGUST_MONDAY_00_00, "Holiday"); // when @@ -159,7 +159,7 @@ void create_startDateIsAfterEndDate_shouldNotCreateFreePeriod() throws Exception void create_freePeriodEndTimeMatchesSessionStartTime_shouldNotCancelSession() throws Exception { // given TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var dto = createTutorialGroupFreePeriodDTO(FIRST_AUGUST_MONDAY_08_00, FIRST_AUGUST_MONDAY_10_00, "Holiday"); // when @@ -179,7 +179,7 @@ void create_freePeriodEndTimeMatchesSessionStartTime_shouldNotCancelSession() th void create_freePeriodStartTimeMatchesSessionEndTime_shouldNotCancelSession() throws Exception { // given TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var dto = createTutorialGroupFreePeriodDTO(FIRST_AUGUST_MONDAY_12_00, FIRST_AUGUST_MONDAY_13_00, "Holiday"); // when @@ -199,7 +199,7 @@ void create_freePeriodStartTimeMatchesSessionEndTime_shouldNotCancelSession() th void create_partialOverlapsWithExistingScheduledSession_shouldCancelSession_PeriodWithinDay() throws Exception { // given TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var dto = createTutorialGroupFreePeriodDTO(FIRST_AUGUST_MONDAY_10_00, FIRST_AUGUST_MONDAY_13_00, "Holiday"); // when @@ -219,7 +219,7 @@ void create_partialOverlapsWithExistingScheduledSession_shouldCancelSession_Peri void create_noOverlapsWithExistingScheduledSessionOnSameDay_shouldNotCancelSession_PeriodWithinDay() throws Exception { // given TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var dto = createTutorialGroupFreePeriodDTO(FIRST_AUGUST_MONDAY_13_00, FIRST_AUGUST_MONDAY_18_00, "Holiday"); // when diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupIntegrationTest.java index ce0d2da9e029..b08e710cd1a5 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupIntegrationTest.java @@ -32,18 +32,18 @@ import de.tum.cit.aet.artemis.communication.domain.DisplayPriority; import de.tum.cit.aet.artemis.communication.domain.Post; -import de.tum.cit.aet.artemis.communication.repository.PostRepository; +import de.tum.cit.aet.artemis.communication.test_repository.PostTestRepository; +import de.tum.cit.aet.artemis.communication.util.ConversationUtilService; import de.tum.cit.aet.artemis.core.domain.Language; import de.tum.cit.aet.artemis.core.domain.User; import de.tum.cit.aet.artemis.core.dto.StudentDTO; -import de.tum.cit.aet.artemis.post.ConversationUtilService; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistration; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistrationType; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSession; import de.tum.cit.aet.artemis.tutorialgroup.web.TutorialGroupResource; import de.tum.cit.aet.artemis.tutorialgroup.web.TutorialGroupResource.TutorialGroupRegistrationImportDTO; -import de.tum.cit.aet.artemis.user.UserFactory; class TutorialGroupIntegrationTest extends AbstractTutorialGroupIntegrationTest { @@ -53,7 +53,7 @@ class TutorialGroupIntegrationTest extends AbstractTutorialGroupIntegrationTest private ConversationUtilService conversationUtilService; @Autowired - private PostRepository postRepository; + private PostTestRepository postRepository; private User instructor1; @@ -110,8 +110,8 @@ void setupTestScenario() { exampleTwoTutorialGroupId = tutorialGroupUtilService .createTutorialGroup(exampleCourseId, generateRandomTitle(), "LoremIpsum2", 10, true, "LoremIpsum2", Language.GERMAN.name(), tutor2, Set.of(student2)).getId(); - tutorialGroupChannelManagementService.createChannelForTutorialGroup(tutorialGroupRepository.findByIdElseThrow(exampleOneTutorialGroupId)); - tutorialGroupChannelManagementService.createChannelForTutorialGroup(tutorialGroupRepository.findByIdElseThrow(exampleTwoTutorialGroupId)); + tutorialGroupChannelManagementService.createChannelForTutorialGroup(tutorialGroupTestRepository.findByIdElseThrow(exampleOneTutorialGroupId)); + tutorialGroupChannelManagementService.createChannelForTutorialGroup(tutorialGroupTestRepository.findByIdElseThrow(exampleTwoTutorialGroupId)); } @@ -124,7 +124,7 @@ void testJustForInstructorEndpoints() throws Exception { request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), buildTutorialGroupWithoutSchedule("tutor1"), TutorialGroup.class, HttpStatus.FORBIDDEN); request.putWithResponseBody(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId), new TutorialGroupResource.TutorialGroupUpdateDTO( - tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(), "Lorem Ipsum", true), + tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(), "Lorem Ipsum", true), TutorialGroup.class, HttpStatus.FORBIDDEN); request.delete(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId), HttpStatus.FORBIDDEN); request.postListWithResponseBody(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId) + "/register-multiple", new HashSet<>(), StudentDTO.class, @@ -164,7 +164,7 @@ void getTitle_asUser_shouldReturnTitle() throws Exception { // when var tutorialGroupTitle = request.get("/api/tutorial-groups/" + exampleOneTutorialGroupId + "/title", HttpStatus.OK, String.class); // then - var title = tutorialGroupRepository.findById(exampleOneTutorialGroupId).orElseThrow().getTitle(); + var title = tutorialGroupTestRepository.findById(exampleOneTutorialGroupId).orElseThrow().getTitle(); assertThat(tutorialGroupTitle).isEqualTo(title); } @@ -366,7 +366,7 @@ void averageAttendanceTestScaffold(Integer[] attendance, Integer expectedAverage // cleanup tutorialGroupSessionRepository.deleteAllInBatch(savedSessions); - tutorialGroupRepository.deleteById(tutorialGroupId); + tutorialGroupTestRepository.deleteById(tutorialGroupId); } @Test @@ -380,7 +380,7 @@ void create_asInstructor_shouldCreateTutorialGroup() throws Exception { asserTutorialGroupChannelIsCorrectlyConfigured(persistedTutorialGroup); // cleanup - tutorialGroupRepository.deleteById(persistedTutorialGroup.getId()); + tutorialGroupTestRepository.deleteById(persistedTutorialGroup.getId()); } @Test @@ -389,26 +389,26 @@ void create_WithIdInBody_shouldReturnBadRequest() throws Exception { // given var tutorialGroup = buildTutorialGroupWithoutSchedule("tutor1"); tutorialGroup.setId(22L); - var numberOfTutorialGroups = tutorialGroupRepository.findAllByCourseId(exampleCourseId).size(); + var numberOfTutorialGroups = tutorialGroupTestRepository.findAllByCourseId(exampleCourseId).size(); // when request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.BAD_REQUEST); // then - assertThat(tutorialGroupRepository.findAllByCourseId(exampleCourseId)).hasSize(numberOfTutorialGroups); + assertThat(tutorialGroupTestRepository.findAllByCourseId(exampleCourseId)).hasSize(numberOfTutorialGroups); } @Test @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void create_tutorialGroupWithTitleAlreadyExists_shouldReturnBadRequest() throws Exception { - var existingTitle = tutorialGroupRepository.findById(exampleOneTutorialGroupId).orElseThrow().getTitle(); + var existingTitle = tutorialGroupTestRepository.findById(exampleOneTutorialGroupId).orElseThrow().getTitle(); // given var tutorialGroup = buildTutorialGroupWithoutSchedule("tutor1"); tutorialGroup.setTitle(existingTitle); - var numberOfTutorialGroups = tutorialGroupRepository.findAllByCourseId(exampleCourseId).size(); + var numberOfTutorialGroups = tutorialGroupTestRepository.findAllByCourseId(exampleCourseId).size(); // when request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.BAD_REQUEST); // then - assertThat(tutorialGroupRepository.findAllByCourseId(exampleCourseId)).hasSize(numberOfTutorialGroups); + assertThat(tutorialGroupTestRepository.findAllByCourseId(exampleCourseId)).hasSize(numberOfTutorialGroups); } @Test @@ -451,7 +451,7 @@ void delete_asInstructor_shouldDeleteTutorialGroup() throws Exception { @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void update_asInstructor_shouldUpdateTutorialGroup() throws Exception { // given - var existingTutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + var existingTutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); var newRandomTitle = generateRandomTitle(); existingTutorialGroup.setTitle(newRandomTitle); @@ -468,7 +468,7 @@ void update_asInstructor_shouldUpdateTutorialGroup() throws Exception { @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void updateAssignedTeachingAssistant_asInstructor_shouldUpdateTutorialGroupAndChannel() throws Exception { // given - var existingTutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + var existingTutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); existingTutorialGroup.setTeachingAssistant(userUtilService.getUserByLogin(testPrefix + "tutor2")); // when @@ -498,15 +498,16 @@ void updateAssignedTeachingAssistant_asInstructor_shouldUpdateTutorialGroupAndCh @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void update_withTitleAlreadyExists_shouldReturnBadRequest() throws Exception { // given - var existingTutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + var existingTutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); var originalTitle = existingTutorialGroup.getTitle(); - var existingGroupTwo = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleTwoTutorialGroupId).orElseThrow(); + var existingGroupTwo = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleTwoTutorialGroupId).orElseThrow(); existingTutorialGroup.setTitle(" " + existingGroupTwo.getTitle() + " "); // when request.putWithResponseBody(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId), new TutorialGroupResource.TutorialGroupUpdateDTO(existingTutorialGroup, "Lorem Ipsum", true), TutorialGroup.class, HttpStatus.BAD_REQUEST); // then - assertThat(tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow().getTitle()).isEqualTo(originalTitle); + assertThat(tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow().getTitle()) + .isEqualTo(originalTitle); asserTutorialGroupChannelIsCorrectlyConfigured(existingTutorialGroup); } @@ -563,7 +564,7 @@ void registerStudent_studentRegistered_shouldReturnNoContent() throws Exception request.postWithoutResponseBody(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId) + "/register/" + student1.getLogin(), HttpStatus.NO_CONTENT, new LinkedMultiValueMap<>()); // then - var tutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + var tutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); assertThat(tutorialGroup.getRegistrations().stream().map(TutorialGroupRegistration::getStudent)).contains(student1); } @@ -605,7 +606,7 @@ void deregisterStudent_studentNotRegistered_shouldReturnNoContent() throws Excep request.delete(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId) + "/deregister/" + student3.getLogin(), HttpStatus.NO_CONTENT, new LinkedMultiValueMap<>()); // then - TutorialGroup tutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + TutorialGroup tutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); assertThat(tutorialGroup.getRegistrations().stream().map(TutorialGroupRegistration::getStudent)).doesNotContain(student3); } @@ -633,7 +634,7 @@ void registerMultipleStudents_asInstructor_shouldRegisterStudents() throws Excep List notFoundStudents = request.postListWithResponseBody(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId) + "/register-multiple", studentsToAdd, StudentDTO.class, HttpStatus.OK); // then - var tutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + var tutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); assertThat(tutorialGroup.getRegistrations().stream().map(TutorialGroupRegistration::getStudent)).contains(student3); assertThat(notFoundStudents).containsExactly(studentNotInCourse); verify(singleUserNotificationService).notifyStudentAboutRegistrationToTutorialGroup(tutorialGroup, student3, instructor1); @@ -641,9 +642,9 @@ void registerMultipleStudents_asInstructor_shouldRegisterStudents() throws Excep // remove registration of student 6 again // remove registration again - var registration = tutorialGroupRegistrationRepository.findTutorialGroupRegistrationByTutorialGroupAndStudentAndType(tutorialGroup, student3, INSTRUCTOR_REGISTRATION) + var registration = tutorialGroupRegistrationTestRepository.findTutorialGroupRegistrationByTutorialGroupAndStudentAndType(tutorialGroup, student3, INSTRUCTOR_REGISTRATION) .orElseThrow(); - tutorialGroupRegistrationRepository.delete(registration); + tutorialGroupRegistrationTestRepository.delete(registration); } @Test @@ -653,7 +654,7 @@ void importRegistrations_justTutorialGroupTitle_shouldCreateTutorialGroups() thr var freshTitleOne = "freshTitleOne"; var freshTitleTwo = "freshTitleTwo"; - var existingTitle = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow().getTitle(); + var existingTitle = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow().getTitle(); var regNullStudent = new TutorialGroupRegistrationImportDTO(freshTitleOne, null, null, null, null, null, null); var regBlankStudent = new TutorialGroupRegistrationImportDTO(freshTitleTwo, new StudentDTO("", "", "", "", ""), null, null, null, null, null); var regStudentPropertiesNull = new TutorialGroupRegistrationImportDTO(freshTitleOne, new StudentDTO(null, null, null, null, null), null, null, null, null, null); @@ -690,8 +691,8 @@ void importRegistrations_tutorialGroupTitleAndStudents_shouldCreateTutorialAndRe var group2Id = tutorialGroupUtilService .createTutorialGroup(exampleCourseId, generateRandomTitle(), "LoremIpsum1", 10, false, "LoremIpsum1", Language.ENGLISH.name(), tutor1, Set.of(student2)).getId(); - var group1 = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group1Id).orElseThrow(); - var group2 = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group2Id).orElseThrow(); + var group1 = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group1Id).orElseThrow(); + var group2 = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group2Id).orElseThrow(); // we test with student1 that the student will be deregistered from the old tutorial group assertUserIsRegisteredInTutorialWithTitle(group1.getTitle(), student1); @@ -747,7 +748,7 @@ void importRegistrations_withoutTitle_shouldNotCreateTutorialGroup() throws Exce // given var group1Id = tutorialGroupUtilService .createTutorialGroup(exampleCourseId, generateRandomTitle(), "LoremIpsum1", 10, false, "LoremIpsum1", Language.ENGLISH.name(), tutor1, Set.of(student1)).getId(); - var group1 = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group1Id).orElseThrow(); + var group1 = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group1Id).orElseThrow(); assertUserIsRegisteredInTutorialWithTitle(group1.getTitle(), student1); // given @@ -803,10 +804,10 @@ void importRegistrations_titleButSameStudentToMultipleGroups_shouldStillCreateTu var group2Id = tutorialGroupUtilService .createTutorialGroup(exampleCourseId, generateRandomTitle(), "LoremIpsum1", 10, false, "LoremIpsum1", Language.ENGLISH.name(), tutor1, Set.of(student2)).getId(); - var group1 = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group1Id).orElseThrow(); - tutorialGroupRegistrationRepository.deleteAllByStudent(student3); - tutorialGroupRegistrationRepository.deleteAllByStudent(student4); - var group2 = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group2Id).orElseThrow(); + var group1 = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group1Id).orElseThrow(); + tutorialGroupRegistrationTestRepository.deleteAllByStudent(student3); + tutorialGroupRegistrationTestRepository.deleteAllByStudent(student4); + var group2 = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(group2Id).orElseThrow(); tutorialGroupChannelManagementService.createChannelForTutorialGroup(group1); tutorialGroupChannelManagementService.createChannelForTutorialGroup(group2); @@ -844,15 +845,15 @@ void importRegistrations_titleButSameStudentToMultipleGroups_shouldStillCreateTu @Test @WithMockUser(username = "admin", roles = "ADMIN") void testDeleteCourseWithTutorialGroups() throws Exception { - var channel = tutorialGroupRepository.getTutorialGroupChannel(exampleOneTutorialGroupId).orElseThrow(); + var channel = tutorialGroupTestRepository.getTutorialGroupChannel(exampleOneTutorialGroupId).orElseThrow(); var post = conversationUtilService.addMessageToConversation(TEST_PREFIX + "student1", channel); request.delete("/api/admin/courses/" + exampleCourseId, HttpStatus.OK); assertThat(courseRepository.findById(exampleCourseId)).isEmpty(); - assertThat(tutorialGroupRepository.findAllByCourseId(exampleCourseId)).isEmpty(); - assertThat(tutorialGroupRepository.getTutorialGroupChannel(exampleOneTutorialGroupId)).isEmpty(); - assertThat(tutorialGroupRepository.getTutorialGroupChannel(exampleTwoTutorialGroupId)).isEmpty(); + assertThat(tutorialGroupTestRepository.findAllByCourseId(exampleCourseId)).isEmpty(); + assertThat(tutorialGroupTestRepository.getTutorialGroupChannel(exampleOneTutorialGroupId)).isEmpty(); + assertThat(tutorialGroupTestRepository.getTutorialGroupChannel(exampleTwoTutorialGroupId)).isEmpty(); assertThat(tutorialGroupsConfigurationRepository.findByCourseIdWithEagerTutorialGroupFreePeriods(exampleCourseId)).isEmpty(); assertThat(postRepository.findById(post.getId())).isEmpty(); } @@ -883,20 +884,21 @@ private List sendImportRequest(List expectedRegisteredStudents, User requestingUser) { @@ -905,7 +907,7 @@ private void assertImportedTutorialGroupWithTitleInDB(String expectedTitle, Set< private void assertTutorialGroupWithTitleInDB(String expectedTitle, Set expectedRegisteredStudents, TutorialGroupRegistrationType expectedRegistrationType, Boolean isOnline, String additionalInformation, Integer capacity, String campus, String language, User teachingAssistant) { - var tutorialGroupOptional = tutorialGroupRepository.findByTitleAndCourseIdWithTeachingAssistantAndRegistrations(expectedTitle, exampleCourseId); + var tutorialGroupOptional = tutorialGroupTestRepository.findByTitleAndCourseIdWithTeachingAssistantAndRegistrations(expectedTitle, exampleCourseId); assertThat(tutorialGroupOptional).isPresent(); var tutorialGroup = tutorialGroupOptional.get(); assertThat(tutorialGroup.getIsOnline()).isEqualTo(isOnline); @@ -971,7 +973,7 @@ private void registerStudentAllowedTest(String loginOfResponsibleUser, boolean e var responsibleUser = userUtilService.getUserByLogin(loginOfResponsibleUser); request.postWithoutResponseBody(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId) + "/register/" + student3.getLogin(), HttpStatus.NO_CONTENT, new LinkedMultiValueMap<>()); - var tutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + var tutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); assertThat(tutorialGroup.getRegistrations().stream().map(TutorialGroupRegistration::getStudent)).contains(student3); verify(singleUserNotificationService).notifyStudentAboutRegistrationToTutorialGroup(tutorialGroup, student3, responsibleUser); if (expectTutorNotification) { @@ -984,9 +986,9 @@ private void registerStudentAllowedTest(String loginOfResponsibleUser, boolean e asserTutorialGroupChannelIsCorrectlyConfigured(tutorialGroup); // remove registration again - var registration = tutorialGroupRegistrationRepository.findTutorialGroupRegistrationByTutorialGroupAndStudentAndType(tutorialGroup, student3, INSTRUCTOR_REGISTRATION) + var registration = tutorialGroupRegistrationTestRepository.findTutorialGroupRegistrationByTutorialGroupAndStudentAndType(tutorialGroup, student3, INSTRUCTOR_REGISTRATION) .orElseThrow(); - tutorialGroupRegistrationRepository.delete(registration); + tutorialGroupRegistrationTestRepository.delete(registration); } private void registerStudentForbiddenTest() throws Exception { @@ -997,7 +999,7 @@ private void registerStudentForbiddenTest() throws Exception { private void deregisterStudentAllowedTest(String loginOfResponsibleUser, boolean expectTutorNotification) throws Exception { var responsibleUser = userUtilService.getUserByLogin(loginOfResponsibleUser); request.delete(getTutorialGroupsPath(exampleCourseId, exampleOneTutorialGroupId) + "/deregister/" + student1.getLogin(), HttpStatus.NO_CONTENT); - TutorialGroup tutorialGroup = tutorialGroupRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); + TutorialGroup tutorialGroup = tutorialGroupTestRepository.findByIdWithTeachingAssistantAndRegistrationsAndSessions(exampleOneTutorialGroupId).orElseThrow(); assertThat(tutorialGroup.getRegistrations().stream().map(TutorialGroupRegistration::getStudent)).doesNotContain(student1); verify(singleUserNotificationService).notifyStudentAboutDeregistrationFromTutorialGroup(tutorialGroup, student1, responsibleUser); if (expectTutorNotification) { @@ -1013,7 +1015,7 @@ private void deregisterStudentAllowedTest(String loginOfResponsibleUser, boolean registration.setStudent(student1); registration.setTutorialGroup(tutorialGroup); registration.setType(INSTRUCTOR_REGISTRATION); - tutorialGroupRegistrationRepository.save(registration); + tutorialGroupRegistrationTestRepository.save(registration); } private void deregisterStudentForbiddenTest() throws Exception { diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupScheduleIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupScheduleIntegrationTest.java index c3fc245f6ec2..6b0ab4262754 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupScheduleIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupScheduleIntegrationTest.java @@ -46,7 +46,7 @@ void createNewTutorialGroupWithSchedule_periodCoversDSTChange_shouldHandleDaylig .getId(); // then - newTutorialGroupCoveringDST = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + newTutorialGroupCoveringDST = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); this.assertTutorialGroupPersistedWithSchedule(newTutorialGroupCoveringDST, scheduleToCreate); var sessions = this.getTutorialGroupSessionsAscending(persistedTutorialGroupId); @@ -54,7 +54,7 @@ void createNewTutorialGroupWithSchedule_periodCoversDSTChange_shouldHandleDaylig var standardTimeSession = sessions.getFirst(); var daylightSavingsTimeSession = sessions.get(1); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(newTutorialGroupCoveringDST.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(newTutorialGroupCoveringDST.getId()).orElseThrow(); this.assertScheduledSessionIsActiveOnDate(standardTimeSession, mondayBeforeDSTSwitch, persistedTutorialGroupId, persistedSchedule); this.assertScheduledSessionIsActiveOnDate(daylightSavingsTimeSession, mondayAfterDSTSwitch, persistedTutorialGroupId, persistedSchedule); @@ -71,14 +71,14 @@ void createNewTutorialGroupWithSchedule_everyTwoWeeks_shouldCreateWithOneWeekPau var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), newTutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); // then - newTutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + newTutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); var sessions = this.getTutorialGroupSessionsAscending(persistedTutorialGroupId); assertThat(sessions).hasSize(2); var firstAugustMondaySession = sessions.getFirst(); var thirdAugustMondaySession = sessions.get(1); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(newTutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(newTutorialGroup.getId()).orElseThrow(); this.assertScheduledSessionIsActiveOnDate(firstAugustMondaySession, FIRST_AUGUST_MONDAY, persistedTutorialGroupId, persistedSchedule); this.assertScheduledSessionIsActiveOnDate(thirdAugustMondaySession, THIRD_AUGUST_MONDAY, persistedTutorialGroupId, persistedSchedule); } @@ -96,10 +96,10 @@ void createNewTutorialGroupWithSchedule_sessionFallsOnTutorialGroupFreeDay_shoul .postWithResponseBody(getTutorialGroupsPath(exampleCourseId), newTutorialGroupCoveringHoliday, TutorialGroup.class, HttpStatus.CREATED).getId(); // then - newTutorialGroupCoveringHoliday = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + newTutorialGroupCoveringHoliday = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); this.assertTutorialGroupPersistedWithSchedule(newTutorialGroupCoveringHoliday, scheduleToCreate); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(newTutorialGroupCoveringHoliday.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(newTutorialGroupCoveringHoliday.getId()).orElseThrow(); var sessions = this.getTutorialGroupSessionsAscending(persistedTutorialGroupId); assertThat(sessions).hasSize(2); @@ -156,13 +156,13 @@ void addScheduleToTutorialGroupWithoutSchedule_asInstructor_shouldAddScheduleAnd request.putWithResponseBody(getTutorialGroupsPath(exampleCourseId, tutorialGroup.getId()), dto, TutorialGroup.class, HttpStatus.OK); // then - var persistedTutorialGroup = tutorialGroupRepository.findByIdElseThrow(tutorialGroup.getId()); + var persistedTutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(tutorialGroup.getId()); var sessions = this.getTutorialGroupSessionsAscending(persistedTutorialGroup.getId()); assertThat(sessions).hasSize(2); var firstAugustMondaySession = sessions.getFirst(); var secondAugustMondaySession = sessions.get(1); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(persistedTutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(persistedTutorialGroup.getId()).orElseThrow(); this.assertScheduledSessionIsActiveOnDate(firstAugustMondaySession, FIRST_AUGUST_MONDAY, tutorialGroup.getId(), persistedSchedule); this.assertScheduledSessionIsActiveOnDate(secondAugustMondaySession, SECOND_AUGUST_MONDAY, tutorialGroup.getId(), persistedSchedule); @@ -183,7 +183,7 @@ void addScheduleToTutorialGroupWithoutSchedule_scheduledSessionFallsOnAlreadyExi // then assertThat(tutorialGroupSessionRepository.findAllByTutorialGroupId(tutorialGroup.getId())).hasSize(1); - assertThat(tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId())).isEmpty(); + assertThat(tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId())).isEmpty(); } @Test @@ -192,18 +192,18 @@ void updateTutorialGroupWithSchedule_NoChangesToSchedule_ShouldNotRecreateSessio // given var tutorialGroup = this.buildTutorialGroupWithExampleSchedule(FIRST_AUGUST_MONDAY, SECOND_AUGUST_MONDAY, "tutor1"); var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); - tutorialGroup = tutorialGroupRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); var sessionIds = tutorialGroup.getTutorialGroupSessions().stream().map(DomainObject::getId).collect(Collectors.toSet()); var scheduleId = tutorialGroup.getTutorialGroupSchedule().getId(); // when - tutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); tutorialGroup.setCapacity(2000); var dto = new TutorialGroupResource.TutorialGroupUpdateDTO(tutorialGroup, "Lorem Ipsum", true); request.putWithResponseBody(getTutorialGroupsPath(exampleCourseId, tutorialGroup.getId()), dto, TutorialGroup.class, HttpStatus.OK); // then - tutorialGroup = tutorialGroupRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); assertThat(tutorialGroup.getCapacity()).isEqualTo(2000); assertThat(tutorialGroup.getTutorialGroupSessions().stream().map(DomainObject::getId).collect(Collectors.toSet())).containsExactlyInAnyOrderElementsOf(sessionIds); assertThat(tutorialGroup.getTutorialGroupSchedule().getId()).isEqualTo(scheduleId); @@ -215,18 +215,18 @@ void updateTutorialGroupWithSchedule_OnlyLocationChanged_ShouldNotRecreateSessio // given var tutorialGroup = this.buildTutorialGroupWithExampleSchedule(FIRST_AUGUST_MONDAY, SECOND_AUGUST_MONDAY, "tutor1"); var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); - tutorialGroup = tutorialGroupRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); var sessionIds = tutorialGroup.getTutorialGroupSessions().stream().map(DomainObject::getId).collect(Collectors.toSet()); var scheduleId = tutorialGroup.getTutorialGroupSchedule().getId(); // when - tutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); tutorialGroup.getTutorialGroupSchedule().setLocation("updated"); var dto = new TutorialGroupResource.TutorialGroupUpdateDTO(tutorialGroup, "Lorem Ipsum", true); request.putWithResponseBody(getTutorialGroupsPath(exampleCourseId, tutorialGroup.getId()), dto, TutorialGroup.class, HttpStatus.OK); // then - tutorialGroup = tutorialGroupRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdWithSessionsElseThrow(persistedTutorialGroupId); assertThat(tutorialGroup.getTutorialGroupSchedule().getLocation()).isEqualTo("updated"); assertThat(tutorialGroup.getTutorialGroupSessions().stream().map(DomainObject::getId).collect(Collectors.toSet())).containsExactlyInAnyOrderElementsOf(sessionIds); assertThat(tutorialGroup.getTutorialGroupSchedule().getId()).isEqualTo(scheduleId); @@ -241,7 +241,7 @@ void modifyExistingScheduleOfTutorialGroup_shouldRecreateScheduledSessionsButKee // given var tutorialGroup = this.buildTutorialGroupWithExampleSchedule(FIRST_AUGUST_MONDAY, SECOND_AUGUST_MONDAY, "tutor1"); var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); - tutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); this.buildAndSaveExampleIndividualTutorialGroupSession(persistedTutorialGroupId, FOURTH_AUGUST_MONDAY_00_00); @@ -256,14 +256,14 @@ void modifyExistingScheduleOfTutorialGroup_shouldRecreateScheduledSessionsButKee request.putWithResponseBody(getTutorialGroupsPath(exampleCourseId, tutorialGroup.getId()), dto, TutorialGroup.class, HttpStatus.OK); // then - tutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); var sessions = this.getTutorialGroupSessionsAscending(tutorialGroup.getId()); assertThat(sessions).hasSize(3); var firstAugustMondaySession = sessions.getFirst(); var thirdAugustMondaySession = sessions.get(1); var fourthAugustMondaySession = sessions.get(2); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); this.assertScheduledSessionIsActiveOnDate(firstAugustMondaySession, FIRST_AUGUST_MONDAY, tutorialGroup.getId(), persistedSchedule); this.assertScheduledSessionIsActiveOnDate(thirdAugustMondaySession, THIRD_AUGUST_MONDAY, tutorialGroup.getId(), persistedSchedule); @@ -278,7 +278,7 @@ void deleteScheduleOfTutorialGroup_shouldDeleteAllScheduledSessionsButKeepIndivi var tutorialGroup = this.buildTutorialGroupWithExampleSchedule(FIRST_AUGUST_MONDAY, SECOND_AUGUST_MONDAY, "tutor1"); var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); this.buildAndSaveExampleIndividualTutorialGroupSession(persistedTutorialGroupId, THIRD_AUGUST_MONDAY_00_00); - tutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); // when tutorialGroup.setTutorialGroupSchedule(null); @@ -298,15 +298,15 @@ void deleteTutorialGroupWithSchedule_shouldDeleteScheduleAndSessions() throws Ex var tutorialGroup = this.buildTutorialGroupWithExampleSchedule(FIRST_AUGUST_MONDAY, SECOND_AUGUST_MONDAY, "tutor1"); var persistedTutorialGroupId = request.postWithResponseBody(getTutorialGroupsPath(exampleCourseId), tutorialGroup, TutorialGroup.class, HttpStatus.CREATED).getId(); this.buildAndSaveExampleIndividualTutorialGroupSession(persistedTutorialGroupId, THIRD_AUGUST_MONDAY_00_00); - tutorialGroup = tutorialGroupRepository.findByIdElseThrow(persistedTutorialGroupId); + tutorialGroup = tutorialGroupTestRepository.findByIdElseThrow(persistedTutorialGroupId); // when request.delete(getTutorialGroupsPath(exampleCourseId, tutorialGroup.getId()), HttpStatus.NO_CONTENT); // then assertThat(tutorialGroupSessionRepository.findAllByTutorialGroupId(tutorialGroup.getId())).isEmpty(); - assertThat(tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId())).isEmpty(); - assertThat(tutorialGroupRepository.findById(tutorialGroup.getId())).isEmpty(); + assertThat(tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId())).isEmpty(); + assertThat(tutorialGroupTestRepository.findById(tutorialGroup.getId())).isEmpty(); } } diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupSessionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupSessionIntegrationTest.java index 44ba7403d1c5..83b9087bd6a8 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupSessionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupSessionIntegrationTest.java @@ -118,7 +118,7 @@ void updateSession_scheduledSession_shouldBeDisconnectedFromSchedule() throws Ex userUtilService.changeUser(testPrefix + "instructor1"); TutorialGroup tutorialGroup = this.setUpTutorialGroupWithSchedule(this.exampleCourseId, "tutor1"); userUtilService.changeUser(testPrefix + "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroup.getId()).orElseThrow(); var sessions = this.getTutorialGroupSessionsAscending(tutorialGroup.getId()); assertThat(sessions).hasSize(2); var firstAugustMondaySession = sessions.getFirst(); diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupsConfigurationIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupsConfigurationIntegrationTest.java index 1569669818ac..dd7b8801006f 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupsConfigurationIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupsConfigurationIntegrationTest.java @@ -17,11 +17,11 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.Language; -import de.tum.cit.aet.artemis.exercise.text.TextExerciseFactory; +import de.tum.cit.aet.artemis.core.user.util.UserFactory; import de.tum.cit.aet.artemis.text.domain.TextExercise; +import de.tum.cit.aet.artemis.text.util.TextExerciseFactory; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSessionStatus; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupsConfiguration; -import de.tum.cit.aet.artemis.user.UserFactory; class TutorialGroupsConfigurationIntegrationTest extends AbstractTutorialGroupIntegrationTest { @@ -230,7 +230,7 @@ void updateCourse_timeZoneChange_deleteTutorialGroupFreePeriodsAndIndividualSess // given var configuration = tutorialGroupUtilService.createTutorialGroupConfiguration(courseId, FIRST_AUGUST_MONDAY, FIRST_SEPTEMBER_MONDAY); var tutorialGroupWithSchedule = setUpTutorialGroupWithSchedule(courseId, "tutor1"); - var persistedSchedule = tutorialGroupScheduleRepository.findByTutorialGroupId(tutorialGroupWithSchedule.getId()).orElseThrow(); + var persistedSchedule = tutorialGroupScheduleTestRepository.findByTutorialGroupId(tutorialGroupWithSchedule.getId()).orElseThrow(); this.buildAndSaveExampleIndividualTutorialGroupSession(tutorialGroupWithSchedule.getId(), FIRST_SEPTEMBER_MONDAY_00_00); tutorialGroupUtilService.addTutorialGroupFreePeriod(configuration.getId(), FOURTH_AUGUST_MONDAY_00_00, FOURTH_AUGUST_MONDAY_00_00, "Holiday"); diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupRegistrationTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupRegistrationTestRepository.java new file mode 100644 index 000000000000..4b91c014ae70 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupRegistrationTestRepository.java @@ -0,0 +1,29 @@ +package de.tum.cit.aet.artemis.tutorialgroups.test_repository; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import de.tum.cit.aet.artemis.core.domain.User; +import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistrationType; +import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRegistrationRepository; + +@Repository +@Primary +public interface TutorialGroupRegistrationTestRepository extends TutorialGroupRegistrationRepository { + + @Transactional // ok because of delete + @Modifying + void deleteAllByStudent(User student); + + @Transactional // ok because of delete + @Modifying + void deleteById(@NotNull Long tutorialGroupRegistrationId); + + boolean existsByTutorialGroupTitleAndStudentAndType(String title, User student, TutorialGroupRegistrationType type); + + Integer countByStudentAndTutorialGroupCourseIdAndType(User student, Long courseId, TutorialGroupRegistrationType type); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupScheduleTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupScheduleTestRepository.java new file mode 100644 index 000000000000..9571f28a2c4b --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupScheduleTestRepository.java @@ -0,0 +1,16 @@ +package de.tum.cit.aet.artemis.tutorialgroups.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSchedule; +import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupScheduleRepository; + +@Repository +@Primary +public interface TutorialGroupScheduleTestRepository extends TutorialGroupScheduleRepository { + + Optional findByTutorialGroupId(Long tutorialGroupId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupTestRepository.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupTestRepository.java new file mode 100644 index 000000000000..75383acde76d --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/test_repository/TutorialGroupTestRepository.java @@ -0,0 +1,28 @@ +package de.tum.cit.aet.artemis.tutorialgroups.test_repository; + +import java.util.Optional; + +import org.springframework.context.annotation.Primary; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; +import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRepository; + +@Repository +@Primary +public interface TutorialGroupTestRepository extends TutorialGroupRepository { + + @Query(""" + SELECT tutorialGroup + FROM TutorialGroup tutorialGroup + LEFT JOIN FETCH tutorialGroup.teachingAssistant + LEFT JOIN FETCH tutorialGroup.registrations + WHERE tutorialGroup.title = :title + AND tutorialGroup.course.id = :courseId + """) + Optional findByTitleAndCourseIdWithTeachingAssistantAndRegistrations(@Param("title") String title, @Param("courseId") Long courseId); + + boolean existsByTitleAndCourseId(String title, Long courseId); +} diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFactory.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/util/TutorialGroupFactory.java similarity index 97% rename from src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFactory.java rename to src/test/java/de/tum/cit/aet/artemis/tutorialgroups/util/TutorialGroupFactory.java index b412b240c78d..1ed5b6beeb7b 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupFactory.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/util/TutorialGroupFactory.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.tutorialgroups; +package de.tum.cit.aet.artemis.tutorialgroups.util; import java.time.LocalDate; import java.time.format.DateTimeFormatter; diff --git a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupUtilService.java b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/util/TutorialGroupUtilService.java similarity index 93% rename from src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupUtilService.java rename to src/test/java/de/tum/cit/aet/artemis/tutorialgroups/util/TutorialGroupUtilService.java index 9663dd183fc3..621f53a19be3 100644 --- a/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/TutorialGroupUtilService.java +++ b/src/test/java/de/tum/cit/aet/artemis/tutorialgroups/util/TutorialGroupUtilService.java @@ -1,4 +1,4 @@ -package de.tum.cit.aet.artemis.tutorialgroups; +package de.tum.cit.aet.artemis.tutorialgroups.util; import static de.tum.cit.aet.artemis.core.util.DateUtil.interpretInTimeZone; import static org.assertj.core.api.Assertions.assertThat; @@ -16,8 +16,8 @@ import de.tum.cit.aet.artemis.core.domain.Course; import de.tum.cit.aet.artemis.core.domain.User; -import de.tum.cit.aet.artemis.core.repository.CourseRepository; -import de.tum.cit.aet.artemis.course.CourseFactory; +import de.tum.cit.aet.artemis.core.test_repository.CourseTestRepository; +import de.tum.cit.aet.artemis.core.util.CourseFactory; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroup; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupFreePeriod; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupRegistration; @@ -26,10 +26,10 @@ import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupSessionStatus; import de.tum.cit.aet.artemis.tutorialgroup.domain.TutorialGroupsConfiguration; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupFreePeriodRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRegistrationRepository; -import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupRepository; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupSessionRepository; import de.tum.cit.aet.artemis.tutorialgroup.repository.TutorialGroupsConfigurationRepository; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupRegistrationTestRepository; +import de.tum.cit.aet.artemis.tutorialgroups.test_repository.TutorialGroupTestRepository; /** * Service responsible for initializing the database with specific testdata related to tutorial groups for use in integration tests. @@ -54,10 +54,10 @@ public class TutorialGroupUtilService { private Optional tutorialGroupInstructors; @Autowired - private CourseRepository courseRepo; + private CourseTestRepository courseRepo; @Autowired - private TutorialGroupRepository tutorialGroupRepository; + private TutorialGroupTestRepository tutorialGroupRepository; @Autowired private TutorialGroupSessionRepository tutorialGroupSessionRepository; @@ -69,7 +69,7 @@ public class TutorialGroupUtilService { private TutorialGroupFreePeriodRepository tutorialGroupFreePeriodRepository; @Autowired - private TutorialGroupRegistrationRepository tutorialGroupRegistrationRepository; + private TutorialGroupRegistrationTestRepository tutorialGroupRegistrationRepository; /** * Creates and saves a Course for TutorialGroup tests. diff --git a/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension index 29dc14fdab36..1c8bac4ed988 100644 --- a/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension +++ b/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension @@ -1,2 +1,2 @@ -de.tum.cit.aet.artemis.util.junit_extensions.AwaitilityExtension -de.tum.cit.aet.artemis.util.junit_extensions.ParallelLoggingExtension +de.tum.cit.aet.artemis.core.util.junit_extensions.AwaitilityExtension +de.tum.cit.aet.artemis.core.util.junit_extensions.ParallelLoggingExtension diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel3v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel3v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/activity/activityModel3v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/activity/activityModel3v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/bpmnModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/bpmnModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/bpmnModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/bpmnModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/bpmnModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/bpmnModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/bpmnModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/bpmnModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/bpmnModel3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/bpmnModel3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/bpmn/bpmnModel3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/bpmn/bpmnModel3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/classdiagram/classModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/classdiagram/classModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/communication/communicationModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/communication/communicationModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel3v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel3v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/component/componentModel3v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/component/componentModel3v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel3v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel3v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/deployment/deploymentModel3v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/deployment/deploymentModel3v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1a.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1a.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1a.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1a.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1av3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1av3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1av3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1av3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1b.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1b.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1b.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1b.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1bv3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1bv3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel1bv3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel1bv3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/flowchart/flowchartModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/flowchart/flowchartModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/object/objectModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/object/objectModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1a.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1a.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1a.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1a.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1av3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1av3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1av3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1av3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1b.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1b.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1b.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1b.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1bv3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1bv3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel1bv3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel1bv3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/petrinet/petriNetModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/petrinet/petriNetModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1a.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1a.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1a.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1a.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1av3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1av3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1av3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1av3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1b.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1b.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1b.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1b.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1bv3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1bv3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1bv3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel1bv3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/syntaxtree/syntaxTreeModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel1.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel1.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel1.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel1.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel1v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel1v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel1v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel1v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel2.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel2.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel2.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel2.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel2v3.json b/src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel2v3.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/modeling/compass/umlmodel/usecase/useCaseModel2v3.json rename to src/test/resources/de/tum/cit/aet/artemis/modeling/compass/umlmodel/usecase/useCaseModel2v3.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/programming/gitlabPushEventRequest.json b/src/test/resources/de/tum/cit/aet/artemis/programming/util/gitlabPushEventRequest.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/programming/gitlabPushEventRequest.json rename to src/test/resources/de/tum/cit/aet/artemis/programming/util/gitlabPushEventRequest.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/programming/gitlabPushEventRequestWithoutCommit.json b/src/test/resources/de/tum/cit/aet/artemis/programming/util/gitlabPushEventRequestWithoutCommit.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/programming/gitlabPushEventRequestWithoutCommit.json rename to src/test/resources/de/tum/cit/aet/artemis/programming/util/gitlabPushEventRequestWithoutCommit.json diff --git a/src/test/resources/de/tum/cit/aet/artemis/exercise/programming/gitlabPushEventRequestWrongCommitOrder.json b/src/test/resources/de/tum/cit/aet/artemis/programming/util/gitlabPushEventRequestWrongCommitOrder.json similarity index 100% rename from src/test/resources/de/tum/cit/aet/artemis/exercise/programming/gitlabPushEventRequestWrongCommitOrder.json rename to src/test/resources/de/tum/cit/aet/artemis/programming/util/gitlabPushEventRequestWrongCommitOrder.json diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml index f98c7180ec7b..c9616a9ff828 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback.xml @@ -4,9 +4,9 @@ - + - + %16.16d{HH:mm:ss.SSS} | %3.3threadId %-16.16thread | %-5level | %-36.36logger{36} : %msg%n