Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Adjust server tests to restructuring into modules #9314

Merged
merged 48 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
83ecf2d
Enable all architecture tests
MaximilianAnzinger Sep 13, 2024
8b43b93
Move architecture tests and object method tests into shared test package
MaximilianAnzinger Sep 13, 2024
adfb778
Restructure integration tests into modules
ole-ve Sep 13, 2024
51a468f
Restructure service tests into modules
ole-ve Sep 13, 2024
ceee431
Merge remote-tracking branch 'origin/develop' into chore/restructure-…
ole-ve Sep 13, 2024
81ff31e
Apply spotless
ole-ve Sep 13, 2024
71bdeec
Fix enforceNothing arch test
ole-ve Sep 13, 2024
52778fb
Fix correctServiceAnnotation arch test
ole-ve Sep 13, 2024
fefb027
Add architecture test to check for test only queries in prod code
MaximilianAnzinger Sep 14, 2024
c563417
Move test repositories to test_repository subdirectory
ole-ve Sep 14, 2024
4ed0b10
Merge remote-tracking branch 'origin/develop' into chore/restructure-…
ole-ve Sep 14, 2024
eb34cd8
Move exercise methods to test repository
MaximilianAnzinger Sep 17, 2024
b5fb222
Merge branch 'develop' into chore/restructure-tests
MaximilianAnzinger Sep 17, 2024
c896c8b
Create ResultTestRepository and improve test repository inheritance
MaximilianAnzinger Sep 19, 2024
ac1887b
Create TutorParticipationTestRepository
MaximilianAnzinger Sep 19, 2024
c468aa2
Create atlas test repositories
MaximilianAnzinger Sep 19, 2024
6db26fe
move test repos into test modules
MaximilianAnzinger Sep 20, 2024
fc4587e
Fix tutorial group repositories
JohannesStoehr Sep 20, 2024
799ac5a
create more test repositories
MaximilianAnzinger Sep 20, 2024
ebc8c8b
Fix text and quiz exercises
JohannesStoehr Sep 20, 2024
681ad06
Merge remote-tracking branch 'origin/chore/restructure-tests' into ch…
JohannesStoehr Sep 20, 2024
f7b9633
Fix check for method references
JohannesStoehr Sep 20, 2024
5d3792f
create more test repositories
MaximilianAnzinger Sep 20, 2024
9fec368
create more test repos
MaximilianAnzinger Sep 20, 2024
573fa81
Fix check for method references and remove unused methods
JohannesStoehr Sep 20, 2024
5f8e55c
add remaining test repos
MaximilianAnzinger Sep 20, 2024
73fc3c1
add more arch tests
MaximilianAnzinger Sep 20, 2024
6786cfe
User group of user in DatabaseQueryCountTest not saved
ole-ve Sep 20, 2024
8699f6a
Replace all usages of prod repo with test repo (if exists)
ole-ve Sep 20, 2024
93c5066
Annotate all test repositories with @Primary to override prod reposit…
ole-ve Sep 20, 2024
72624ee
Add archTest to enforce @Primary annotation on test repositories
ole-ve Sep 20, 2024
f917f45
Remove ToDo
ole-ve Sep 20, 2024
ab4eb7f
Merge remote-tracking branch 'origin/develop' into chore/restructure-…
ole-ve Sep 20, 2024
c267f28
Fix unintentional change
ole-ve Sep 20, 2024
232d809
Fix unintentional change
ole-ve Sep 20, 2024
1dbb3d7
Use ProgrammingExerciseTestRepository instead of ProgrammingExerciseR…
ole-ve Sep 20, 2024
3245271
Add archTest to check that test repositories are used instead of prod…
ole-ve Sep 20, 2024
dde0954
Fix unintentional change
ole-ve Sep 20, 2024
4e68bb7
Disable testCreateAnswerInExamChannel
ole-ve Sep 20, 2024
67105d4
Remove validated todo: https://docs.hazelcast.com/imdg/4.2/configurat…
ole-ve Sep 20, 2024
87c8996
Move JhiMetricsIntegrationTest to core module
ole-ve Sep 20, 2024
d065dc8
move tests from competency package into atlas module
MaximilianAnzinger Sep 21, 2024
520bcc5
fix atlas structure
MaximilianAnzinger Sep 21, 2024
c96f537
move online course tests to lti
MaximilianAnzinger Sep 21, 2024
f861722
Merge branch 'develop' into chore/restructure-tests
MaximilianAnzinger Sep 23, 2024
a4d4947
Merge branch 'develop' into chore/restructure-tests
MaximilianAnzinger Sep 28, 2024
3f77991
Merge branch 'develop' into chore/restructure-tests
MaximilianAnzinger Sep 28, 2024
b2b58e7
Merge remote-tracking branch 'origin/develop' into chore/restructure-…
ole-ve Sep 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
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;
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastStudent;
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 {

Expand All @@ -44,7 +43,6 @@
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()
Expand Down Expand Up @@ -80,11 +78,10 @@
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()
.resideInAPackage(REST_OPEN_PACKAGE + "..");
rule.check(productionClasses);

Check failure on line 85 in src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationArchitectureTest.java

View workflow job for this annotation

GitHub Actions / Java Architecture Tests

de.tum.cit.aet.artemis.authorization.AuthorizationArchitectureTest ► testEnforceNothingAnnotations()

Failed test found in: build/test-results/test/TEST-de.tum.cit.aet.artemis.authorization.AuthorizationArchitectureTest.xml Error: java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'methods that are annotated with @EnforceNothing and are not annotated with @ManualConfig should be declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..'' was violated (4 times):
Raw output
java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'methods that are annotated with @EnforceNothing and are not annotated with @ManualConfig should be declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..'' was violated (4 times):
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setCompetencyExtractionJobStatus(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.competency.PyrisCompetencyStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:116)
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setStatusOfCourseChatJob(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.chat.PyrisChatStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:90)
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setStatusOfIngestionJob(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.lectureingestionwebhook.PyrisLectureIngestionStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:139)
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setStatusOfJob(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.chat.PyrisChatStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:65)
	at com.tngtech.archunit.lang.ArchRule$Assertions.assertNoViolation(ArchRule.java:94)
	at com.tngtech.archunit.lang.ArchRule$Assertions.check(ArchRule.java:86)
	at com.tngtech.archunit.lang.ArchRule$Factory$SimpleArchRule.check(ArchRule.java:165)
	at com.tngtech.archunit.lang.syntax.ObjectsShouldInternal.check(ObjectsShouldInternal.java:81)
	at de.tum.cit.aet.artemis.authorization.AuthorizationArchitectureTest.testEnforceNothingAnnotations(AuthorizationArchitectureTest.java:85)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)

