-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development: Refactor lti tests (#9375)
- Loading branch information
1 parent
e5d9c6c
commit 93138e3
Showing
9 changed files
with
117 additions
and
55 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/test/java/de/tum/cit/aet/artemis/atlas/architecture/AtlasTestArchitectureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.tum.cit.aet.artemis.atlas.architecture; | ||
|
||
import de.tum.cit.aet.artemis.atlas.AbstractAtlasIntegrationTest; | ||
import de.tum.cit.aet.artemis.shared.architecture.AbstractModuleTestArchitectureTest; | ||
|
||
class AtlasTestArchitectureTest extends AbstractModuleTestArchitectureTest<AbstractAtlasIntegrationTest> { | ||
|
||
@Override | ||
protected String getModulePackageName() { | ||
return "atlas"; | ||
} | ||
|
||
@Override | ||
protected Class<AbstractAtlasIntegrationTest> getAbstractModuleIntegrationTestClass() { | ||
return AbstractAtlasIntegrationTest.class; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/test/java/de/tum/cit/aet/artemis/lti/AbstractLtiIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package de.tum.cit.aet.artemis.lti; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import de.tum.cit.aet.artemis.core.util.RequestUtilService; | ||
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.lti.test_repository.OnlineCourseConfigurationTestRepository; | ||
import de.tum.cit.aet.artemis.programming.util.ProgrammingExerciseUtilService; | ||
import de.tum.cit.aet.artemis.quiz.service.QuizExerciseService; | ||
import de.tum.cit.aet.artemis.quiz.service.QuizSubmissionService; | ||
import de.tum.cit.aet.artemis.quiz.test_repository.QuizExerciseTestRepository; | ||
import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; | ||
|
||
public abstract class AbstractLtiIntegrationTest extends AbstractSpringIntegrationIndependentTest { | ||
|
||
// Repositories | ||
@Autowired | ||
protected OnlineCourseConfigurationTestRepository onlineCourseConfigurationRepository; | ||
|
||
// External Repositories | ||
@Autowired | ||
protected QuizExerciseTestRepository quizExerciseTestRepository; | ||
|
||
@Autowired | ||
protected SubmissionTestRepository submissionRepository; | ||
|
||
// External Services | ||
@Autowired | ||
protected QuizExerciseService quizExerciseService; | ||
|
||
@Autowired | ||
protected QuizSubmissionService quizSubmissionService; | ||
|
||
// External Util Services | ||
@Autowired | ||
protected ProgrammingExerciseUtilService programmingExerciseUtilService; | ||
|
||
@Autowired | ||
protected ParticipationUtilService participationUtilService; | ||
|
||
@Autowired | ||
protected RequestUtilService request; | ||
|
||
// Misc | ||
@Autowired | ||
protected ObjectMapper objectMapper; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/test/java/de/tum/cit/aet/artemis/lti/architecture/LtiTestArchitectureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.tum.cit.aet.artemis.lti.architecture; | ||
|
||
import de.tum.cit.aet.artemis.lti.AbstractLtiIntegrationTest; | ||
import de.tum.cit.aet.artemis.shared.architecture.AbstractModuleTestArchitectureTest; | ||
|
||
class LtiTestArchitectureTest extends AbstractModuleTestArchitectureTest<AbstractLtiIntegrationTest> { | ||
|
||
@Override | ||
protected String getModulePackageName() { | ||
return "lti"; | ||
} | ||
|
||
@Override | ||
protected Class<AbstractLtiIntegrationTest> getAbstractModuleIntegrationTestClass() { | ||
return AbstractLtiIntegrationTest.class; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...t/java/de/tum/cit/aet/artemis/shared/architecture/AbstractModuleTestArchitectureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.tum.cit.aet.artemis.shared.architecture; | ||
|
||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; | ||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noMembers; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public abstract class AbstractModuleTestArchitectureTest<T> extends AbstractArchitectureTest { | ||
|
||
abstract protected String getModulePackageName(); | ||
|
||
abstract protected Class<T> getAbstractModuleIntegrationTestClass(); | ||
|
||
@Test | ||
void integrationTestsShouldExtendAbstractModuleIntegrationTest() { | ||
classes().that().resideInAPackage(ARTEMIS_PACKAGE + "." + getModulePackageName()).and().haveSimpleNameEndingWith("IntegrationTest").should() | ||
.beAssignableTo(getAbstractModuleIntegrationTestClass()).because("All integration tests should extend %s".formatted(getAbstractModuleIntegrationTestClass())) | ||
.check(testClasses); | ||
} | ||
|
||
@Test | ||
void integrationTestsShouldNotAutowireMembers() { | ||
noMembers().that().areAnnotatedWith(Autowired.class).should().beDeclaredInClassesThat().areAssignableTo(getAbstractModuleIntegrationTestClass()).andShould() | ||
.notBeDeclaredIn(getAbstractModuleIntegrationTestClass()) | ||
.because("Integration tests should not autowire members in any class that inherits from %s".formatted(getAbstractModuleIntegrationTestClass())).check(testClasses); | ||
} | ||
} |