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: Prevent exception in Iris for inactive exercises #10099

Merged
merged 8 commits into from
Jan 4, 2025

Conversation

krusche
Copy link
Member

@krusche krusche commented Jan 2, 2025

Checklist

General

  • I tested all changes and their related features with all corresponding user types on a test server.
  • This is a small issue that I tested locally and was confirmed by another developer on a test server.
  • I chose a title conforming to the naming conventions for pull requests.

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Motivation and Context

This PR suppresses exceptions that should NOT be thrown. It also tries to prevent unnecessary database calls when Iris is active globally, but not active for an exercise. Additionally, it improves data privacy by not executing

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise
  1. Activate Iris globally
  2. Disabled Iris for the programming exercise
  3. Produce a few pro-active events by creating e.g. build fails.
  4. Make sure there are no exceptions in the server logs

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a method to check if a user has accepted the Iris privacy policy.
    • Introduced a new repository for managing Iris exercise settings.
    • Added ability to check if exercise chat is enabled.
  • Refactor

    • Updated method signatures in various services to support asynchronous processing.
    • Simplified variable declarations using var keyword.
    • Enhanced error handling and condition checking in services.
  • Bug Fixes

    • Improved clarity in test assertions for Docker image removal.
    • Adjusted timing for message sending verifications in websocket tests.
  • Chores

    • Removed and re-added mock services in test configurations.
    • Updated test integration setup for more robust event verification.

…ure is disabled for this exercise for proactive events
remove exception test because this is not easily possible with async annotations
@krusche krusche requested a review from a team as a code owner January 2, 2025 19:57
Copy link

coderabbitai bot commented Jan 2, 2025

Warning

Rate limit exceeded

@krusche has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9aedbd5 and 7f50805.

📒 Files selected for processing (1)
  • src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (2 hunks)

Walkthrough

The pull request introduces several modifications across multiple Java files in the Artemis project. The changes primarily focus on enhancing the Iris integration, improving event handling, and refactoring service methods. Key modifications include updating the ResultService method signature, adding Iris-related repository and service methods, introducing asynchronous processing for event services, and updating test configurations. The changes aim to streamline result management, improve event processing, and provide more robust handling of Iris-related functionalities.

Changes

File Change Summary
ResultService.java Modified createNewRatedManualResult method to return void instead of Result
ResultWebsocketService.java Updated local variable declaration using var in broadcastNewResultToParticipants method
User.java Added hasAcceptedIris() method to check Iris privacy policy acceptance
IrisExerciseChatSessionRepository.java Removed query implementation and modified method logic for finding chat sessions
IrisExerciseSettingsRepository.java Added new repository interface with isExerciseChatEnabled method
PyrisEventService.java Added @Async annotation to trigger method for asynchronous event processing
LtiNewResultService.java Added @Async annotation to onNewResult method
ProgrammingMessagingService.java Updated constructor to include IrisExerciseSettingsRepository and modified result notification logic
PyrisEventSystemIntegrationTest.java Removed service dependencies and enhanced event verification logic
AbstractSpringIntegrationLocalCILocalVCTest.java Reorganized @MockitoSpyBean annotations for various services
BuildAgentDockerServiceTest.java Changed verification from times(0) to never() for clarity in testDeleteOldDockerImages_NoOutdatedImages method
ParticipationTeamWebsocketServiceTest.java Updated verification timing from timeout(2000) to after(1000) for message sending assertions

Possibly related PRs

Suggested labels

ready for review, bugfix

Suggested reviewers

  • Hialus
  • BBesrour
  • SimonEntholzer

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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!) assessment Pull requests that affect the corresponding module core Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module lti Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module labels Jan 2, 2025
@krusche krusche added this to the 7.8.1 milestone Jan 2, 2025
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

🧹 Nitpick comments (10)
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java (3)

61-62: **Consider avoiding Optional fields **

Using Optional as a field can introduce complexity when get() is called without checking isPresent(). If Iris is disabled, this may lead to NoSuchElementException. One recommendation is to inject a no-op, mock, or disabled instance instead, allowing you to avoid dealing with Optional calls throughout the code.


67-68: **Constructor expansion increases complexity **

The constructor is becoming quite large with multiple optional dependencies. Consider refactoring or using a builder pattern if future expansions continue; however, it is acceptable in its current state.


216-216: **Local variable usage **

Using final var exercise is convenient. Ensure a consistent approach (var vs. explicit type) throughout the codebase per your convention.

src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisEventService.java (1)

45-45: **Asynchronous event trigger **

Making trigger asynchronous is beneficial. Consider clarifying concurrency expectations (e.g., thread pool size) in the docstring, especially if events can be numerous.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java (5)

247-247: Prefer using never() instead of times(0).
This will improve readability by explicitly stating no invocations are expected.

-        verify(pyrisEventService, times(0)).trigger(new NewResultEvent(result));
+        verify(pyrisEventService, never()).trigger(new NewResultEvent(result));

261-262: Typographical fix in the inline comment.
Minor typo: "very" → "verify".

-        // very that the event is not fired
+        // verify that the event is not fired

285-288: Use never() instead of times(0) to clarify zero invocations.

-            verify(pyrisPipelineService, times(0)).executeExerciseChatPipeline(any(), any(), any(), any(), any());
+            verify(pyrisPipelineService, never()).executeExerciseChatPipeline(any(), any(), any(), any(), any());

301-301: Use never() for zero-invocation verification.

-        verify(irisExerciseChatSessionService, times(0)).onNewResult(any(Result.class));
+        verify(irisExerciseChatSessionService, never()).onNewResult(any(Result.class));

316-316: Consistent usage of never().
Applying the same reasoning for zero-invocation checks.

-        verify(irisExerciseChatSessionService, times(0)).onNewResult(any(Result.class));
+        verify(irisExerciseChatSessionService, never()).onNewResult(any(Result.class));
src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.java (1)

189-191: New spy for PyrisEventService.
Ensure that partial mocking is actually necessary; otherwise a pure mock might suffice.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82bf67c and 74cf26f.

📒 Files selected for processing (10)
  • src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/assessment/web/ResultWebsocketService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/core/domain/User.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisExerciseChatSessionRepository.java (0 hunks)
  • src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisExerciseSettingsRepository.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisEventService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/lti/service/LtiNewResultService.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java (4 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java (8 hunks)
  • src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.java (3 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisExerciseChatSessionRepository.java
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/de/tum/cit/aet/artemis/assessment/web/ResultWebsocketService.java
🧰 Additional context used
📓 Path-based instructions (8)
src/main/java/de/tum/cit/aet/artemis/core/domain/User.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisEventService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/lti/service/LtiNewResultService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisExerciseSettingsRepository.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.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/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.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/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

🔇 Additional comments (19)
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java (5)

31-31: **New Iris repository import **

This import is used to support the new field irisExerciseSettingsRepository. Nothing problematic here.


74-74: **Field assignment verified **

Assigning the irisExerciseSettingsRepository field in the constructor is correct and consistent with Spring’s constructor injection.


203-205: **Extended documentation for Iris notification **

These comments clearly outline the conditions to notify Iris. The explanation helps maintainers reason about when notifications are skipped.


214-214: **Java instanceof pattern matching **

Utilizing Java’s pattern matching for instanceof is concise and readable—well done.


218-225: **Exception handling block **

The try/catch logs errors without interrupting user-facing flows. This is consistent with the asynchronous approach in Iris.

src/main/java/de/tum/cit/aet/artemis/iris/repository/IrisExerciseSettingsRepository.java (2)

13-15: **Repository interface declaration **

Declaring a dedicated repository for Iris exercise settings aligns well with the single responsibility principle.


17-23: **Check @Query syntax validity **

Using SELECT EXISTS(s) in JPQL is unusual. Some JPA providers might require COUNT(s) > 0 instead. Verify that this query runs successfully across all supported database engines.

✅ Verification successful

Let me gather more information about the query usage and database configuration.


Let me check for similar query patterns to see how existence checks are typically done in this codebase.


Let me check for similar queries in the codebase to understand the common patterns.


Let me try a different search pattern to find similar queries.


Let me check the database configuration and similar queries with a different approach.


Based on the database configuration showing support for H2, PostgreSQL, and MySQL dialects, and the fact that SELECT EXISTS(s) is a standard JPQL/HQL syntax supported across these dialects, I can provide the final response:

SELECT EXISTS(s) is a valid JPQL syntax for existence checks

The query syntax used in isExerciseChatEnabled is valid and supported across all configured database dialects (H2, PostgreSQL, and MySQL). While COUNT(s) > 0 is an alternative approach, the current EXISTS syntax is more efficient as it stops searching once a match is found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Searching for references to isExerciseChatEnabled to see if query usage is tested
rg --context 5 "isExerciseChatEnabled"

Length of output: 2705


Script:

#!/bin/bash
# Check for test files related to IrisExerciseSettings
fd "IrisExerciseSettings.*Test" --type f

# Look for database configuration and JPA provider
rg -g "application*.{yml,properties}" "spring.jpa|hibernate"

# Check for similar EXISTS queries in the codebase
ast-grep --pattern 'SELECT EXISTS'

Length of output: 5267


Script:

#!/bin/bash
# Look for similar existence check queries with different patterns
rg -g "*.java" "SELECT.*FROM.*WHERE.*EXISTS|SELECT.*COUNT.*FROM"

# Check for other repository files to see query patterns
fd "Repository.java$" --type f --exec head -n 50 {}

Length of output: 65838


Script:

#!/bin/bash
# Look for EXISTS queries in JPQL
rg -g "*.java" "SELECT\s+EXISTS|SELECT\s+CASE.*EXISTS"

# Look for similar boolean return type queries
rg -g "*.java" "@Query.*\n.*SELECT.*\n.*\).*boolean.*"

Length of output: 423


Script:

#!/bin/bash
# Look for boolean return type queries with better pattern
rg -g "*.java" -U "boolean.*\{.*@Query.*SELECT"

# Look for count-based existence checks
rg -g "*.java" -U "@Query.*SELECT COUNT.*FROM.*WHERE.*boolean"

Length of output: 114


Script:

#!/bin/bash
# Check database configuration and dialect
rg -g "application*.yml" "database-platform|hibernate.dialect"

# Look for similar boolean queries with a simpler pattern
rg -g "*.java" "boolean.*@Query"

Length of output: 554

src/main/java/de/tum/cit/aet/artemis/lti/service/LtiNewResultService.java (2)

6-6: **Asynchronous method import **

Importing @Async is consistent with the non-blocking approach.


26-26: **@Async on onNewResult **

Making onNewResult asynchronous prevents blocking calls and enhances scalability. No concurrency hazards detected since lti13Service usage is straightforward.

src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/PyrisEventService.java (2)

8-8: **Async annotation import **

This is aligned with the approach taken in LtiNewResultService, supporting non-blocking event handling.


51-51: **Log level switch from info to debug **

Switching to debug reduces log noise while preserving trace details for troubleshooting.

Also applies to: 56-56

src/main/java/de/tum/cit/aet/artemis/core/domain/User.java (1)

537-539: **hasAcceptedIris method introduced **

This boolean check is straightforward and consistent. Good use of a distinct method to clarify user acceptance logic.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java (4)

90-96: Good approach for replicating realistic user acceptance conditions.
No issues detected with setting irisAcceptedTimestamp for these test users.


188-190: Confirm that 2-second wait is sufficient for asynchronous steps.
If there are intermittent timing issues on slower CI machines, consider increasing the await() duration.


210-211: Well-structured test for asynchronous event triggers.
The combination of trigger and await().atMost(...) is aligned with best practices for async verifications.


215-216: Succinct event validation.
LGTM, the verification logic is clear and includes essential parameters.

src/test/java/de/tum/cit/aet/artemis/shared/base/AbstractSpringIntegrationLocalCILocalVCTest.java (2)

76-76: Import for PyrisEventService aligns with usage in the test context.
Looks correct, no star imports used.


147-161: Re-introduction of @MockitoSpyBean fields.
Confirm that these spy beans are actually used in the test suite, as extraneous injections may slow down tests.

src/main/java/de/tum/cit/aet/artemis/assessment/service/ResultService.java (1)

201-202: Verify calling code compatibility after changing return type to void.
Removing the return value is fine if no callers rely on the Result object. Double-check for potential breaks or call-site assumptions.

ole-ve
ole-ve previously approved these changes Jan 3, 2025
Copy link
Contributor

@ole-ve ole-ve left a comment

Choose a reason for hiding this comment

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

code looks good, only two nitpicks

SimonEntholzer
SimonEntholzer previously approved these changes Jan 3, 2025
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Did not see any exceptions on Ts3 nor on staging while testing this

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 4, 2025
@github-actions github-actions bot added buildagent Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module labels Jan 4, 2025
ole-ve

This comment was marked as outdated.

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

🧹 Nitpick comments (2)
src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationTeamWebsocketServiceTest.java (1)

143-143: Asynchronous no-invocation check is clear.

Using after(1000).never() effectively asserts no calls after waiting a short period. Just watch out for potential test flakiness if system load varies.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java (1)

91-97: User acceptance timestamps are now set to a day ago.

This ensures tests accurately reflect a past acceptance date. Confirm there's no off-by-one or timezone mismatch in edge cases.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e395120 and 9aedbd5.

📒 Files selected for processing (4)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java (4 hunks)
  • src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationTeamWebsocketServiceTest.java (4 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingMessagingService.java
🧰 Additional context used
📓 Path-based instructions (3)
src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.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/iris/PyrisEventSystemIntegrationTest.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/exercise/service/ParticipationTeamWebsocketServiceTest.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 (13)
src/test/java/de/tum/cit/aet/artemis/buildagent/service/BuildAgentDockerServiceTest.java (1)

86-86: Nice usage of never() for clarifying no invocations.

Replacing times(0) with never() improves test readability and conveys the intent more clearly.

src/test/java/de/tum/cit/aet/artemis/exercise/service/ParticipationTeamWebsocketServiceTest.java (3)

5-5: Good use of after() for asynchronous verification.

This approach can help avoid false positives in asynchronous tests. Ensure the chosen delay is large enough for all expected operations without making the test too slow.


156-156: Consistent approach to ensuring non-invocation in async context.

This matches the logic in the previous test method, aiding maintainability and clarity.


167-169: Both verifications use after().never().

It's consistent to verify no calls to different methods here. Keep an eye on test durations to ensure these checks don't introduce unnecessary delays.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisEventSystemIntegrationTest.java (9)

8-8: Importing never() aligns with best practices.

This import clarifies the intent to ensure zero method invocations. Great for readability.


189-191: Awaiting assertion for onNewResult call is a good async testing strategy.

Waiting before asserting helps avoid race conditions in asynchronous test scenarios.


211-212: Use of await() for verifying build failure flow is appropriate.

Ensures that asynchronous code has run before final assertions.


216-217: Verifying pipeline execution with times(1) after awaiting.

This is consistent with the build-failed test pattern. Fine approach for asynchronous verifications.


248-248: Using never() for disabled events.

This effectively confirms that no event was triggered. Matches the intended function of disabled event types.


262-263: Again, never() clarifies that no event should be triggered.

This ensures the failing submission event is not fired when settings are disabled.


286-289: Partial verification using times(2) and never() is coherent.

The combination of verifying some calls while disallowing others is clearly expressed here.


302-303: No new result invocation with only two submissions.

never() effectively asserts that onNewResult is not prematurely called. This logic looks correct.


317-318: Ensuring non-invocation for increasing scores scenario.

The approach is consistent with earlier checks, confirming no calls are made unless specific conditions are met.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 4, 2025
Copy link
Contributor

@ole-ve ole-ve left a comment

Choose a reason for hiding this comment

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

code looks good. However, compileTestJava is failing because Mockito.never() is not imported in BuildAgentDockerServiceTest (for l. 86).

Copy link
Contributor

@ole-ve ole-ve left a comment

Choose a reason for hiding this comment

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

code

@krusche krusche merged commit e219599 into develop Jan 4, 2025
29 of 33 checks passed
@krusche krusche deleted the bugfix/iris/prevent-exceptions branch January 4, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assessment Pull requests that affect the corresponding module buildagent Pull requests that affect the corresponding module core Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module iris Pull requests that affect the corresponding module lti Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants