Skip to content

Conversation

@LeZhen1105
Copy link
Contributor

@LeZhen1105 LeZhen1105 commented Nov 22, 2025

Checklist

General

Server

Motivation and Context

After upgrading to Hibernate 6, several tests around the SlideSplitterService started to fail with
StaleObjectStateException / ObjectOptimisticLockingFailureException for Slide entities.

Slide entities now rely on the database-generated IDs in tests.

Description

This PR fixes failing integration tests around SlideSplitterService after the Hibernate 6 upgrade.
Concr

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Log in to Artemis
  2. Navigate to Course Administration
  3. ...

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exam with a Programming Exercise
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Make sure that the UI of the programming exercise in the exam mode stays unchanged. You can use the exam mode documentation as reference.
  4. ...

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • Tests
    • Streamlined test setup to rely on automatic ID generation, removing manual ID assignments; cleanup adjustments only. No changes to public APIs and no impact on application functionality or user experience.

✏️ Tip: You can customize this high-level summary in your review settings.

@LeZhen1105 LeZhen1105 requested a review from a team as a code owner November 22, 2025 21:10
@github-project-automation github-project-automation bot moved this to Work In Progress in Artemis Development Nov 22, 2025
@github-actions github-actions bot added tests lecture Pull requests that affect the corresponding module labels Nov 22, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2025

Walkthrough

A single test file was updated to remove explicit Slide ID assignments so JPA-generated IDs are used; a minor brace/empty-block placement in a cleanup section was adjusted. No public API or test logic behavior was intentionally changed.

Changes

Cohort / File(s) Summary
Test setup refactor
src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java
Removed hard-coded slide.setId(...) calls in test setup to rely on JPA ID generation; adjusted a closing-brace/cleanup block placement (no-op).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify tests pass with JPA-generated IDs instead of hard-coded IDs.
  • Check any assertions that previously relied on specific IDs still behave correctly.
  • Confirm the cleanup brace/empty block change introduces no side effects.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main objective of the PR: fixing SlideSplitterServiceTest to work with updated Hibernate behavior. It is specific, concise, and clearly summarizes the primary change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/development/fix-slide-splitter-service-hibernate

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91a32fe and ba9f328.

📒 Files selected for processing (1)
  • src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: client-style
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: client-tests
  • GitHub Check: Build and Push Docker Image / Build linux/arm64 Docker Image for ls1intum/artemis
  • GitHub Check: Build and Push Docker Image / Build linux/amd64 Docker Image for ls1intum/artemis
  • GitHub Check: Build .war artifact
  • GitHub Check: Analyse

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java (1)

231-269: Critical: Test uses hardcoded ID after switching to auto-generated IDs.

The test creates slides with database-generated IDs (lines 231-246) but then attempts to look them up using the hardcoded ID 3L (lines 259, 264). After removing explicit ID assignments per the PR objectives, this assumption is no longer valid—the third slide's ID will be whatever the database generates, not necessarily 3L.

Apply this diff to capture and use the actual generated ID:

         // Create existing slides (all 3) with known IDs and valid paths
+        Long thirdSlideId = null;
         for (int i = 1; i <= 3; i++) {
             // Create a real file in the temp directory
             Path slidePath = tempFilePath.resolve("slide" + i + ".png");
 
             // Create a simple image file (1x1 pixel)
             BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
             ImageIO.write(image, "png", slidePath.toFile());
 
             Slide slide = new Slide();
             slide.setSlideNumber(i);
             slide.setAttachmentVideoUnit(testAttachmentVideoUnit);
 
             // The path is relative to the base path and should match what's expected
             slide.setSlideImagePath("temp/slide" + i + ".png");
-            slideRepository.save(slide);
+            Slide savedSlide = slideRepository.save(slide);
 
-            if (i == 3) {
-            }
+            if (i == 3) {
+                thirdSlideId = savedSlide.getId();
+            }
         }
         // Act
         slideSplitterService.splitAttachmentVideoUnitIntoSingleSlides(testDocument, testAttachmentVideoUnit, "test.pdf", hiddenPagesList, pageOrderList);
 
         // Assert
         List<Slide> slides = slideRepository.findAllByAttachmentVideoUnitId(testAttachmentVideoUnit.getId());
         assertThat(slides).isNotNull();
         assertThat(slides.size()).isEqualTo(2); // Should only have 2 slides attached to unit
 
         // Check if slide 3 exists but is detached
-        Slide slide3 = slideRepository.findById(3L).orElse(null);
+        Slide slide3 = slideRepository.findById(thirdSlideId).orElse(null);
 
         // If slide3 is null, the service is completely removing it rather than detaching
         if (slide3 == null) {
             // Test that it was removed instead
-            assertThat(slideRepository.existsById(3L)).isFalse();
+            assertThat(slideRepository.existsById(thirdSlideId)).isFalse();
         }
         else {
             // Test that it was detached
             assertThat(slide3.getAttachmentVideoUnit()).isNull();
         }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfdfb8f and 91a32fe.

📒 Files selected for processing (1)
  • src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/test/java/**/*.java

⚙️ CodeRabbit configuration file

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

Files:

  • src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java
🧠 Learnings (2)
📚 Learning: 2025-09-25T11:25:54.261Z
Learnt from: Elfari1028
Repo: ls1intum/Artemis PR: 11351
File: src/main/java/de/tum/cit/aet/artemis/versioning/dto/QuizExerciseSnapshotDTO.java:52-53
Timestamp: 2025-09-25T11:25:54.261Z
Learning: In the Artemis versioning system, quiz questions processed by QuizExerciseSnapshotDTO should always have valid IDs (non-null getId()) since versioning works with persisted entities, making null filtering unnecessary according to Elfari1028.

Applied to files:

  • src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java
📚 Learning: 2024-06-10T19:44:09.116Z
Learnt from: julian-christl
Repo: ls1intum/Artemis PR: 8052
File: src/test/java/de/tum/in/www1/artemis/lecture/CompetencyIntegrationTest.java:310-310
Timestamp: 2024-06-10T19:44:09.116Z
Learning: Modifications to parameters in `competencyProgressUtilService.createCompetencyProgress` for debugging purposes are considered irrelevant to the test outcomes but helpful for clarity during debugging.

Applied to files:

  • src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Build and Push Docker Image / Build linux/arm64 Docker Image for ls1intum/artemis
  • GitHub Check: Build .war artifact
  • GitHub Check: Build and Push Docker Image / Build linux/amd64 Docker Image for ls1intum/artemis
  • GitHub Check: client-style
  • GitHub Check: server-style
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse

@github-project-automation github-project-automation bot moved this from Work In Progress to Ready For Review in Artemis Development Nov 22, 2025
@github-actions
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ✅SkippedFailedTime ⏱
End-to-End (E2E) Test Report1 ran1 passed0 skipped0 failed1s 623ms
TestResultTime ⏱
No test annotations available

@github-actions
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ✅Skipped ⚠️FailedTime ⏱
End-to-End (E2E) Test Report215 ran212 passed3 skipped0 failed1h 14m 29s 409ms
TestResultTime ⏱
No test annotations available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lecture Pull requests that affect the corresponding module tests

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

2 participants