Skip to content

Add comprehensive test coverage for Consumer, Restaurant, Courier services and expand Order tests#187

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

Add comprehensive test coverage for Consumer, Restaurant, Courier services and expand Order tests#187
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776690311-improve-test-coverage

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Adds ~1500 lines of test code covering three previously untested services (Consumer, Restaurant, Courier), a new OrderService unit test, expanded OrderController endpoint tests, and domain entity unit tests. Also introduces test data factories (ConsumerMother, CourierMother) and updates build infrastructure for test dependencies.

New test files (14):

  • Domain entities: OrderTest, CourierTest, RestaurantTest, ConsumerTest — state machine transitions, creation, validation
  • Service layer: ConsumerServiceTest, RestaurantServiceTest, CourierServiceTest, OrderServiceTest — mocked repository interactions
  • Controllers: ConsumerControllerTest, RestaurantControllerTest, CourierControllerTest — RestAssured MockMvc tests; OrderControllerTest expanded with 11 new endpoint tests (create, cancel, revise, accept, preparing, ready, pickedup, delivered)
  • Test data factories: ConsumerMother, CourierMother

Build changes:

  • Root build.gradle: Forces Mockito 4.11.0 + ByteBuddy 1.14.12 via configurations.all { resolutionStrategy } to fix Java 21 compatibility (Mockito 2.x bundled with Spring Boot 2.0.3 cannot mock interfaces on Java 21)
  • ftgo-consumer-service/build.gradle and ftgo-restaurant-service/build.gradle: Migrated from deprecated com.jayway.restassured to io.rest-assured:3.0.6, added spring-mock-mvc and ftgo-test-util dependencies
  • ftgo-domain/build.gradle: Added mockito-core test dependency

Review & Testing Checklist for Human

  • Global dependency forcing in root build.gradle: The configurations.all { resolutionStrategy { force ... } } applies to ALL configurations (compile + runtime), not just test. Verify this doesn't affect production runtime behavior. Consider scoping to testImplementation/testCompile only if possible.
  • RestAssured package migration: ftgo-consumer-service and ftgo-restaurant-service switched from com.jayway.restassuredio.rest-assured. Confirm no existing test code in those modules relied on the old package (they should have had zero tests, but double-check).
  • Reflection-based private field access: Several tests use Field.setAccessible(true) to set entity IDs (e.g., ConsumerControllerTest.setConsumerId, CourierControllerTest.setCourierId, domain tests setting Order.id). Verify this works under Java 21's module access rules in CI.
  • Test correctness spot-check: Review a sample of domain entity tests (OrderTest, CourierTest) to verify state transition assertions are meaningful and not just trivially passing. The CourierServiceTest uses manual mock() in @Before while others use @RunWith(MockitoJUnitRunner.class) — minor inconsistency.

Suggested test plan: Run ./gradlew :ftgo-domain:test :ftgo-consumer-service:test :ftgo-restaurant-service:test :ftgo-courier-service:test :ftgo-order-service:test locally and verify all tests pass. Check that pre-existing tests (e.g., CourierAssignmentStrategyTest, AddressTest) still pass with the forced dependency versions.

Notes

  • The Mockito/ByteBuddy version forcing was necessary because Spring Boot 2.0.3 bundles Mockito 2.15.0 which uses ByteBuddy 1.7.9 — this cannot create mock proxies under Java 21's stricter reflection rules (java.lang.UnsupportedOperationException: Cannot define class using reflection).
  • Controller tests use inline JSON strings for request bodies rather than ObjectMapper serialization. These match the current DTO structures but won't auto-update if DTOs change.

Link to Devin session: https://app.devin.ai/sessions/8d5dc462c316414393712dd16db9c1cb
Requested by: @bcmake

…vices and expand Order tests

- Add domain entity tests: OrderTest, CourierTest, RestaurantTest, ConsumerTest
- Add service layer tests: ConsumerServiceTest, RestaurantServiceTest, CourierServiceTest, OrderServiceTest
- Add controller tests: ConsumerControllerTest, RestaurantControllerTest, CourierControllerTest
- Expand OrderControllerTest with 11 new endpoint tests (create, cancel, revise, accept, lifecycle)
- Add test data factories: ConsumerMother, CourierMother
- Update build.gradle files with test dependencies for consumer, restaurant, courier services
- Fix Mockito/ByteBuddy Java 21 compatibility via dependency resolution strategy

Co-Authored-By: benc <Benc@windsurf.com>
@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

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.

0 participants