From dc7ee51b52ebcc856161e01d60ca60c85cf42937 Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Mon, 3 Jun 2024 17:09:37 +0200 Subject: [PATCH 1/6] replace isEqualToIgnoringGivenFields --- .../AssessmentComplaintIntegrationTest.java | 2 +- .../FileUploadSubmissionIntegrationTest.java | 12 ++++++------ .../modeling/ModelingSubmissionIntegrationTest.java | 4 ++-- .../ProgrammingSubmissionIntegrationTest.java | 2 +- .../artemis/text/TextSubmissionIntegrationTest.java | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java index 80bb76625af9..c8f0864e7412 100644 --- a/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java @@ -277,7 +277,7 @@ void submitComplaintResponse_rejectComplaint() throws Exception { Result storedResult = resultRepo.findWithBidirectionalSubmissionAndFeedbackAndAssessorAndAssessmentNoteAndTeamStudentsByIdElseThrow(modelingAssessment.getId()); Result updatedResult = storedResult.getSubmission().getLatestResult(); participationUtilService.checkFeedbackCorrectlyStored(modelingAssessment.getFeedbacks(), updatedResult.getFeedbacks(), FeedbackType.MANUAL); - assertThat(storedResult).as("only feedbacks are changed in the result").isEqualToIgnoringGivenFields(modelingAssessment, "feedbacks"); + assertThat(storedResult).as("only feedbacks are changed in the result").usingRecursiveComparison().ignoringFields("feedbacks").isEqualTo(modelingAssessment); } @Test diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java index a2e9521123d8..f066eac99461 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java @@ -320,8 +320,8 @@ void getSubmissionWithoutAssessment() throws Exception { FileUploadSubmission storedSubmission = request.get("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submission-without-assessment", HttpStatus.OK, FileUploadSubmission.class); - assertThat(storedSubmission).as("in-time submission was found").isEqualToIgnoringGivenFields(submission, "results", "submissionDate", "fileService", "filePathService", - "entityFileService"); + assertThat(storedSubmission).as("in-time submission was found").usingRecursiveComparison() + .ignoringFields("results", "submissionDate", "fileService", "filePathService", "entityFileService").isEqualTo(submission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(submission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); checkDetailsHidden(storedSubmission, false); @@ -342,8 +342,8 @@ void getLateSubmissionWithoutAssessment() throws Exception { FileUploadSubmission storedSubmission = request.get("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submission-without-assessment", HttpStatus.OK, FileUploadSubmission.class); - assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(lateSubmission, "result", "submissionDate", "fileService", "filePathService", - "entityFileService"); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison() + .ignoringFields("results", "submissionDate", "fileService", "filePathService", "entityFileService").isEqualTo(lateSubmission); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); checkDetailsHidden(storedSubmission, false); } @@ -364,8 +364,8 @@ void testGetLateSubmissionWithoutAssessmentLock() throws Exception { FileUploadSubmission storedSubmission = request.get("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submission-without-assessment?lock=true", HttpStatus.OK, FileUploadSubmission.class); - assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(lateSubmission, "results", "submissionDate", "fileService", "filePathService", - "entityFileService"); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison() + .ignoringFields("results", "submissionDate", "fileService", "filePathService", "entityFileService").isEqualTo(lateSubmission); assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull(); checkDetailsHidden(storedSubmission, false); } diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java index daeb1332fe06..e8b9c827d674 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java @@ -584,7 +584,7 @@ void getModelSubmissionWithoutAssessment() throws Exception { ModelingSubmission storedSubmission = request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment", HttpStatus.OK, ModelingSubmission.class); - assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(submission, "results", "submissionDate"); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate").isEqualTo(submission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(submission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); checkDetailsHidden(storedSubmission, false); @@ -630,7 +630,7 @@ void getModelSubmissionWithoutAssessment_lockSubmission() throws Exception { // set dates to UTC and round to milliseconds for comparison submission.setSubmissionDate(ZonedDateTime.ofInstant(submission.getSubmissionDate().truncatedTo(ChronoUnit.SECONDS).toInstant(), ZoneId.of("UTC"))); storedSubmission.setSubmissionDate(ZonedDateTime.ofInstant(storedSubmission.getSubmissionDate().truncatedTo(ChronoUnit.SECONDS).toInstant(), ZoneId.of("UTC"))); - assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(submission, "results", "similarElementCounts"); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate").isEqualTo(submission); assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull(); assertThat(storedSubmission.getLatestResult().getAssessor()).as("assessor is tutor1").isEqualTo(user); checkDetailsHidden(storedSubmission, false); diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java index cc4451d5a70b..e70aa5e4c528 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java @@ -765,7 +765,7 @@ void testGetProgrammingSubmissionWithoutAssessment() throws Exception { String url = "/api/exercises/" + exercise.getId() + "/programming-submission-without-assessment"; ProgrammingSubmission storedSubmission = request.get(url, HttpStatus.OK, ProgrammingSubmission.class); - assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(submission, "results", "submissionDate"); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate").isEqualTo(submission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(submission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); } diff --git a/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java index 65fdda3ce838..101e095b7a01 100644 --- a/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java @@ -277,7 +277,7 @@ void getTextSubmissionWithoutAssessment_lockSubmission() throws Exception { TextSubmission storedSubmission = request.get("/api/exercises/" + finishedTextExercise.getId() + "/text-submission-without-assessment?lock=true", HttpStatus.OK, TextSubmission.class); - assertThat(storedSubmission).as("submission was found").isEqualToIgnoringGivenFields(textSubmission, "results", "submissionDate", "blocks"); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate", "blocks").isEqualTo(textSubmission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(textSubmission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull(); assertThat(storedSubmission.getLatestResult().getAssessor()).as("assessor is tutor1").isEqualTo(user); From d3cb28f03c3c4a72941dfc623ab868db1f386648 Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Mon, 3 Jun 2024 17:12:01 +0200 Subject: [PATCH 2/6] replace isEqualToComparingFieldByField --- .../tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java index 06420317800e..39537c889962 100644 --- a/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java @@ -1337,7 +1337,7 @@ void testConsecutiveSaveFailsAfterAddingOrRemovingReferencedFeedback() throws Ex verify(textBlockService, times(irrelevantCallCount + 3)).findAllBySubmissionId(textSubmission.getId()); Set textBlocks = textBlockRepository.findAllBySubmissionId(textSubmissionWithoutAssessment.getId()); - assertThat(textBlocks).allSatisfy(block -> assertThat(block).isEqualToComparingFieldByField(blocksSubmission.get(block.getId()))); + assertThat(textBlocks).allSatisfy(block -> assertThat(block).usingRecursiveComparison().isEqualTo(blocksSubmission.get(block.getId()))); } /** From 4f5d9d6ea1e365e849284f4ffcc3394bf3b8d238 Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Mon, 3 Jun 2024 17:22:41 +0200 Subject: [PATCH 3/6] replace URL constructor --- .../connectors/localvc/LocalVCRepositoryUri.java | 4 ++-- .../service/JenkinsInternalUriServiceTest.java | 9 +++++---- .../service/ResourceLoaderServiceTest.java | 3 ++- .../connectors/lti/LtiDeepLinkingServiceTest.java | 15 ++++++++------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCRepositoryUri.java b/src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCRepositoryUri.java index a22079cc7fe8..b2be0a17c29c 100644 --- a/src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCRepositoryUri.java +++ b/src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCRepositoryUri.java @@ -148,12 +148,12 @@ private static int getGitPartStartIndex(String urlString, Path urlPath) throws L *
    *
  • * Input: Local repository path - {@code Paths.get("/local/path/projectX/my-repo/.git")} - * and Local VC server URL - {@code new URL("https://artemis.cit.tum.de")} + * and Local VC server URL - {@code new URI("https://artemis.cit.tum.de").getURL()} * Output: {@code https://artemis.cit.tum.de/git/projectX/my-repo.git} *
  • *
  • * Input: Remote repository path - {@code Paths.get("/remote/path/projectY/my-repo")} - * and Local VC server URL - {@code new URL("https://artemis.cit.tum.de")} + * and Local VC server URL - {@code new URI("https://artemis.cit.tum.de").getURL()} * Output: {@code https://artemis.cit.tum.de/git/projectY/my-repo.git} *
  • *
diff --git a/src/test/java/de/tum/in/www1/artemis/service/JenkinsInternalUriServiceTest.java b/src/test/java/de/tum/in/www1/artemis/service/JenkinsInternalUriServiceTest.java index 28b0adb59cb4..c44461f54e98 100644 --- a/src/test/java/de/tum/in/www1/artemis/service/JenkinsInternalUriServiceTest.java +++ b/src/test/java/de/tum/in/www1/artemis/service/JenkinsInternalUriServiceTest.java @@ -7,6 +7,7 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Optional; @@ -37,8 +38,8 @@ class JenkinsInternalUriServiceTest extends AbstractSpringIntegrationJenkinsGitl void initTestCase() throws Exception { vcsRepositoryUri = new VcsRepositoryUri("http://localhost:80/some-repo.git"); ciUrl = "http://localhost:8080/some-ci-path"; - internalVcsUrl = new URL("http://1.2.3.4:123"); - internalCiUrl = new URL("http://5.6.7.8:123"); + internalVcsUrl = new URI("http://1.2.3.4:123").toURL(); + internalCiUrl = new URI("http://5.6.7.8:123").toURL(); ReflectionTestUtils.setField(jenkinsInternalUrlService, "internalVcsUrl", Optional.empty()); ReflectionTestUtils.setField(jenkinsInternalUrlService, "internalCiUrl", Optional.empty()); } @@ -93,8 +94,8 @@ void testGetCiUrlOnInternalCiUrl() { @Test void testGetUrlOnInternalUrlWithoutPort() throws Exception { - ReflectionTestUtils.setField(jenkinsInternalUrlService, "internalCiUrl", Optional.of(new URL("http://www.host.name.com/"))); - ReflectionTestUtils.setField(jenkinsInternalUrlService, "internalVcsUrl", Optional.of(new URL("http://www.hostname.com/"))); + ReflectionTestUtils.setField(jenkinsInternalUrlService, "internalCiUrl", Optional.of(new URI("http://www.host.name.com/").toURL())); + ReflectionTestUtils.setField(jenkinsInternalUrlService, "internalVcsUrl", Optional.of(new URI("http://www.hostname.com/").toURL())); var newVcsUrl = jenkinsInternalUrlService.toInternalVcsUrl(vcsRepositoryUri); assertThat(newVcsUrl).hasToString("http://www.hostname.com/some-repo.git"); diff --git a/src/test/java/de/tum/in/www1/artemis/service/ResourceLoaderServiceTest.java b/src/test/java/de/tum/in/www1/artemis/service/ResourceLoaderServiceTest.java index 341778e5d68a..85239865dd8a 100644 --- a/src/test/java/de/tum/in/www1/artemis/service/ResourceLoaderServiceTest.java +++ b/src/test/java/de/tum/in/www1/artemis/service/ResourceLoaderServiceTest.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; @@ -131,7 +132,7 @@ private void setupJavaFiles(final String content) throws IOException { void testGetResourceFilePathFromJar() throws IOException, URISyntaxException { ResourceLoader resourceLoader = mock(ResourceLoader.class); Resource resource = mock(Resource.class); - URL resourceUrl = new URL("jar:file:/example.jar!/path/to/resource.txt"); + URL resourceUrl = new URI("jar:file:/example.jar!/path/to/resource.txt").toURL(); // Mock the getResource() method. doReturn(true).when(resource).exists(); diff --git a/src/test/java/de/tum/in/www1/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java b/src/test/java/de/tum/in/www1/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java index f29e605c573d..db1ef62c884c 100644 --- a/src/test/java/de/tum/in/www1/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java +++ b/src/test/java/de/tum/in/www1/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java @@ -8,7 +8,8 @@ import static org.mockito.Mockito.when; import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Arrays; @@ -71,7 +72,7 @@ void tearDown() throws Exception { } @Test - void testPerformDeepLinking() throws MalformedURLException { + void testPerformDeepLinking() throws MalformedURLException, URISyntaxException { createMockOidcIdToken(); when(tokenRetriever.createDeepLinkingJWT(anyString(), anyMap())).thenReturn("test_jwt"); @@ -83,7 +84,7 @@ void testPerformDeepLinking() throws MalformedURLException { } @Test - void testEmptyJwtBuildLtiDeepLinkResponse() throws MalformedURLException { + void testEmptyJwtBuildLtiDeepLinkResponse() throws MalformedURLException, URISyntaxException { createMockOidcIdToken(); when(tokenRetriever.createDeepLinkingJWT(anyString(), anyMap())).thenReturn(null); @@ -95,7 +96,7 @@ void testEmptyJwtBuildLtiDeepLinkResponse() throws MalformedURLException { } @Test - void testEmptyReturnUrlBuildLtiDeepLinkResponse() throws JsonProcessingException, MalformedURLException { + void testEmptyReturnUrlBuildLtiDeepLinkResponse() throws JsonProcessingException, MalformedURLException, URISyntaxException { createMockOidcIdToken(); when(tokenRetriever.createDeepLinkingJWT(anyString(), anyMap())).thenReturn("test_jwt"); ObjectMapper mapper = new ObjectMapper(); @@ -134,7 +135,7 @@ void testEmptyReturnUrlBuildLtiDeepLinkResponse() throws JsonProcessingException } @Test - void testEmptyDeploymentIdBuildLtiDeepLinkResponse() throws MalformedURLException { + void testEmptyDeploymentIdBuildLtiDeepLinkResponse() throws MalformedURLException, URISyntaxException { createMockOidcIdToken(); when(tokenRetriever.createDeepLinkingJWT(anyString(), anyMap())).thenReturn("test_jwt"); when(oidcIdToken.getClaim(de.tum.in.www1.artemis.domain.lti.Claims.LTI_DEPLOYMENT_ID)).thenReturn(null); @@ -145,7 +146,7 @@ void testEmptyDeploymentIdBuildLtiDeepLinkResponse() throws MalformedURLExceptio .withMessage("Missing claim: " + Claims.LTI_DEPLOYMENT_ID); } - private void createMockOidcIdToken() throws MalformedURLException { + private void createMockOidcIdToken() throws MalformedURLException, URISyntaxException { Map mockSettings = new TreeMap<>(); mockSettings.put("deep_link_return_url", "test_return_url"); when(oidcIdToken.getClaim(Claims.DEEP_LINKING_SETTINGS)).thenReturn(mockSettings); @@ -154,7 +155,7 @@ private void createMockOidcIdToken() throws MalformedURLException { when(oidcIdToken.getClaim("exp")).thenReturn("12345"); when(oidcIdToken.getClaim("iat")).thenReturn("test"); when(oidcIdToken.getClaim("nonce")).thenReturn("1234-34535-abcbcbd"); - when(oidcIdToken.getIssuer()).thenReturn(new URL("http://artemis.com")); + when(oidcIdToken.getIssuer()).thenReturn(new URI("http://artemis.com").toURL()); when(oidcIdToken.getAudience()).thenReturn(Arrays.asList("http://moodle.com")); when(oidcIdToken.getExpiresAt()).thenReturn(Instant.now().plus(2, ChronoUnit.HOURS)); when(oidcIdToken.getIssuedAt()).thenReturn(Instant.now()); From 84e4b4fe8b1d039e7ec1b2c43eb71b774931beb4 Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Mon, 3 Jun 2024 17:24:46 +0200 Subject: [PATCH 4/6] replace setGoals --- .../programming/ProgrammingExerciseTemplateIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java index 121488751dc2..3e1c06217bfb 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java @@ -306,7 +306,7 @@ private int invokeMaven(boolean testwiseCoverageAnalysis) throws MavenInvocation InvocationRequest mvnRequest = new DefaultInvocationRequest(); mvnRequest.setJavaHome(java17Home); mvnRequest.setPomFile(testRepo.localRepoFile); - mvnRequest.setGoals(List.of("clean", "test")); + mvnRequest.addArgs(List.of("clean", "test")); if (testwiseCoverageAnalysis) { mvnRequest.addArg("-Pcoverage"); } From def46a5fba3a68d166514201129dc3f6600e126e Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Mon, 3 Jun 2024 17:33:20 +0200 Subject: [PATCH 5/6] replace isEqualToComparingOnlyGivenFields --- .../ModelingAssessmentIntegrationTest.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java index 2d6df5ca0c63..7d38150fc5e1 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java @@ -1054,10 +1054,12 @@ void testOverrideAutomaticAssessment_existingManualAssessmentDoesNotChange() thr modelingAssessment = resultRepo.findDistinctWithFeedbackBySubmissionId(modelingSubmission2.getId()).orElseThrow(); assertThat(modelingAssessment.getFeedbacks()).as("assessment is correctly stored").hasSize(1); - assertThat(modelingAssessment.getFeedbacks().get(0)).as("feedback credits and text are correct").isEqualToComparingOnlyGivenFields(changedFeedback, "credits", "text"); + assertThat(modelingAssessment.getFeedbacks().getFirst().getCredits()).as("feedback credits are correct").isEqualTo(changedFeedback.getCredits()); + assertThat(modelingAssessment.getFeedbacks().getFirst().getText()).as("feedback text are correct").isEqualTo(changedFeedback.getText()); modelingAssessment = resultRepo.findDistinctWithFeedbackBySubmissionId(modelingSubmission.getId()).orElseThrow(); assertThat(modelingAssessment.getFeedbacks()).as("existing manual assessment has correct amount of feedback").hasSize(1); - assertThat(modelingAssessment.getFeedbacks().get(0)).as("existing manual assessment did not change").isEqualToComparingOnlyGivenFields(originalFeedback, "credits", "text"); + assertThat(modelingAssessment.getFeedbacks().getFirst().getCredits()).as("existing manual assessment did not change credits").isEqualTo(originalFeedback.getCredits()); + assertThat(modelingAssessment.getFeedbacks().getFirst().getText()).as("existing manual assessment did not change text").isEqualTo(originalFeedback.getText()); } @Test @@ -1080,11 +1082,12 @@ void testOverrideSubmittedManualAssessment_noConflict() throws Exception { modelingAssessment = resultRepo.findDistinctWithFeedbackBySubmissionId(modelingSubmission.getId()).orElseThrow(); assertThat(modelingAssessment.getFeedbacks()).as("overridden assessment has correct amount of feedback").hasSize(1); - assertThat(modelingAssessment.getFeedbacks().get(0)).as("feedback is properly overridden").isEqualToComparingOnlyGivenFields(changedFeedback, "credits", "text"); + assertThat(modelingAssessment.getFeedbacks().getFirst().getCredits()).as("feedback credits are properly overridden").isEqualTo(changedFeedback.getCredits()); + assertThat(modelingAssessment.getFeedbacks().getFirst().getText()).as("feedback text is properly overridden").isEqualTo(changedFeedback.getText()); modelingAssessment = compassService.getSuggestionResult(modelingSubmission2, classExercise); assertThat(modelingAssessment.getFeedbacks()).as("automatic assessment still exists").hasSize(1); - assertThat(modelingAssessment.getFeedbacks().get(0)).as("automatic assessment is overridden properly").isEqualToComparingOnlyGivenFields(changedFeedback, "credits", - "text"); + assertThat(modelingAssessment.getFeedbacks().getFirst().getCredits()).as("automatic assessment credits are overridden properly").isEqualTo(changedFeedback.getCredits()); + assertThat(modelingAssessment.getFeedbacks().getFirst().getText()).as("automatic assessment text is overridden properly").isEqualTo(changedFeedback.getText()); } @Test @@ -1112,10 +1115,12 @@ void testOverrideSubmittedManualAssessment_conflict() throws Exception { modelingAssessment = resultRepo.findDistinctWithFeedbackBySubmissionId(modelingSubmission.getId()).orElseThrow(); assertThat(modelingAssessment.getFeedbacks()).as("overridden assessment has correct amount of feedback").hasSize(2); - assertThat(modelingAssessment.getFeedbacks().get(0)).as("feedback is properly overridden").isEqualToComparingOnlyGivenFields(changedFeedback, "credits", "text"); + assertThat(modelingAssessment.getFeedbacks().getFirst().getCredits()).as("feedback credits are properly overridden").isEqualTo(changedFeedback.getCredits()); + assertThat(modelingAssessment.getFeedbacks().getFirst().getText()).as("feedback text is properly overridden").isEqualTo(changedFeedback.getText()); modelingAssessment = resultRepo.findDistinctWithFeedbackBySubmissionId(modelingSubmission2.getId()).orElseThrow(); assertThat(modelingAssessment.getFeedbacks()).as("existing submitted assessment still exists").hasSize(2); - assertThat(modelingAssessment.getFeedbacks().get(0)).as("existing feedback is still the same").isEqualToComparingOnlyGivenFields(originalFeedback, "credits", "text"); + assertThat(modelingAssessment.getFeedbacks().getFirst().getCredits()).as("existing feedback credits are still the same").isEqualTo(originalFeedback.getCredits()); + assertThat(modelingAssessment.getFeedbacks().getFirst().getText()).as("existing feedback text is still the same").isEqualTo(originalFeedback.getText()); modelingAssessment = compassService.getSuggestionResult(modelingSubmission3, classExercise); assertThat(modelingAssessment).as("automatic assessment is not possible").isNull(); From 616cad803520c1a4d716948b611d623b15633c2f Mon Sep 17 00:00:00 2001 From: Maximilian Anzinger Date: Tue, 4 Jun 2024 16:16:49 +0200 Subject: [PATCH 6/6] adjust ignored fields --- .../AssessmentComplaintIntegrationTest.java | 3 ++- .../FileUploadSubmissionIntegrationTest.java | 12 ++++++------ .../modeling/ModelingSubmissionIntegrationTest.java | 5 +++-- .../ProgrammingSubmissionIntegrationTest.java | 3 ++- .../artemis/text/TextAssessmentIntegrationTest.java | 3 ++- .../artemis/text/TextSubmissionIntegrationTest.java | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java index c8f0864e7412..0087be32e985 100644 --- a/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java @@ -277,7 +277,8 @@ void submitComplaintResponse_rejectComplaint() throws Exception { Result storedResult = resultRepo.findWithBidirectionalSubmissionAndFeedbackAndAssessorAndAssessmentNoteAndTeamStudentsByIdElseThrow(modelingAssessment.getId()); Result updatedResult = storedResult.getSubmission().getLatestResult(); participationUtilService.checkFeedbackCorrectlyStored(modelingAssessment.getFeedbacks(), updatedResult.getFeedbacks(), FeedbackType.MANUAL); - assertThat(storedResult).as("only feedbacks are changed in the result").usingRecursiveComparison().ignoringFields("feedbacks").isEqualTo(modelingAssessment); + final String[] ignoringFields = { "feedbacks", "submission", "participation", "assessor" }; + assertThat(storedResult).as("only feedbacks are changed in the result").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(modelingAssessment); } @Test diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java index f066eac99461..3aa49a34d264 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java @@ -320,8 +320,8 @@ void getSubmissionWithoutAssessment() throws Exception { FileUploadSubmission storedSubmission = request.get("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submission-without-assessment", HttpStatus.OK, FileUploadSubmission.class); - assertThat(storedSubmission).as("in-time submission was found").usingRecursiveComparison() - .ignoringFields("results", "submissionDate", "fileService", "filePathService", "entityFileService").isEqualTo(submission); + final String[] ignoringFields = { "results", "submissionDate", "fileService", "filePathService", "entityFileService", "participation" }; + assertThat(storedSubmission).as("in-time submission was found").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(submission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(submission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); checkDetailsHidden(storedSubmission, false); @@ -342,8 +342,8 @@ void getLateSubmissionWithoutAssessment() throws Exception { FileUploadSubmission storedSubmission = request.get("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submission-without-assessment", HttpStatus.OK, FileUploadSubmission.class); - assertThat(storedSubmission).as("submission was found").usingRecursiveComparison() - .ignoringFields("results", "submissionDate", "fileService", "filePathService", "entityFileService").isEqualTo(lateSubmission); + final String[] ignoringFields = { "results", "submissionDate", "fileService", "filePathService", "entityFileService", "participation" }; + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(lateSubmission); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); checkDetailsHidden(storedSubmission, false); } @@ -364,8 +364,8 @@ void testGetLateSubmissionWithoutAssessmentLock() throws Exception { FileUploadSubmission storedSubmission = request.get("/api/exercises/" + releasedFileUploadExercise.getId() + "/file-upload-submission-without-assessment?lock=true", HttpStatus.OK, FileUploadSubmission.class); - assertThat(storedSubmission).as("submission was found").usingRecursiveComparison() - .ignoringFields("results", "submissionDate", "fileService", "filePathService", "entityFileService").isEqualTo(lateSubmission); + final String[] ignoringFields = { "results", "submissionDate", "fileService", "filePathService", "entityFileService", "participation" }; + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(lateSubmission); assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull(); checkDetailsHidden(storedSubmission, false); } diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java index e8b9c827d674..e93f47d56a05 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java @@ -584,7 +584,7 @@ void getModelSubmissionWithoutAssessment() throws Exception { ModelingSubmission storedSubmission = request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment", HttpStatus.OK, ModelingSubmission.class); - assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate").isEqualTo(submission); + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate", "participation").isEqualTo(submission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(submission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); checkDetailsHidden(storedSubmission, false); @@ -630,7 +630,8 @@ void getModelSubmissionWithoutAssessment_lockSubmission() throws Exception { // set dates to UTC and round to milliseconds for comparison submission.setSubmissionDate(ZonedDateTime.ofInstant(submission.getSubmissionDate().truncatedTo(ChronoUnit.SECONDS).toInstant(), ZoneId.of("UTC"))); storedSubmission.setSubmissionDate(ZonedDateTime.ofInstant(storedSubmission.getSubmissionDate().truncatedTo(ChronoUnit.SECONDS).toInstant(), ZoneId.of("UTC"))); - assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate").isEqualTo(submission); + final String[] ignoringFields = { "results", "submissionDate", "participation", "similarElementCounts" }; + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(submission); assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull(); assertThat(storedSubmission.getLatestResult().getAssessor()).as("assessor is tutor1").isEqualTo(user); checkDetailsHidden(storedSubmission, false); diff --git a/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java index e70aa5e4c528..e5bad186e55c 100644 --- a/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java @@ -765,7 +765,8 @@ void testGetProgrammingSubmissionWithoutAssessment() throws Exception { String url = "/api/exercises/" + exercise.getId() + "/programming-submission-without-assessment"; ProgrammingSubmission storedSubmission = request.get(url, HttpStatus.OK, ProgrammingSubmission.class); - assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate").isEqualTo(submission); + final String[] ignoringFields = { "results", "submissionDate", "participation" }; + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(submission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(submission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is not set").isNull(); } diff --git a/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java index 39537c889962..4936bebbd6ec 100644 --- a/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java @@ -1337,7 +1337,8 @@ void testConsecutiveSaveFailsAfterAddingOrRemovingReferencedFeedback() throws Ex verify(textBlockService, times(irrelevantCallCount + 3)).findAllBySubmissionId(textSubmission.getId()); Set textBlocks = textBlockRepository.findAllBySubmissionId(textSubmissionWithoutAssessment.getId()); - assertThat(textBlocks).allSatisfy(block -> assertThat(block).usingRecursiveComparison().isEqualTo(blocksSubmission.get(block.getId()))); + final String[] ignoringFields = { "submission.results", "submission.submissionDate", "submission.participation", "submission.blocks", "submission.versions" }; + assertThat(textBlocks).allSatisfy(block -> assertThat(block).usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(blocksSubmission.get(block.getId()))); } /** diff --git a/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java index 101e095b7a01..e4779c7569ff 100644 --- a/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java @@ -277,7 +277,8 @@ void getTextSubmissionWithoutAssessment_lockSubmission() throws Exception { TextSubmission storedSubmission = request.get("/api/exercises/" + finishedTextExercise.getId() + "/text-submission-without-assessment?lock=true", HttpStatus.OK, TextSubmission.class); - assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields("results", "submissionDate", "blocks").isEqualTo(textSubmission); + final String[] ignoringFields = { "results", "submissionDate", "blocks", "participation" }; + assertThat(storedSubmission).as("submission was found").usingRecursiveComparison().ignoringFields(ignoringFields).isEqualTo(textSubmission); assertThat(storedSubmission.getSubmissionDate()).as("submission date is correct").isCloseTo(textSubmission.getSubmissionDate(), HalfSecond()); assertThat(storedSubmission.getLatestResult()).as("result is set").isNotNull(); assertThat(storedSubmission.getLatestResult().getAssessor()).as("assessor is tutor1").isEqualTo(user);