Check failure on line 85 in src/test/java/de/tum/cit/aet/artemis/authorization/AuthorizationArchitectureTest.java

View workflow job for this annotation

GitHub Actions / H2 Tests

de.tum.cit.aet.artemis.authorization.AuthorizationArchitectureTest ► testEnforceNothingAnnotations()

Failed test found in: build/test-results/test/TEST-de.tum.cit.aet.artemis.authorization.AuthorizationArchitectureTest.xml Error: java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'methods that are annotated with @EnforceNothing and are not annotated with @ManualConfig should be declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..'' was violated (4 times):
Raw output
java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'methods that are annotated with @EnforceNothing and are not annotated with @ManualConfig should be declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..'' was violated (4 times):
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setCompetencyExtractionJobStatus(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.competency.PyrisCompetencyStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:116)
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setStatusOfCourseChatJob(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.chat.PyrisChatStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:90)
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setStatusOfIngestionJob(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.lectureingestionwebhook.PyrisLectureIngestionStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:139)
Method <de.tum.cit.aet.artemis.iris.web.PublicPyrisStatusUpdateResource.setStatusOfJob(java.lang.String, de.tum.cit.aet.artemis.iris.service.pyris.dto.chat.PyrisChatStatusUpdateDTO, jakarta.servlet.http.HttpServletRequest)> is not declared in classes that reside in a package 'de.tum.cit.aet.artemis.*.web.open..' in (PublicPyrisStatusUpdateResource.java:65)
	at com.tngtech.archunit.lang.ArchRule$Assertions.assertNoViolation(ArchRule.java:94)
	at com.tngtech.archunit.lang.ArchRule$Assertions.check(ArchRule.java:86)
	at com.tngtech.archunit.lang.ArchRule$Factory$SimpleArchRule.check(ArchRule.java:165)
	at com.tngtech.archunit.lang.syntax.ObjectsShouldInternal.check(ObjectsShouldInternal.java:81)
	at de.tum.cit.aet.artemis.authorization.AuthorizationArchitectureTest.testEnforceNothingAnnotations(AuthorizationArchitectureTest.java:85)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading