-
Notifications
You must be signed in to change notification settings - Fork 0
feat: week 9 exercise #47
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
Conversation
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.
Pull Request Overview
This PR adds Week 9 functionality by introducing a new service wrapper class and corresponding tests, along with improvements to test infrastructure and code clarity.
- Adds
Week9ChallengeServicewrapper class to provide simplified access to challenge operations - Improves test infrastructure by using
TRUNCATE TABLEwith identity restart for cleaner database resets - Replaces Unicode escape sequences with actual characters in test assertions for better readability
Reviewed Changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/main/java/me/nickhanson/codeforge/service/Week9ChallengeService.java |
New service wrapper providing findAll() and findById() methods that delegate to ChallengeService |
src/test/java/me/nickhanson/codeforge/service/Week9ChallengeServiceTest.java |
Unit tests verifying delegation behavior of the new wrapper service |
src/test/java/me/nickhanson/codeforge/service/ChallengeServiceTest.java |
Adds tests for listChallenges() and getById() methods; removes unused import |
src/test/java/me/nickhanson/codeforge/service/QuoteServiceTest.java |
Replaces Unicode escape sequences with actual quotation marks in assertions |
src/test/java/me/nickhanson/codeforge/persistence/DaoTestBase.java |
Improves database reset using TRUNCATE TABLE with RESTART IDENTITY instead of DELETE |
docs/screenshots/week-9-getById.png |
Screenshot documentation for Week 9 getById functionality |
docs/screenshots/week-9-getAll.png |
Screenshot documentation for Week 9 getAll functionality |
docs/projects/pd-presentation/screenshots/annotation-diagram.png |
Presentation diagram image |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assertTrue(svc.getById(42L).isPresent()); | ||
| assertEquals("Two Sum", svc.getById(42L).get().getTitle()); | ||
| verify(dao, times(2)).getById(42L); // or call once then store the Optional |
Copilot
AI
Nov 4, 2025
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.
The test calls svc.getById(42L) twice, which results in two unnecessary DAO calls. Store the result in a variable to avoid redundant method invocations. The comment acknowledges this but the code should be fixed.
| assertTrue(svc.getById(42L).isPresent()); | |
| assertEquals("Two Sum", svc.getById(42L).get().getTitle()); | |
| verify(dao, times(2)).getById(42L); // or call once then store the Optional | |
| var result = svc.getById(42L); | |
| assertTrue(result.isPresent()); | |
| assertEquals("Two Sum", result.get().getTitle()); | |
| verify(dao).getById(42L); |
This pull request introduces a new service class for week 9 challenges and improves testing and database reset logic. The most important changes are the addition of the
Week9ChallengeServiceclass and its corresponding tests, as well as refactoring the database reset method for better reliability. Minor test improvements and formatting updates are also included.New service and test coverage:
Week9ChallengeServiceclass to wrap core challenge retrieval methods, providing a specialized interface for week 9 challenge operations.Week9ChallengeServiceTestto verify delegation of calls to the underlyingChallengeService.Database reset improvements:
DaoTestBase.resetDatabase()to use H2'sTRUNCATE TABLE ... RESTART IDENTITYand temporarily disable referential integrity for reliable test isolation.Challenge service test enhancements:
ChallengeServiceTestforfindAllandfindById, increasing coverage of challenge retrieval logic.Minor test formatting updates:
QuoteServiceTestassertions to use standard Unicode quote characters for clarity and consistency. [1] [2] [3]