Add comprehensive unit test coverage across domain and service layers#183
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Add comprehensive unit test coverage across domain and service layers#183devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
- 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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds ~66 unit tests across 13 new test files covering the previously untested domain model and service layers:
Order(state machine lifecycle + invalid transitions),OrderLineItem,OrderLineItems,Restaurant,MenuItem,RestaurantMenu,Consumer,Courier,Plan,ActionOrderServiceTest— order creation, cancellation, revision, acceptance with courier assignment, and full state transition chain (APPROVED → DELIVERED), with mocked repositoriesConsumerServiceTest— validation, creation, lookupCourierServiceTest— creation, availability toggling, lookupBuild dependency changes:
junit:junit:4.12andmockito-core:2.+toftgo-domain(had no test deps)mockito-core:2.+toftgo-consumer-servicemockito-core:3.12.4+byte-buddy:1.12.10toftgo-order-serviceandftgo-courier-serviceto work around Mockito 2.x / Java 17 incompatibility when mocking Spring Data repository interfacesReview & Testing Checklist for Human
ftgo-consumer-serviceusesmockito-core:2.+(floating) whileftgo-order-serviceandftgo-courier-servicepinmockito-core:3.12.4+byte-buddy:1.12.10. The split exists because consumer-service avoids mockingCrudRepositorydirectly (uses reflection instead). Verify this is acceptable or if all modules should be aligned.ConsumerServiceTest(lines 26-29): UsesField.setAccessible(true)to inject the mockConsumerRepositorybecauseConsumerServiceuses@Autowiredfield injection. This is fragile — will break silently if the field is renamed. Consider whether this is acceptable or ifConsumerServiceshould be refactored to constructor injection.shouldAcceptOrdermocks theCourierclass (OrderServiceTestline 126) becauseCourier.planis not initialized outside JPA context, soaddAction()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../gradlew :ftgo-domain:test :ftgo-common:test :ftgo-consumer-service:test :ftgo-courier-service:test :ftgo-order-service:testlocally to confirm all new tests pass on your environment.Notes
byte-buddy:1.12.10dependency is needed because the version bundled with Spring Boot 2.0.3's Mockito 2.15.0 usessun.misc.Unsafe.defineClasswhich was removed in Java 17.OrderControllerTestfailures (unrelated to this PR) were not modified.Link to Devin session: https://app.devin.ai/sessions/3e95da912de843389401182e2d4515bc
Requested by: @tobydrinkall