Skip to content

Implement unit tests across all modules per UNIT_TEST_PLAN.md#193

Open
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1777640222-implement-unit-tests
Open

Implement unit tests across all modules per UNIT_TEST_PLAN.md#193
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1777640222-implement-unit-tests

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented May 1, 2026

Summary

Implements the unit test plan from UNIT_TEST_PLAN.md across 5 phases, adding 91 new test cases across 16 test classes (plus expanding the existing OrderControllerTest). All 102 tests pass locally (including pre-existing tests).

Phase 1 — Domain Model (28 tests)

  • OrderTest (12): Full state machine coverage (APPROVED→ACCEPTED→PREPARING→READY→PICKED_UP→DELIVERED), cancel, reject invalid transitions
  • CourierTest (9): Availability toggle, location tracking, delivery count, cancel delivery
  • PlanTest (4): Add/remove actions, filter by delivery, empty plan
  • RestaurantTest (3): Find menu item, unknown item, revise menu throws

Phase 2 — Common Module (7 tests)

  • AddressTest (3): Constructor with/without lat/lng, setter access
  • ErrorResponseTest (2): Field population, auto-timestamp
  • PersonNameTest (2): Field storage, JSON serialization round-trip

Phase 3 — Service Layer (21 tests, Mockito-based)

  • OrderServiceTest (11): Create order, restaurant-not-found, cancel, accept with courier scheduling, state transitions, delivery time estimation
  • ConsumerServiceTest (5): Create, find, validate, not-found exception
  • CourierServiceTest (5): Create, availability update, location update, not-found exception

Phase 4 — Controller Layer (16 tests, MockMvc)

  • OrderControllerTest (6): Expanded from 2 → 6 with create, cancel, accept, consumer orders
  • ConsumerControllerTest (3): Create, get, 404
  • CourierControllerTest (5): Create, get, availability, location, workload
  • RestaurantControllerTest (3): Create, get, 404

Phase 5 — Cross-cutting (9 tests)

  • ApiTrackingInterceptorTest (6): Correlation ID generation/propagation, persistence, error recording, graceful failure
  • ApiRequestLogTest (3): Creation with required fields, complete with status, complete with error

Build Changes

  • Upgraded Mockito to 4.11.0 and ByteBuddy to 1.14.9 (Java 17 compatibility)
  • Added --add-opens JVM args for Mockito reflection access on Java 17
  • Added ftgo-courier-service as test dependency in ftgo-order-service
  • Added mockito-core test dependency to ftgo-domain

Note on GlobalExceptionHandlerTest

The GlobalExceptionHandler lives in ftgo-application, which cannot compile tests due to the missing eventuate-util-test transitive dependency from ftgo-end-to-end-tests-common. The 7 exception handler behaviors are partially covered through controller-level 404 tests. A standalone test can be added once the eventuate dependency issue is resolved.

Review & Testing Checklist for Human

  • Verify all 102 tests pass locally: ./gradlew :ftgo-domain:test :ftgo-common:test :ftgo-order-service:test :ftgo-consumer-service:test :ftgo-courier-service:test :ftgo-restaurant-service:test
  • Review Mockito/ByteBuddy version upgrade in build.gradle — ensures Java 17 compatibility without breaking existing tests
  • Spot-check that new test assertions match actual production behavior (especially Order state machine transitions)

Notes

  • The ftgo-application module test compilation is blocked by a missing eventuate-util-test artifact — this is a pre-existing issue, not introduced by this PR
  • The new Long() deprecation warning in OrderControllerTest is carried over from the original test code

Link to Devin session: https://app.devin.ai/sessions/36cf0a22dc1a4682a07c9af2a10f6ccd
Requested by: @tobydrinkall


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)
Open in Devin Review

Phase 1 - Domain Model (28 tests):
- OrderTest: 12 tests covering state machine transitions and happy path
- CourierTest: 9 tests for availability, location, delivery tracking
- PlanTest: 4 tests for action management and filtering
- RestaurantTest: 3 tests for menu item lookup and revise

Phase 2 - Common Module (7 tests):
- AddressTest: 3 tests for constructors and field access
- ErrorResponseTest: 2 tests for field population and timestamp
- PersonNameTest: 2 tests for storage and serialization

Phase 3 - Service Layer (21 tests):
- OrderServiceTest: 11 tests covering CRUD, state transitions, delivery
- ConsumerServiceTest: 5 tests for create, find, validate
- CourierServiceTest: 5 tests for create, availability, location

Phase 4 - Controller Layer (16 tests):
- OrderControllerTest: 6 tests (expanded from 2) with create, cancel, accept
- ConsumerControllerTest: 3 tests for create, get, not-found
- CourierControllerTest: 5 tests for create, get, availability, location, workload
- RestaurantControllerTest: 3 tests for create, get, not-found

Phase 5 - Cross-cutting (9 tests):
- ApiTrackingInterceptorTest: 6 tests for correlation ID and persistence
- ApiRequestLogTest: 3 tests for creation and completion

Build changes:
- Upgraded Mockito to 4.11.0 and ByteBuddy to 1.14.9 for Java 17 compat
- Added JVM --add-opens args for Mockito reflection access
- Added ftgo-courier-service test dependency to ftgo-order-service

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Toby Drinkall <toby.drinkall@cognition.ai>
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