diff --git a/src/test/java/de/tum/cit/aet/artemis/fileupload/AbstractFileUploadIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/AbstractFileUploadIntegrationTest.java new file mode 100644 index 000000000000..6c6ff7719640 --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/AbstractFileUploadIntegrationTest.java @@ -0,0 +1,81 @@ +package de.tum.cit.aet.artemis.fileupload; + +import org.springframework.beans.factory.annotation.Autowired; + +import de.tum.cit.aet.artemis.assessment.repository.ComplaintRepository; +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.ComplaintUtilService; +import de.tum.cit.aet.artemis.atlas.competency.util.CompetencyUtilService; +import de.tum.cit.aet.artemis.communication.repository.conversation.ChannelRepository; +import de.tum.cit.aet.artemis.core.util.PageableSearchUtilService; +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.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.exercise.test_repository.SubmissionTestRepository; +import de.tum.cit.aet.artemis.fileupload.repository.FileUploadExerciseRepository; +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.util.ModelingExerciseUtilService; +import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; + +public class AbstractFileUploadIntegrationTest extends AbstractSpringIntegrationIndependentTest { + + // Repositories + @Autowired + protected FileUploadExerciseRepository fileUploadExerciseRepository; + + // External Repositories + @Autowired + protected ComplaintRepository complaintRepository; + + @Autowired + protected SubmissionTestRepository submissionRepository; + + @Autowired + protected ExamRepository examRepository; + + @Autowired + protected StudentParticipationTestRepository studentParticipationRepository; + + @Autowired + protected FeedbackRepository feedbackRepository; + + @Autowired + protected GradingCriterionRepository gradingCriterionRepository; + + @Autowired + protected ChannelRepository channelRepository; + + @Autowired + protected ParticipationTestRepository participationRepository; + + // Services + @Autowired + protected FileUploadSubmissionRepository fileUploadSubmissionRepository; + + // Util Services + @Autowired + protected FileUploadExerciseUtilService fileUploadExerciseUtilService; + + // External Util Services + @Autowired + protected ParticipationUtilService participationUtilService; + + @Autowired + protected ExamUtilService examUtilService; + + @Autowired + protected ComplaintUtilService complaintUtilService; + + @Autowired + protected PageableSearchUtilService pageableSearchUtilService; + + @Autowired + protected CompetencyUtilService competencyUtilService; + + @Autowired + protected ModelingExerciseUtilService modelingExerciseUtilService; +} diff --git a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java index ca1177b834fb..763f80e3be0d 100644 --- a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadAssessmentIntegrationTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.util.LinkedMultiValueMap; @@ -30,65 +29,28 @@ 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.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.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.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.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 { +class FileUploadAssessmentIntegrationTest extends AbstractFileUploadIntegrationTest { private static final String TEST_PREFIX = "fileuploadassessment"; public static final String API_FILE_UPLOAD_SUBMISSIONS = "/api/file-upload-submissions/"; - @Autowired - private ComplaintRepository complaintRepo; - - @Autowired - private FileUploadExerciseRepository fileUploadExerciseRepository; - - @Autowired - private SubmissionTestRepository submissionRepository; - - @Autowired - private ExamRepository examRepository; - - @Autowired - private StudentParticipationTestRepository studentParticipationRepository; - - @Autowired - private FileUploadExerciseUtilService fileUploadExerciseUtilService; - - @Autowired - private ParticipationUtilService participationUtilService; - - @Autowired - private ExamUtilService examUtilService; - - @Autowired - private ComplaintUtilService complaintUtilService; - private FileUploadExercise afterReleaseFileUploadExercise; private Course course; @@ -206,7 +168,7 @@ void testUpdateFileUploadAssessmentAfterComplaint_studentHidden() throws Excepti Result fileUploadAssessment = fileUploadSubmission.getLatestResult(); Complaint complaint = new Complaint().result(fileUploadAssessment).complaintText("This is not fair"); - complaint = complaintRepo.save(complaint); + complaint = complaintRepository.save(complaint); complaint.getResult().setParticipation(null); // Break infinite reference chain ComplaintResponse complaintResponse = complaintUtilService.createInitialEmptyResponse(TEST_PREFIX + "tutor2", complaint); diff --git a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java index 131eeaec747b..d1deb2f81694 100644 --- a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadExerciseIntegrationTest.java @@ -25,7 +25,6 @@ import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; @@ -33,68 +32,27 @@ 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.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.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.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.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.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 { +class FileUploadExerciseIntegrationTest extends AbstractFileUploadIntegrationTest { private static final String TEST_PREFIX = "fileuploaderxercise"; - @Autowired - private FeedbackRepository feedbackRepository; - - @Autowired - private GradingCriterionRepository gradingCriterionRepository; - - @Autowired - private FileUploadExerciseRepository fileUploadExerciseRepository; - - @Autowired - private StudentParticipationTestRepository studentParticipationRepository; - - @Autowired - private ChannelRepository channelRepository; - - @Autowired - private FileUploadExerciseUtilService fileUploadExerciseUtilService; - - @Autowired - private ExamUtilService examUtilService; - - @Autowired - private ParticipationUtilService participationUtilService; - - @Autowired - private PageableSearchUtilService pageableSearchUtilService; - - @Autowired - private CompetencyUtilService competencyUtilService; - private FileUploadExercise fileUploadExercise; private Course course; diff --git a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java index 7d88ad1e0b01..645e472b4672 100644 --- a/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; @@ -38,36 +37,15 @@ 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.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.modeling.util.ModelingExerciseUtilService; -import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; -class FileUploadSubmissionIntegrationTest extends AbstractSpringIntegrationIndependentTest { +class FileUploadSubmissionIntegrationTest extends AbstractFileUploadIntegrationTest { private static final String TEST_PREFIX = "fileuploadsubmission"; - @Autowired - private FileUploadSubmissionRepository fileUploadSubmissionRepository; - - @Autowired - private ParticipationTestRepository participationRepository; - - @Autowired - private FileUploadExerciseUtilService fileUploadExerciseUtilService; - - @Autowired - private ParticipationUtilService participationUtilService; - - @Autowired - private ModelingExerciseUtilService modelingExerciseUtilService; - private FileUploadExercise releasedFileUploadExercise; private FileUploadExercise finishedFileUploadExercise; diff --git a/src/test/java/de/tum/cit/aet/artemis/fileupload/architecture/FileUploadTestArchitectureTest.java b/src/test/java/de/tum/cit/aet/artemis/fileupload/architecture/FileUploadTestArchitectureTest.java new file mode 100644 index 000000000000..f67db93f311f --- /dev/null +++ b/src/test/java/de/tum/cit/aet/artemis/fileupload/architecture/FileUploadTestArchitectureTest.java @@ -0,0 +1,17 @@ +package de.tum.cit.aet.artemis.fileupload.architecture; + +import de.tum.cit.aet.artemis.fileupload.AbstractFileUploadIntegrationTest; +import de.tum.cit.aet.artemis.shared.architecture.module.AbstractModuleTestArchitectureTest; + +class FileUploadTestArchitectureTest extends AbstractModuleTestArchitectureTest { + + @Override + public String getModulePackage() { + return ARTEMIS_PACKAGE + ".fileupload"; + } + + @Override + protected Class getAbstractModuleIntegrationTestClass() { + return AbstractFileUploadIntegrationTest.class; + } +}