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

Conversation

MaximilianAnzinger
Copy link
Collaborator

@MaximilianAnzinger MaximilianAnzinger commented Sep 13, 2024

Checklist

General

Motivation and Context

After restructuring the server (prod) module structure, these changes adjust the test-code structure to the new prod-code structure.

Note: Most of the changes just come from moving files and methods.

Description

In detail, this includes:

  • Moving tests to the same modules in test code that exist in prod code incl. adjusting (file) paths
  • Adding test_repository subpackage to each module if this module uses a test repository
  • Each existing TestRepository implements the respective (prod) Repository. If such a test repository exists, the prod repository must not be used in any test (-> arch test)
  • Methods in prod repositories that are only used by test code must reside in the respective test repository (arch test)
  • Each TestRepository must be annotated with @primary as otherwise, this causes conflicts with the prod-repository (arch test)
  • AnswerMessageIntegrationTest#testCreateAnswerInExamChannel has been disabled. This test fails with JsonException No _valueDeserializer assigned but only if run as part of the whole test suite. The root cause for this issue is unclear.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Summary by CodeRabbit

  • Bug Fixes

    • Removed several methods from various repository interfaces, which may affect how users retrieve specific data.
    • Adjusted the functionality for retrieving user and course-related data, streamlining the user experience.
  • Chores

    • Reorganized the AuditResource class into a more specific package for better project structure.

@MaximilianAnzinger MaximilianAnzinger requested a review from a team as a code owner September 13, 2024 11:19
Copy link

coderabbitai bot commented Sep 13, 2024

Walkthrough

The pull request involves the removal of several methods from various repository interfaces in the codebase. These changes affect how certain entities, such as CompetencyProgress, LearningPath, ScienceEvent, and User, can be queried. The modifications streamline the repository interfaces by eliminating methods that may no longer be necessary or relevant, thus simplifying the overall code structure.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/atlas/repository/CompetencyProgressRepository.java Method removed: findByCompetencyIdAndUserIdOrElseThrow(long competencyId, long userId).
src/main/java/de/tum/cit/aet/artemis/atlas/repository/LearningPathRepository.java Method removed: findWithEagerCompetenciesByCourseIdAndUserIdElseThrow(long courseId, long userId).
src/main/java/de/tum/cit/aet/artemis/atlas/repository/ScienceEventRepository.java Method removed: findAllByType(ScienceEventType type).
src/main/java/de/tum/cit/aet/artemis/communication/repository/ConversationParticipantRepository.java Method removed: findConversationParticipantByConversationIdAndUserIdElseThrow(Long conversationId, Long userId).
src/main/java/de/tum/cit/aet/artemis/communication/repository/PostRepository.java Method removed: findPostsByAuthorIdAndCourseId(@Param("authorId") long authorId, @Param("courseId") long courseId).
src/main/java/de/tum/cit/aet/artemis/communication/repository/ReactionRepository.java Methods removed: findReactionsByPostId(Long postId), findReactionsByAnswerPostId(Long answerPostId).
src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ChannelRepository.java Method removed: findCourseWideChannelsInCourse(@Param("courseId") long courseId).
src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/ConversationRepository.java Method removed: List<Conversation> findAllByCourseId(long courseId);.
src/main/java/de/tum/cit/aet/artemis/communication/repository/conversation/OneToOneChatRepository.java Method removed: findByIdWithConversationParticipantsAndUserGroups(@Param("oneToOneChatId") Long oneToOneChatId).
src/main/java/de/tum/cit/aet/artemis/core/repository/CourseRepository.java Methods removed: findWithEagerLearningPathsAndCompetenciesAndPrerequisitesById(long courseId), default Course findWithEagerLearningPathsAndCompetenciesAndPrerequisitesByIdElseThrow(long courseId).
src/main/java/de/tum/cit/aet/artemis/core/repository/DataExportRepository.java Method removed: findAllSuccessfullyCreatedDataExports().
src/main/java/de/tum/cit/aet/artemis/core/repository/UserRepository.java Multiple methods removed related to user learning paths and deletion status.

Possibly related PRs

Suggested labels

code quality, small, maintainer-approved

Suggested reviewers

  • JohannesStoehr
  • krusche
  • pzdr7
  • EneaGore
  • coolchock
  • Strohgelaender

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

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.

