Skip to content

Feature/referee match assignment#42

Merged
pol-rivero merged 14 commits intoUdL-EPS-SoftArch-Igualada:mainfrom
polMarsol:feature/referee-match-assignment
Mar 3, 2026
Merged

Feature/referee match assignment#42
pol-rivero merged 14 commits intoUdL-EPS-SoftArch-Igualada:mainfrom
polMarsol:feature/referee-match-assignment

Conversation

@polMarsol
Copy link
Contributor

Closes #33

Copilot AI review requested due to automatic review settings February 25, 2026 15:37
@udl-softarch udl-softarch bot added the pr-not-ready This PR cannot be merged until you have reviewed the code analysis results. label Feb 25, 2026
@udl-softarch
Copy link

udl-softarch bot commented Feb 25, 2026

Thank you for your PR @polMarsol! Now, you should wait for the automated code analysis by CodeRabbit, Copilot and SonarQube.
Please review all warnings carefully, as some of them might be false positives.

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: ready.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request introduces a complete match referee assignment feature with validation. It adds a REST controller, service layer with six validation checks, custom exception handling, domain model extensions (Match state and referee association), and comprehensive unit tests covering success and all error scenarios.

Changes

Cohort / File(s) Summary
DTOs and Request/Response Models
src/main/java/cat/udl/eps/softarch/fll/controller/dto/MatchAssignmentRequest.java, src/main/java/cat/udl/eps/softarch/fll/controller/dto/MatchAssignmentResponse.java
New DTO records for handling referee assignment requests and responses with validated input fields (matchId, refereeId) and response payload (status "ASSIGNED").
Domain Model Extensions
src/main/java/cat/udl/eps/softarch/fll/domain/Match.java, src/main/java/cat/udl/eps/softarch/fll/domain/MatchState.java
Added many-to-one association from Match to Referee with lazy fetch, new MatchState enum field with getters/setters (SCHEDULED, IN_PROGRESS, FINISHED states), and corresponding accessors.
Exception Handling
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java, src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java, src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java
New exception framework with error code enum (six codes: MATCH_NOT_FOUND, REFEREE_NOT_FOUND, INVALID_ROLE, AVAILABILITY_CONFLICT, MATCH_ALREADY_HAS_REFEREE, INVALID_MATCH_STATE), custom exception class, and REST controller advice mapping errors to HTTP status codes (NOT_FOUND or BAD_REQUEST).
Service and Repository
src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java, src/main/java/cat/udl/eps/softarch/fll/repository/MatchRepository.java
New transactional service orchestrating six validation checks (match/referee existence, role, state, availability conflict detection), and new repository query method for finding referee scheduling conflicts via time overlap.
Controller
src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.java
New REST controller exposing POST /matchAssignments/assign endpoint that delegates to service and constructs MatchAssignmentResponse with assigned status.
Unit Tests
src/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.java, src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java
Test coverage for controller (success and error responses) and service (successful assignment plus all six validation failure scenarios with helper methods for test data setup).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Feature/referee match assignment' is directly related to and clearly summarizes the main change: implementing referee-to-match assignment functionality as specified in the linked issue #33.
Description check ✅ Passed The PR description 'Closes #33' is concise and directly related to the changeset, referencing the specific issue that defines all functional requirements for the referee assignment feature.
Linked Issues check ✅ Passed The PR fully implements all requirements from issue #33: REST endpoint with MatchAssignmentRequest/Response DTOs [#33], validation of all six error scenarios [#33], assignment logic in MatchAssignmentService [#33], exception handling with proper HTTP status codes [#33], and comprehensive unit tests for success and all failure cases [#33].
Out of Scope Changes check ✅ Passed All changes are within scope: new controller/service for match assignment, supporting domain entities (MatchState), DTOs, exception handling, repository methods for conflict detection, and tests. No extraneous modifications detected.
Code Style ✅ Passed Code adheres to style requirements: English language, clear variable names, no non-Javadoc comments, and indentation within acceptable limits for fluent APIs and lambdas.
Has Tests ✅ Passed Pull request contains adequate test coverage for added functionality with comprehensive tests for main success path and all six validation failure cases across service and controller layers.

✏️ 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.

❤️ 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: 8

Caution

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

⚠️ Outside diff range comments (1)
pom.xml (1)

54-127: ⚠️ Potential issue | 🟠 Major

Dependency updates in pom.xml violate repository policy.

This patch modifies/adds multiple project dependencies in pom.xml, which is currently disallowed by the repo rules. Please revert these dependency changes (or move them to a separately approved dependency-update PR).

As per coding guidelines, "Disallow modifications to the project dependencies".


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af340f5 and a76f84b.

📒 Files selected for processing (20)
  • pom.xml
  • src/main/java/cat/udl/eps/softarch/demo/api/dto/AssignRefereeRequest.java
  • src/main/java/cat/udl/eps/softarch/demo/api/dto/AssignRefereeResponse.java
  • src/main/java/cat/udl/eps/softarch/demo/api/dto/AssignmentErrorResponse.java
  • src/main/java/cat/udl/eps/softarch/demo/controller/MatchAssignmentController.java
  • src/main/java/cat/udl/eps/softarch/demo/domain/Match.java
  • src/main/java/cat/udl/eps/softarch/demo/domain/MatchState.java
  • src/main/java/cat/udl/eps/softarch/demo/domain/Referee.java
  • src/main/java/cat/udl/eps/softarch/demo/domain/Team.java
  • src/main/java/cat/udl/eps/softarch/demo/exception/AssignmentErrorCode.java
  • src/main/java/cat/udl/eps/softarch/demo/exception/AssignmentValidationException.java
  • src/main/java/cat/udl/eps/softarch/demo/exception/MatchAssignmentExceptionHandler.java
  • src/main/java/cat/udl/eps/softarch/demo/repository/MatchRepository.java
  • src/main/java/cat/udl/eps/softarch/demo/repository/RefereeRepository.java
  • src/main/java/cat/udl/eps/softarch/demo/repository/VolunteerRepository.java
  • src/main/java/cat/udl/eps/softarch/demo/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/demo/TeamMemberTest.java
  • src/test/java/cat/udl/eps/softarch/demo/TeamTest.java
  • src/test/java/cat/udl/eps/softarch/demo/controller/MatchAssignmentControllerTest.java
  • src/test/java/cat/udl/eps/softarch/demo/service/MatchAssignmentServiceTest.java

Copy link
Contributor

Copilot AI left a 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 pull request implements the match referee assignment feature as specified in issue #33. The implementation adds functionality to assign referees to matches with comprehensive validation including role verification, availability conflict detection, and match state validation. However, the PR includes unrelated changes to Team functionality and violates critical project guidelines regarding testing practices and dependency management.

Changes:

  • Implements match referee assignment API with comprehensive validation (match existence, referee existence, role validation, availability conflicts, match state, and existing referee checks)
  • Adds domain entities (Match, Referee, MatchState) and repositories with pessimistic locking for concurrency control
  • Includes unit and integration tests but lacks required Cucumber BDD tests
  • Contains unrelated Team validation changes and tests written in Catalan

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 22 comments.

Show a summary per file
File Description
MatchAssignmentService.java Core service implementing referee assignment logic with validation chain
MatchAssignmentController.java REST controller exposing POST /match-assignments endpoint with authentication
MatchRepository.java Repository with pessimistic locking and overlap detection query
VolunteerRepository.java Added findByIdForUpdate method with pessimistic locking
RefereeRepository.java New repository for Referee entity management
Match.java New domain entity for competition matches
Referee.java New domain entity extending Volunteer
MatchState.java Enum defining match states (SCHEDULED, FINISHED)
AssignRefereeRequest.java Request DTO with validation
AssignRefereeResponse.java Response DTO for successful assignments
AssignmentErrorResponse.java Error response DTO
AssignmentErrorCode.java Enum defining all assignment error codes
AssignmentValidationException.java Custom exception for assignment validation failures
MatchAssignmentExceptionHandler.java Controller advice for exception handling and HTTP status mapping
MatchAssignmentServiceTest.java Unit tests covering all validation scenarios
MatchAssignmentControllerTest.java Integration tests for API endpoints
Team.java Adds @Size validation annotation (unrelated to feature)
TeamTest.java Unit tests for Team functionality with Catalan comments (unrelated to feature)
TeamMemberTest.java Unit tests for TeamMember with Catalan comments (unrelated to feature)
pom.xml Formatting changes and adds junit-jupiter-api dependency (violates guidelines)

