-
Notifications
You must be signed in to change notification settings - Fork 350
Development: Fix SlideSplitterServiceTest for updating hibernate
#11685
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
base: develop
Are you sure you want to change the base?
Development: Fix SlideSplitterServiceTest for updating hibernate
#11685
Conversation
WalkthroughA 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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. Comment |
There was a problem hiding this 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 necessarily3L.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
📒 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
src/test/java/de/tum/cit/aet/artemis/lecture/service/SlideSplitterServiceTest.java
Outdated
Show resolved
Hide resolved
End-to-End (E2E) Test Results Summary
|
||||||||||||||||||
End-to-End (E2E) Test Results Summary
|
||||||||||||||||||
Checklist
General
Server
Motivation and Context
After upgrading to Hibernate 6, several tests around the
SlideSplitterServicestarted to fail withStaleObjectStateException/ObjectOptimisticLockingFailureExceptionforSlideentities.Slideentities now rely on the database-generated IDs in tests.Description
This PR fixes failing integration tests around
SlideSplitterServiceafter the Hibernate 6 upgrade.Concr
Steps for Testing
Prerequisites:
Exam Mode Testing
Prerequisites:
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
Manual Tests
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.