Skip to content

Improve test coverage from 67% to 94%#7

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1778766456-improve-test-coverage
Open

Improve test coverage from 67% to 94%#7
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1778766456-improve-test-coverage

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

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

Summary

Adds JaCoCo coverage plugin and comprehensive unit/integration tests to increase instruction coverage from 67% → 94%.

New tests added (11 files):

  • Service tests: QuoteServiceTest, ExperimentalRankingServiceTest, ProviderServiceTest
  • Web controller tests: QuoteWebControllerTest, AdminControllerTest, ProviderWebControllerTest, HomeControllerTest
  • API controller tests: ProviderApiControllerTest, MapApiControllerTest, HealthControllerTest
  • Integration test: DataSeederTest

Key changes to pom.xml:

  • Added JaCoCo Maven plugin with prepare-agent and report goals

Review & Testing Checklist for Human

Low risk — only adds tests and a coverage plugin; no source code changes.

  • Run cd backend && ./mvnw test -q and confirm all 82+ tests pass with 0 failures
  • Check JaCoCo report at backend/target/site/jacoco/index.html shows ≥85% instruction coverage

Notes

  • Tests use MockMvc for controller tests, Mockito for service tests, and @SpringBootTest for integration tests
  • UK postcode validation tests use valid format postcodes (e.g., "SW1A 1AA")

Link to Devin session: https://bobby-demo.devinenterprise.com/sessions/a91b9e60b18f4fc0b3b784e65b059883
Requested by: @bnob-git


Open in Devin Review

- 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-integration
Copy link
Copy Markdown
Contributor 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
Contributor 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 found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +36 to +37
when(providerService.getAllProviders()).thenReturn(List.of(new Provider()));
when(providerMapper.toDtoList(List.of(new Provider()))).thenReturn(List.of(dto));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🟡 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.

Suggested change
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));
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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