Skip to content

Add comprehensive unit test coverage across domain and service layers#183

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776186938-unit-test-coverage
Open

Add comprehensive unit test coverage across domain and service layers#183
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776186938-unit-test-coverage

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 14, 2026

Summary

Adds ~66 unit tests across 13 new test files covering the previously untested domain model and service layers:

  • ftgo-domain (10 test files): Order (state machine lifecycle + invalid transitions), OrderLineItem, OrderLineItems, Restaurant, MenuItem, RestaurantMenu, Consumer, Courier, Plan, Action
  • ftgo-order-service (1 test file): OrderServiceTest — order creation, cancellation, revision, acceptance with courier assignment, and full state transition chain (APPROVED → DELIVERED), with mocked repositories
  • ftgo-consumer-service (1 test file): ConsumerServiceTest — validation, creation, lookup
  • ftgo-courier-service (1 test file): CourierServiceTest — creation, availability toggling, lookup

Build dependency changes:

  • Added junit:junit:4.12 and mockito-core:2.+ to ftgo-domain (had no test deps)
  • Added mockito-core:2.+ to ftgo-consumer-service
  • Added mockito-core:3.12.4 + byte-buddy:1.12.10 to ftgo-order-service and ftgo-courier-service to work around Mockito 2.x / Java 17 incompatibility when mocking Spring Data repository interfaces

Review & Testing Checklist for Human

  • Mockito version inconsistency: ftgo-consumer-service uses mockito-core:2.+ (floating) while ftgo-order-service and ftgo-courier-service pin mockito-core:3.12.4 + byte-buddy:1.12.10. The split exists because consumer-service avoids mocking CrudRepository directly (uses reflection instead). Verify this is acceptable or if all modules should be aligned.
  • Reflection-based mock injection in ConsumerServiceTest (lines 26-29): Uses Field.setAccessible(true) to inject the mock ConsumerRepository because ConsumerService uses @Autowired field injection. This is fragile — will break silently if the field is renamed. Consider whether this is acceptable or if ConsumerService should be refactored to constructor injection.
  • shouldAcceptOrder mocks the Courier class (OrderServiceTest line 126) because Courier.plan is not initialized outside JPA context, so addAction() NPEs on a real instance. This means the courier delivery planning logic is not fully exercised. Verify the assertion (verify(courier, times(2)).addAction(...)) is sufficient.
  • Run ./gradlew :ftgo-domain:test :ftgo-common:test :ftgo-consumer-service:test :ftgo-courier-service:test :ftgo-order-service:test locally to confirm all new tests pass on your environment.

Notes

  • The explicit byte-buddy:1.12.10 dependency is needed because the version bundled with Spring Boot 2.0.3's Mockito 2.15.0 uses sun.misc.Unsafe.defineClass which was removed in Java 17.
  • Pre-existing OrderControllerTest failures (unrelated to this PR) were not modified.

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


Open with Devin

- ftgo-domain: Add tests for Order (state machine lifecycle), OrderLineItem,
  OrderLineItems, Restaurant, MenuItem, RestaurantMenu, Consumer, Courier,
  Plan, and Action classes
- ftgo-order-service: Add OrderServiceTest with mocked dependencies covering
  create, cancel, revise, accept, and state transition operations
- ftgo-consumer-service: Add ConsumerServiceTest covering validation, creation,
  and lookup operations
- ftgo-courier-service: Add CourierServiceTest covering creation, availability
  updates, and lookup operations
- Upgrade Mockito/ByteBuddy in order-service and courier-service for Java 17
  compatibility
- Add test dependencies to ftgo-domain module

Total: ~66 new test cases across 13 test files
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

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

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