@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) labels Sep 13, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 13, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 13, 2024
cremertim
cremertim previously approved these changes Sep 28, 2024
Copy link
Contributor

@cremertim cremertim left a comment

Choose a reason for hiding this comment

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

Re-approve after new commit

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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between a4d4947 and b2b58e7.

📒 Files selected for processing (6)
  • src/main/java/de/tum/cit/aet/artemis/assessment/repository/ComplaintResponseRepository.java (0 hunks)
  • src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java (0 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java (0 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java (0 hunks)
  • src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.java (2 hunks)
  • src/test/java/de/tum/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.java (3 hunks)
💤 Files not reviewed due to no reviewable changes (4)
  • src/main/java/de/tum/cit/aet/artemis/assessment/repository/ComplaintResponseRepository.java
  • src/main/java/de/tum/cit/aet/artemis/assessment/repository/ResultRepository.java
  • src/main/java/de/tum/cit/aet/artemis/exercise/repository/SubmissionRepository.java
  • src/main/java/de/tum/cit/aet/artemis/programming/repository/ProgrammingExerciseRepository.java
🧰 Additional context used
📓 Path-based instructions (2)
src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.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/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.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

📓 Learnings (1)
src/test/java/de/tum/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.java (1)
Learnt from: Strohgelaender
PR: ls1intum/Artemis#8030
File: src/main/java/de/tum/in/www1/artemis/service/CourseScoreCalculationService.java:21-49
Timestamp: 2024-02-16T16:56:16.054Z
Learning: The project consistently avoids using star-imports in Java files.
🔇 Additional comments (6)
src/test/java/de/tum/cit/aet/artemis/assessment/TutorEffortIntegrationTest.java (4)

21-22: LGTM: Import statements updated correctly.

The import statements have been updated to use the new test repository classes, which aligns with the PR objective of adjusting server tests to the restructured modules. The naming convention for test repositories is consistent, using the "Test" suffix.

Also applies to: 25-26


60-60: LGTM: Test case initialization updated correctly.

The initTestCase method has been updated to use the new TextSubmissionTestRepository, which aligns with the PR objective of adjusting server tests to the restructured modules. The method name, although long, is descriptive and follows the Spring Data naming conventions.


63-63: LGTM: User repository updated to test repository.

The change from userRepository to userTestRepository is consistent with the overall shift to using test repositories in this integration test. This aligns with the PR objectives and maintains consistency with other test repository usage in the file.


Line range hint 1-143: Overall assessment: Changes align with PR objectives.

The modifications to TutorEffortIntegrationTest.java successfully implement the transition to test repositories, which aligns with the PR objective of adjusting server tests to the restructured modules. The existing test logic remains unchanged, maintaining the current test coverage.

A minor naming inconsistency was noted for one repository field, but this doesn't impact functionality. Consider addressing this for improved code consistency.

The changes in this file appear to be ready for merging, pending the suggested minor improvement.

src/test/java/de/tum/cit/aet/artemis/assessment/service/CourseScoreCalculationServiceTest.java (2)

1-1: Package structure change aligns with modular restructuring.

The package change from de.tum.cit.aet.artemis.service to de.tum.cit.aet.artemis.assessment.service appropriately reflects the assessment-specific nature of this service, aligning with the PR's objective of restructuring the code into modules.


52-58: Variable type updates align with test repository usage.

The changes from StudentParticipationRepository to StudentParticipationTestRepository and ResultRepository to ResultTestRepository are consistent with the PR objective of using test repositories in place of production repositories for tests. This separation enhances the distinction between test and production code, promoting better maintainability and reducing potential conflicts.

Copy link
Contributor

@raffifasaro raffifasaro left a comment

Choose a reason for hiding this comment

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

code LGTM

@krusche krusche merged commit c7ccd42 into develop Sep 28, 2024
19 of 24 checks passed
@krusche krusche deleted the chore/restructure-tests branch September 28, 2024 15:52
@krusche krusche added this to the 7.5.5 milestone Sep 28, 2024
@coderabbitai coderabbitai bot mentioned this pull request Sep 28, 2024
6 tasks
@krusche krusche modified the milestones: 7.5.5, 7.5.6 Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Archived in project
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants