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: Remove multiple occurrences of deprecated code #8721

Merged
merged 7 commits into from
Jun 4, 2024

Conversation

MaximilianAnzinger
Copy link
Collaborator

@MaximilianAnzinger MaximilianAnzinger commented Jun 3, 2024

Checklist

General

Motivation and Context

Replaces the following deprecated method calls:

  • isEqualToIgnoringGivenFields
  • isEqualToComparingFieldByField
  • URL constructor
  • mvnRequest.setGoals
  • isEqualToComparingOnlyGivenFields

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

@MaximilianAnzinger MaximilianAnzinger requested a review from a team as a code owner June 3, 2024 15:39
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) labels Jun 3, 2024
Copy link

coderabbitai bot commented Jun 3, 2024

Walkthrough

The changes primarily involve refactoring the code to replace the URL class with the URI class for better handling and flexibility in URL construction and comparison. Additionally, several test assertions have been modified to use recursive comparison methods, enhancing the accuracy and robustness of the tests.

Changes

File Path Change Summary
src/main/java/de/tum/in/www1/artemis/service/connectors/localvc/LocalVCRepositoryUri.java Updated URL class usage to URI in the getGitPartStartIndex method.
src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java Modified assertions to use recursive comparison, ignoring specific fields.
src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java Refactored assertions to use usingRecursiveComparison() and ignoringFields() methods.
src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingAssessmentIntegrationTest.java Updated feedback attribute access and comparison in test methods.
src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java Modified assertions to use recursive comparison, ignoring specific fields.
src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingExerciseTemplateIntegrationTest.java Changed method for setting Maven goals to adding arguments in InvocationRequest.
src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java Modified assertions to use recursive comparison, ignoring specific fields.
src/test/java/de/tum/in/www1/artemis/service/JenkinsInternalUriServiceTest.java Replaced URL object instantiation with URI followed by conversion to URL.
src/test/java/de/tum/in/www1/artemis/service/ResourceLoaderServiceTest.java Replaced URL object instantiation with URI followed by conversion to URL in resource loading test.
src/test/java/de/tum/in/www1/artemis/service/connectors/lti/LtiDeepLinkingServiceTest.java Introduced URISyntaxException handling in method signatures and replaced URL with URI in deep linking tests.
src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java Updated assertion logic for comparing TextBlock objects using recursive comparison.
src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java Updated assertion logic for comparing submissions using recursive comparison with ignored fields.

Sequence Diagram(s) (Beta)

The changes are primarily refactoring and do not significantly alter the control flow or introduce new features. Therefore, no sequence diagrams are necessary at this time.


Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between def46a5 and 53aa3ec.

Files selected for processing (6)
  • src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java (3 hunks)
  • src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java (2 hunks)
  • src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java (1 hunks)
  • src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java (1 hunks)
Additional context used
Path-based instructions (6)
src/test/java/de/tum/in/www1/artemis/text/TextSubmissionIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

Additional comments not posted (8)
src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java (3)

323-324: Great job updating the assertion to use recursive comparison!


345-346: Excellent update to the assertion for handling late submissions.


367-368: Nice work ensuring the recursive comparison is used consistently across different test scenarios.

src/test/java/de/tum/in/www1/artemis/exercise/programming/ProgrammingSubmissionIntegrationTest.java (1)

768-769: Updated assertion to use usingRecursiveComparison().ignoringFields enhances flexibility and maintainability.

src/test/java/de/tum/in/www1/artemis/assessment/AssessmentComplaintIntegrationTest.java (1)

280-281: Great job updating the assertion to use recursive comparison!

This change aligns with the PR's goal to replace deprecated methods with more robust alternatives. It enhances the test's ability to ignore specific fields, which is crucial for focusing on relevant data in complex object graphs.

src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java (2)

587-587: The update to use recursive comparison in assertions is aligned with the PR's objectives and correctly implemented here.

Verification successful

Let's gather more information to ensure the recursive comparison assertion is correctly implemented. We will search for the usage of usingRecursiveComparison and ignoringFields separately to verify their presence and correctness.


The search results confirm that the recursive comparison assertion in ModelingSubmissionIntegrationTest.java is correctly implemented and aligned with the PR's objectives. The necessary fields are correctly ignored in the comparison.

  • src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java: The assertion correctly uses usingRecursiveComparison().ignoringFields("results", "submissionDate", "participation").
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all necessary fields are correctly ignored in the recursive comparison.

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type java $'usingRecursiveComparison().ignoringFields("results", "submissionDate", "participation")'

Length of output: 106



Script:

#!/bin/bash
# Description: Verify the presence and correctness of the recursive comparison assertion.

# Search for the usage of usingRecursiveComparison in the codebase.
rg --type java 'usingRecursiveComparison'

# Search for the usage of ignoringFields in the codebase.
rg --type java 'ignoringFields'

Length of output: 30175


633-634: The update to use recursive comparison in assertions, including ignoring the "similarElementCounts" field, is correctly implemented and aligns with the PR's objectives.

Verification successful

The update to use recursive comparison in assertions, including ignoring the "similarElementCounts" field, is correctly implemented and aligns with the PR's objectives. The necessary fields are correctly ignored in the ModelingSubmissionIntegrationTest.

  • src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java:
    • Line: 633-634
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all necessary fields are correctly ignored in the recursive comparison, including "similarElementCounts".

# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type java $'usingRecursiveComparison().ignoringFields("results", "submissionDate", "participation", "similarElementCounts")'

Length of output: 130



Script:

#!/bin/bash
# Description: Verify the usage of recursive comparison with ignoring fields in the codebase.

# Test: Search for the usage of `usingRecursiveComparison().ignoringFields` in the codebase.
rg --type java 'usingRecursiveComparison().ignoringFields'

Length of output: 60



Script:

#!/bin/bash
# Description: Verify the usage of recursive comparison in the codebase.

# Test: Search for the usage of `usingRecursiveComparison` in the codebase.
rg --type java 'usingRecursiveComparison'

Length of output: 15242



Script:

#!/bin/bash
# Description: Extract the relevant lines from ModelingSubmissionIntegrationTest to verify the ignored fields.

# Test: Extract lines around the usage of `usingRecursiveComparison` in ModelingSubmissionIntegrationTest.
rg --type java -A 5 -B 5 'usingRecursiveComparison' src/test/java/de/tum/in/www1/artemis/exercise/modeling/ModelingSubmissionIntegrationTest.java

Length of output: 1847

src/test/java/de/tum/in/www1/artemis/text/TextAssessmentIntegrationTest.java (1)

1340-1341: The updated assertion logic using usingRecursiveComparison().ignoringFields is more robust and flexible.

This change aligns with the PR's goal to replace deprecated methods with more modern and flexible alternatives. It's great to see the use of ignoringFields to specify exactly which fields should be ignored in the comparison, enhancing the test's specificity and reliability.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 3, 2024
Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests with usingRecursiveComparison().ignoringFields(...) seam to fail

@Strohgelaender
Copy link
Contributor

The recursive comparator does not work since the old method uses the equals-method all top-level fields (where in the most cases then just a comparison by ID is performed) whereas the recursive comparator checks every field recursively leading to many differences (because relations are not loaded and so on). You can replace that by explicit isEqualTo assertions on the checked fields.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Copy link
Contributor

@Strohgelaender Strohgelaender left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm now

@krusche krusche added this to the 7.1.2 milestone Jun 4, 2024
@krusche krusche merged commit 7eed1c7 into develop Jun 4, 2024
22 of 27 checks passed
@krusche krusche deleted the chore/development/remove-deprecated-code branch June 4, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality server Pull requests that update Java code. (Added Automatically!) tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants