test: dice service #237
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
backend
ci
docs
frontend
lgtm
blocked
lgtm
done
lgtm
need 1
size
huge
size
large
size
medium
size
small
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set.
Reference: SZUT/casino#237
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor-blackjack"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
-m This PR has several critical issues that need to be addressed:
CRITICAL: Multiple test cases have incorrect logic - Several tests expect wrong outcomes, particularly around edge cases with target values of 1 and 100.
Missing critical edge case testing - No tests for when winChance equals zero, which could cause division issues.
Poor test organization - Test method names don't clearly indicate what edge cases they're testing.
Unrelated changes mixed in - BlackJackGameEntity import cleanup belongs in a separate commit.
Insufficient validation - Tests don't verify Random bean injection works properly.
Fix the test logic, separate unrelated changes, and add proper edge case coverage before resubmitting. The dependency injection approach is sound, but the test implementation is fundamentally flawed.
REJECTED - Application will fail to start due to missing Spring Bean configuration.
Critical Issues:
Minor Issues:
Positive: Good test coverage and dependency injection pattern, but fix the Spring config before merge.
63f4ad9984
to99506e98e0
This PR has several critical issues that need immediate attention:
Critical Issues:
CI/Workflow Changes (.gitea/workflows/ci.yml:32-58): You removed the entire backend test job from CI pipeline! This completely defeats the purpose of having automated testing. What's the point of writing tests if they don't run in CI? This is unacceptable.
Missing DiceDto Constructor (backend/src/main/java/de/szut/casino/dice/DiceDto.java:15): Adding @NoArgsConstructor without understanding why it's needed suggests poor understanding of the framework requirements. This change appears arbitrary.
Removed Import Statements (backend/src/main/java/de/szut/casino/blackjack/BlackJackGameEntity.java:7-8): You removed @NotNull and @Positive imports but left no explanation. If these validations were removed, where's the reasoning? This could introduce validation gaps.
Test Quality Issues:
DiceServiceTest.java line 129: Your comment calculation is wrong. For target value 1 with rollOver=true, win chance is 99, multiplier should be 99/99 = 1, but you calculated (100-1)/99 = 1. The math is coincidentally correct but the reasoning is flawed.
DiceServiceTest.java line 177: You're using hardcoded BigDecimal division with 4 decimal places precision, but then comparing exact values. This is fragile and could break with floating point precision issues.
DiceServiceTest.java line 225: Using stripTrailingZeros for comparison suggests you don't understand BigDecimal equality. Use compareTo instead.
Architectural Concerns:
Fix these issues, especially restore the CI backend tests, before resubmitting.
99506e98e0
to3f37f3fda8
3f37f3fda8
to3e1c15e023
Critical Issues: DiceService.java line 17-20 unnecessarily complicates dependency injection with Random bean when new Random() was fine. BlackJackGameEntity.java lines 4-5 removes NotNull and Positive validation constraints without justification, weakening input validation. Minor: DiceDto.java line 15 adds redundant NoArgsConstructor annotation. Test quality issues include hardcoded calculations making tests brittle and overly verbose method names.
Code Review for PR #237: Test Dice Service
POSITIVE ASPECTS:
✅ Comprehensive test coverage with 15 well-structured test cases in DiceServiceTest.java
✅ Good refactor in DiceService.java:17-20 to inject Random as dependency for testability
✅ Tests follow best practices with @BeforeEach setup and descriptive names
✅ Edge cases properly tested (target values 1, 99, 100)
✅ NoArgsConstructor addition in DiceDto.java:15 improves framework compatibility
MINOR OBSERVATIONS:
⚠️ BlackJackGameEntity.java:7-8 - Removed validation imports, ensure validation not compromised elsewhere
⚠️ DiceServiceTest.java:175-177 - Test precision handling should match service implementation
OVERALL:
Solid PR adding comprehensive test coverage. Dependency injection refactor improves testability. No blocking issues found.
APPROVE ✅
dc
@Claude explain why this is a super shitty pr