Improve test coverage from 67% to 94%#7
Conversation
- Add JaCoCo coverage plugin to pom.xml - Add QuoteService, ExperimentalRankingService, ProviderService unit tests - Add QuoteWebController, AdminController, ProviderWebController MockMvc tests - Add MapApiController, ProviderApiController, HealthController API tests - Add DataSeeder integration test - Coverage: 67% → 94% instruction coverage Co-Authored-By: Bobby Nobakht <bobby.nobakht@cognition.ai>
🤖 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:
|
| when(providerService.getAllProviders()).thenReturn(List.of(new Provider())); | ||
| when(providerMapper.toDtoList(List.of(new Provider()))).thenReturn(List.of(dto)); |
There was a problem hiding this comment.
🟡 Mockito stub for toDtoList never matches due to Provider lacking equals()
The mock at line 37 uses List.of(new Provider()) as the expected argument, but providerService.getAllProviders() (stubbed at line 36) returns a list containing a different new Provider() instance. Since Provider does not override equals() (backend/src/main/java/com/compare/domain/Provider.java), Mockito's default equals-based matching compares by reference identity, so the toDtoList stub never matches. The mock returns null instead of List.of(dto), and the test only passes because it asserts status().isOk() — ResponseEntity.ok(null) still returns HTTP 200. The test gives false confidence that the mapper integration is working.
| when(providerService.getAllProviders()).thenReturn(List.of(new Provider())); | |
| when(providerMapper.toDtoList(List.of(new Provider()))).thenReturn(List.of(dto)); | |
| Provider provider = new Provider(); | |
| when(providerService.getAllProviders()).thenReturn(List.of(provider)); | |
| when(providerMapper.toDtoList(List.of(provider))).thenReturn(List.of(dto)); |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Adds JaCoCo coverage plugin and comprehensive unit/integration tests to increase instruction coverage from 67% → 94%.
New tests added (11 files):
Key changes to pom.xml:
prepare-agentandreportgoalsReview & Testing Checklist for Human
Low risk — only adds tests and a coverage plugin; no source code changes.
cd backend && ./mvnw test -qand confirm all 82+ tests pass with 0 failuresbackend/target/site/jacoco/index.htmlshows ≥85% instruction coverageNotes
Link to Devin session: https://bobby-demo.devinenterprise.com/sessions/a91b9e60b18f4fc0b3b784e65b059883
Requested by: @bnob-git