feat(match-assignment): add atomic batch referee assignment by round#76
Conversation
|
Thank you for your PR @Ferranicu! Now, you should wait for the automated code analysis by CodeRabbit, Copilot and SonarQube. Once you are confident that you have fixed all the detected issues and this PR is ready to be merged, add a comment with exactly one word: |
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a transactional POST /matchAssignments/batch endpoint, DTOs, service logic, exception/enriched error responses, and tests to perform all-or-nothing batch referee assignments with per-item validation and intra-batch conflict detection. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
Pull request overview
Adds support for assigning referees to multiple matches within a round in one atomic (all-or-nothing) operation, including validation, intra-batch conflict detection, and API/error-response plumbing.
Changes:
- Added
POST /matchAssignments/batchendpoint with request/response DTOs for round-scoped batch assignment. - Implemented transactional batch assignment logic in
MatchAssignmentService, including intra-batch overlap detection and detailed per-item failure metadata. - Added unit tests, controller tests, and Cucumber scenarios covering success, rollback on conflict, and rollback on invalid role.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java | Implements transactional batch assignment, validations, and intra-batch overlap checks. |
| src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.java | Exposes POST /matchAssignments/batch. |
| src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java | Defines batch request payload with bean validation. |
| src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemRequest.java | Defines per-item request DTO. |
| src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java | Defines batch response payload. |
| src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemResponse.java | Defines per-item response DTO. |
| src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java | Adds batch-aware error response structure with per-item details. |
| src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java | Extends exception to carry batch failure metadata (index/matchId/refereeId). |
| src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java | Adds ROUND_NOT_FOUND error code. |
| src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java | Adds service-level tests for batch success and rollback scenarios. |
| src/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.java | Adds controller tests for batch success and detailed error response. |
| src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java | Adds Cucumber step defs to create rounds/matches and call batch endpoint. |
| src/test/resources/features/MatchAssignment.feature | Adds Cucumber scenarios for batch assignment success and rollback cases. |
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
Outdated
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java
Outdated
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 6
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 726ab8af-bc66-429c-8f4f-adfc01215d13
📒 Files selected for processing (13)
src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.javasrc/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemRequest.javasrc/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemResponse.javasrc/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.javasrc/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.javasrc/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.javasrc/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.javasrc/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.javasrc/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.javasrc/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.javasrc/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.javasrc/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.javasrc/test/resources/features/MatchAssignment.feature
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java
Outdated
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
Show resolved
Hide resolved
src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ae37f06b-21ae-4abe-aea5-782607fb56b9
📒 Files selected for processing (9)
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.javasrc/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.javasrc/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.javasrc/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.javasrc/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.javasrc/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.javasrc/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.javasrc/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.javasrc/test/resources/features/MatchAssignment.feature
src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
Outdated
Show resolved
Hide resolved
src/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: defb32e0-7037-465f-8d33-e0e524c861c4
📒 Files selected for processing (2)
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.javasrc/test/java/cat/udl/eps/softarch/fll/steps/MatchAssignmentStepDefs.java
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
Show resolved
Hide resolved
|
ready |
|
This PR is now marked as ready to be merged. |
|
Looks good to me. You just need to fix the sonarqube warnings. |
|
|
@pol-rivero done, fixed the sonarqube warnings |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2ca81f72-d7c3-43dd-8b5e-030613082270
📒 Files selected for processing (1)
src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
Show resolved
Hide resolved
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
Show resolved
Hide resolved
| public BatchMatchAssignmentResponse assignBatch(String roundId, List<BatchMatchAssignmentItemRequest> assignments) { | ||
| Long parsedRoundId = parseIdOrThrow(roundId); | ||
| Round round = roundRepository.findById(parsedRoundId) | ||
| .orElseThrow(() -> new MatchAssignmentException( | ||
| MatchAssignmentErrorCode.ROUND_NOT_FOUND, |
There was a problem hiding this comment.
assignBatch is doing parsing, de-duplication, ordering, DB lookups/locking, validation, conflict detection, persistence, and response mapping in one method. To keep control flow and testing manageable, consider extracting these phases into small private methods (e.g., parse+dedupe, load+validate candidates, build response) and keeping assignBatch as orchestration only.
|
@Ferranicu Perfect, thanks |
7e9ad77
into
UdL-EPS-SoftArch-Igualada:main



Closes #66
Implements atomic batch referee assignment per round, with full validation, intra-batch conflict detection, detailed failure reporting, and unit/Cucumber coverage.