Skip to content

Add TicketController integration test suite - #44

Merged
simonforsberg merged 10 commits into
mainfrom
feature/ticketcontroller-it
Apr 27, 2026
Merged

Add TicketController integration test suite#44
simonforsberg merged 10 commits into
mainfrom
feature/ticketcontroller-it

Conversation

@simonforsberg

@simonforsberg simonforsberg commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Tests
    • Added integration test suite for ticket controller to validate authentication scenarios, form submission behavior, and ticket management operations including assignment and status transitions across different user roles.

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@simonforsberg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 40 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 39 minutes and 40 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81712075-b0d8-48b9-ba82-5676d237509b

📥 Commits

Reviewing files that changed from the base of the PR and between 6e31813 and 47a3b86.

📒 Files selected for processing (1)
  • src/test/java/org/example/alfs/controllers/TicketControllerIT.java
📝 Walkthrough

Walkthrough

A new Spring Boot integration test suite for TicketController is introduced, bootstrapping MockMvc with transactional context and role-based test users. The tests exercise controller routes including anonymous ticket creation, token-based viewing, role-restricted list views, and admin capabilities for assigning and updating ticket status, validating both successful operations and failed transitions.

Changes

Cohort / File(s) Summary
Integration Test Suite
src/test/java/org/example/alfs/controllers/TicketControllerIT.java
New integration test class covering TicketController endpoints with transactional setup, role-based user fixtures, and test scenarios for anonymous/authenticated access, token-based operations, role-restricted views, and status transitions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A tester's delight, with MockMvc in hand,
Role-based users dancing across the land,
Anonymous hops and token-blessed views,
Investigating transitions (some pass, some lose),
Status updates bloom where admins tread! 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately reflects the primary change: adding an integration test suite for TicketController with 216 new lines of test code.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/ticketcontroller-it

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/test/java/org/example/alfs/controllers/TicketControllerIT.java (2)

84-100: Minor: reuse the seeded ticket instead of creating another.

setUp() already creates a ticket and stores ticketId; this test builds a second one solely to obtain a token. You can fetch the existing ticket's token via the service/repository and drop the duplication, keeping tests lean and focused.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/example/alfs/controllers/TicketControllerIT.java` around
lines 84 - 100, In anonymousReporter_validToken_returnsView() remove the extra
ticket creation and instead fetch the seeded ticket's token created in setUp()
(use the stored ticketId from the test class) by calling
ticketService.findById(ticketId) or repository equivalent, then use that
ticket.getToken() in the mockMvc.perform(get("/tickets/token/" + ...)); update
references in the test to use ticketId and existing ticket retrieval so you no
longer call ticketService.createNewTicket(dto).

206-214: Make the "invalid transition" precondition explicit.

This test depends on the ticket being in OPEN (no investigator) so that OPEN → RESOLVED is rejected, which works only because @Transactional rolls back state between tests and the prior admin_canUpdateTicketStatus test's assignInvestigator call doesn't leak here. Consider asserting or arranging the starting status explicitly (or using a status pair that is unambiguously invalid regardless of transitions map, e.g. RESOLVED → OPEN on a freshly resolved ticket) so the intent and precondition are self-documenting and robust to future changes in ALLOWED_TRANSITIONS.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/example/alfs/controllers/TicketControllerIT.java` around
lines 206 - 214, The test admin_cannotPerformInvalidStatusTransition relies on
implicit state; make the precondition explicit by ensuring the ticket is in the
expected starting status before performing the POST: either reset or fetch the
ticket and assert/set its status to OPEN (and confirm no investigator assigned)
or explicitly transition it into a state that will unambiguously reject the
requested change (e.g., programmatically set to RESOLVED then attempt
RESOLVED→OPEN) so the invalid-transition intent is clear; modify the setup
inside TicketControllerIT (or this test) to arrange/assert the ticket's status
(using existing helpers like assignInvestigator or status setters used in
admin_canUpdateTicketStatus) prior to calling mockMvc.perform in
admin_cannotPerformInvalidStatusTransition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/test/java/org/example/alfs/controllers/TicketControllerIT.java`:
- Around line 84-100: In anonymousReporter_validToken_returnsView() remove the
extra ticket creation and instead fetch the seeded ticket's token created in
setUp() (use the stored ticketId from the test class) by calling
ticketService.findById(ticketId) or repository equivalent, then use that
ticket.getToken() in the mockMvc.perform(get("/tickets/token/" + ...)); update
references in the test to use ticketId and existing ticket retrieval so you no
longer call ticketService.createNewTicket(dto).
- Around line 206-214: The test admin_cannotPerformInvalidStatusTransition
relies on implicit state; make the precondition explicit by ensuring the ticket
is in the expected starting status before performing the POST: either reset or
fetch the ticket and assert/set its status to OPEN (and confirm no investigator
assigned) or explicitly transition it into a state that will unambiguously
reject the requested change (e.g., programmatically set to RESOLVED then attempt
RESOLVED→OPEN) so the invalid-transition intent is clear; modify the setup
inside TicketControllerIT (or this test) to arrange/assert the ticket's status
(using existing helpers like assignInvestigator or status setters used in
admin_canUpdateTicketStatus) prior to calling mockMvc.perform in
admin_cannotPerformInvalidStatusTransition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39a7c27f-36e0-4cfa-8023-acb94e496bc4

📥 Commits

Reviewing files that changed from the base of the PR and between 41c00e6 and 6e31813.

📒 Files selected for processing (1)
  • src/test/java/org/example/alfs/controllers/TicketControllerIT.java

@simonforsberg
simonforsberg merged commit fc2bb43 into main Apr 27, 2026
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 27, 2026
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.

1 participant