…g, hidden internals, and test/code cleanup
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: 2

♻️ Duplicate comments (1)
src/main/java/cat/udl/eps/softarch/demo/domain/Team.java (1)

71-74: ⚠️ Potential issue | 🟡 Minor

@Size on lazy @OneToMany – performance and LazyInitializationException risk remains.

When Bean Validation is triggered (e.g., via @Valid in a controller or a Hibernate pre-update listener), Hibernate must load the entire members collection to evaluate @Size. If that validation runs outside an active session (detached entity scenario), a LazyInitializationException is thrown. Ensure all call-sites that trigger Bean Validation on a Team instance remain within transaction boundaries.


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a76f84b and 7379ebf.

📒 Files selected for processing (8)
  • src/main/java/cat/udl/eps/softarch/demo/domain/Match.java
  • src/main/java/cat/udl/eps/softarch/demo/domain/Team.java
  • src/main/java/cat/udl/eps/softarch/demo/repository/MatchRepository.java
  • src/main/java/cat/udl/eps/softarch/demo/repository/RefereeRepository.java
  • src/main/java/cat/udl/eps/softarch/demo/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/demo/TeamMemberTest.java
  • src/test/java/cat/udl/eps/softarch/demo/TeamTest.java
  • src/test/java/cat/udl/eps/softarch/demo/service/MatchAssignmentServiceTest.java

Copilot AI review requested due to automatic review settings February 25, 2026 16:14
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: 4


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7379ebf and 820a479.

📒 Files selected for processing (3)
  • src/main/java/cat/udl/eps/softarch/demo/domain/Match.java
  • src/main/java/cat/udl/eps/softarch/demo/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/demo/service/MatchAssignmentServiceTest.java

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 14 comments.

@polMarsol
Copy link
Contributor Author

done

Copilot AI review requested due to automatic review settings February 25, 2026 16:52
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: 3


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 820a479 and 125fa8c.

📒 Files selected for processing (6)
  • src/main/java/cat/udl/eps/softarch/demo/domain/Match.java
  • src/main/java/cat/udl/eps/softarch/demo/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/demo/TeamTest.java
  • src/test/java/cat/udl/eps/softarch/demo/service/MatchAssignmentServiceTest.java
  • src/test/java/cat/udl/eps/softarch/demo/steps/MatchAssignmentStepDefs.java
  • src/test/resources/features/MatchAssignment.feature

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings March 2, 2026 16:38
@polMarsol polMarsol force-pushed the feature/referee-match-assignment branch from 5119a3c to 9fd115e Compare March 2, 2026 16:38
…ol/first-lego-league-backend into feature/referee-match-assignment
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

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: 4


ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 125fa8c and 9fd115e.

📒 Files selected for processing (12)
  • src/main/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentController.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/MatchAssignmentRequest.java
  • src/main/java/cat/udl/eps/softarch/fll/controller/dto/MatchAssignmentResponse.java
  • src/main/java/cat/udl/eps/softarch/fll/domain/Match.java
  • src/main/java/cat/udl/eps/softarch/fll/domain/MatchState.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentException.java
  • src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java
  • src/main/java/cat/udl/eps/softarch/fll/repository/MatchRepository.java
  • src/main/java/cat/udl/eps/softarch/fll/service/MatchAssignmentService.java
  • src/test/java/cat/udl/eps/softarch/fll/controller/MatchAssignmentControllerTest.java
  • src/test/java/cat/udl/eps/softarch/fll/service/MatchAssignmentServiceTest.java

Copilot AI review requested due to automatic review settings March 2, 2026 20:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2026

@polMarsol
Copy link
Contributor Author

polMarsol commented Mar 2, 2026

@pol-rivero @copilot code review[agent] I think it's done!

@pol-rivero
Copy link
Member

LGTM 👍

By the way, next time remember that you can mark a PR as ready by creating a comment with just the word ready, otherwise I won't see the PR.

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

Labels

pr-not-ready This PR cannot be merged until you have reviewed the code analysis results.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Assignment of Match Referees with validation of availability

4 participants