Skip to content

4 implement participant voting for event dates - #12

Merged
TyostoKarry merged 6 commits into
mainfrom
4-implement-participant-voting-for-event-dates
Oct 21, 2025
Merged

4 implement participant voting for event dates#12
TyostoKarry merged 6 commits into
mainfrom
4-implement-participant-voting-for-event-dates

Conversation

@TyostoKarry

Copy link
Copy Markdown
Owner
  • Added EventVote entity to represent participant votes on selected event dates.
    • Established a one-to-many relationship between Event and EventVote.
    • Configured cascading, eager fetching, and orphan removal for consistent persistence and cleanup.
  • Extended EventService with addVote() method to handle new votes and updates.
    • Ensure only valid event dates can be voted for.
    • Replace previous votes by the same participant.
  • Added endpoint POST /api/v1/event/{id}/vote in EventController.
  • Extended GlobalExceptionHandler to handle additional error types:
    • IllegalArgumentException maps to HTTP 400
    • HttpMessageNotReadableException maps to HTTP 400
    • MethodArgumentNotValidException maps to HTTP 400
    • All handlers now return error messages via ResponseEntity, ensuring clients receive informative responses.
  • Updated controller tests in EventControllerTest to include event vote tests
  • Created comprehensive service tests in EventServiceTest to validate the business logic functionality

- Added EventVote entity to represent participants’ votes on event date selections.
- Extended Event entity with a one-to-many relationship to EventVote entries.
- Configured cascading, eager fetching, and orphan removal for consistent persistence.
- Add DTOs for voting (VoteCreateRequest, VoteCreateResponse, VotesListItemDto)
- Extend EventService with addVote() to handle participant votes
- Update EventController with POST /api/v1/event/{id}/vote endpoint
- Ensure validation for allowed vote dates and replace previous participant votes
- Update EventDetailsResponse to match the format specified in the instructions
- Combine EventDetailsResponse and VoteCreateResponse into single dto
- Update dto use cases to match the new dtos
- Simplified layering by moving DTO mapping to the controller.
- EventService.addVote() now returns the updated Event entity, and EventController handles conversion to EventDetailsResponse.
… argument errors

Extended GlobalExceptionHandler beyond EventNotFoundException handling to include:
- handleIllegalArgument maps IllegalArgumentException to HTTP 400
- handleJsonParseError maps HttpMessageNotReadableException to HTTP 400
- handleValidationError maps MethodArgumentNotValidException to HTTP 400

By explicitly returning ResponseEntity objects with error messages, these handlers ensure that both clients and tests receive the actual exception messages in the HTTP response body instead of default empty bodies produced by Spring's built-in error handling.
- Added vote-related controller test cases for success and error scenarios
- Created comprehensive EventService tests covering all logic paths
- Introduced nested groups in controller and service tests for clarity
- Updated old controller error case tests to use .response.contentAsString instead of .resolvedException?.message after extending GlobalExceptionHandler
@TyostoKarry TyostoKarry self-assigned this Oct 21, 2025
@TyostoKarry TyostoKarry linked an issue Oct 21, 2025 that may be closed by this pull request
@TyostoKarry
TyostoKarry merged commit 4add781 into main Oct 21, 2025
1 check passed
@TyostoKarry
TyostoKarry deleted the 4-implement-participant-voting-for-event-dates branch October 21, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement participant voting for event dates

1 participant