add unit testing for create grocery list, delete account, add grocery item, and remove grocery item - #35
Conversation
Greptile SummaryThis PR adds unit tests for four service-layer use cases: create grocery list, delete account, add grocery item, and remove grocery item. The tests are well-structured using JUnit 5 nested classes, Mockito mocks, and Confidence Score: 5/5Safe to merge — all findings are P2 suggestions with no blocking correctness issues. Both files add test-only code with no changes to production logic. All identified issues are minor gaps in coverage (untested deleteUser(Integer id) overload, missing duplicate-item edge case) rather than defects in the tests themselves. Existing test assertions correctly reflect service behaviour. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Test
participant GroceryListService
participant UserRepository
participant GroceryListRepository
participant ItemRepository
Note over Test,ItemRepository: addGroceryList (success path)
Test->>GroceryListService: addGroceryList(username, dto)
GroceryListService->>UserRepository: findByUsername(username)
UserRepository-->>GroceryListService: Optional<User>
GroceryListService->>GroceryListRepository: save(groceryList)
GroceryListService->>UserRepository: save(user)
Note over Test,ItemRepository: addItemToGroceryList (success path)
Test->>GroceryListService: addItemToGroceryList(username, listId, itemId)
GroceryListService->>UserRepository: findByUsername(username)
UserRepository-->>GroceryListService: Optional<User>
GroceryListService->>GroceryListRepository: findById(listId)
GroceryListRepository-->>GroceryListService: Optional<GroceryList>
GroceryListService->>ItemRepository: findById(itemId)
ItemRepository-->>GroceryListService: Optional<Item>
GroceryListService->>GroceryListRepository: save(groceryList)
Note over Test,ItemRepository: removeItemFromGroceryList (success path)
Test->>GroceryListService: removeItemFromGroceryList(username, listId, itemId)
GroceryListService->>UserRepository: findByUsername(username)
UserRepository-->>GroceryListService: Optional<User>
GroceryListService->>GroceryListRepository: findById(listId)
GroceryListRepository-->>GroceryListService: Optional<GroceryList>
GroceryListService->>ItemRepository: findById(itemId)
ItemRepository-->>GroceryListService: Optional<Item>
GroceryListService->>GroceryListRepository: save(groceryList)
Reviews (1): Last reviewed commit: "Add remove grocery item tests" | Re-trigger Greptile |
No description provided.