Add test coverage for single-table-inheritance pattern#3468
Add test coverage for single-table-inheritance pattern#3468rranjangupta wants to merge 4 commits intoiluwatar:masterfrom
Conversation
PR SummaryAdds test coverage for the single-table-inheritance module, including a smoke test for the main application and comprehensive CRUD tests for Vehicle entities across STI subtypes. Changes
autogenerated by presubmit.ai |
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Commits Considered (1)
- 1f451f2: Add STI tests
Files Processed (2)
- single-table-inheritance/src/test/java/com/iluwatar/SingleTableInheritanceTest.java (1 hunk)
- single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java (1 hunk)
Actionable Comments (1)
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [112-112]
possible_bug: "Floating-point comparison should include a delta"
Skipped Comments (1)
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [73-79]
maintainability: "Null-safe cleanup in tearDown"
| void saveVehicle_shouldPersistFreighterWithCorrectType() { | ||
| assertTrue(savedFreighter.getVehicleId() > 0); | ||
| assertInstanceOf(Freighter.class, savedFreighter); | ||
| assertEquals(8130.0, ((Freighter) savedFreighter).getFlightLength()); |
There was a problem hiding this comment.
Floating-point comparisons should specify a delta to account for precision. Use a tolerance when asserting double values.
There was a problem hiding this comment.
🚨 Pull request needs attention.
Review Summary
Commits Considered (1)
- 3fdda66: test: add delta for floating-point comparison in VehicleServiceTest
Files Processed (1)
- single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java (1 hunk)
Actionable Comments (1)
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [74-80]
possible bug: "Null-safety in teardown"
Skipped Comments (0)
| @AfterEach | ||
| void tearDown() { | ||
| vehicleService.deleteVehicle(savedCar); | ||
| vehicleService.deleteVehicle(savedTruck); | ||
| vehicleService.deleteVehicle(savedTrain); | ||
| vehicleService.deleteVehicle(savedFreighter); | ||
| } |
There was a problem hiding this comment.
Guard teardown against nulls: saved* references may be null if setup failed, which would cause a NullPointerException during cleanup. Add null checks before deleting.
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Commits Considered (1)
- 1b2d598: fix: guard teardown against nulls and use assertNotNull in VehicleServiceTest
Add null checks in @AfterEach tearDown() to prevent NullPointerException
if setUp() partially fails. Replace assertTrue(x != null) with assertNotNull(x).
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Files Processed (1)
- single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (4)
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [57-57]
maintainability: "Ensure injected dependency is non-null"
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [136-144]
possible bug: "Potential flakiness in getAllVehicles test"
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [75-81]
maintainability: "Teardown is null-safe; consider per-deletion isolation"
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [129-132]
best-practice: "Use a guaranteed non-existent ID for negative test"
…viceTest Add null checks in @AfterEach tearDown() to prevent NullPointerException if setUp() partially fails. Replace assertTrue(x != null) with assertNotNull(x).
1b2d598 to
0476a66
Compare
…st for consistency
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Commits Considered (1)
- 0476a66: fix: guard teardown against nulls and use assertNotNull in VehicleServiceTest
Add null checks in @AfterEach tearDown() to prevent NullPointerException
if setUp() partially fails. Replace assertTrue(x != null) with assertNotNull(x).
Files Processed (1)
- single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (2)
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [136-145]
readability: "Verify presence of all STI subtypes in bulk retrieval"
-
single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java [161-170]
readability: "Enhance deletion test coverage for non-existent or removed entities"
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Commits Considered (1)
- 5c78862: style: format code in SingleTableInheritanceTest and VehicleServiceTest for consistency
Files Processed (2)
- single-table-inheritance/src/test/java/com/iluwatar/SingleTableInheritanceTest.java (1 hunk)
- single-table-inheritance/src/test/java/com/iluwatar/service/VehicleServiceTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)
|
|
@iluwatar Can we please merge this? |



Pull Request Template
What does this PR do?
Adds test coverage for the
single-table-inheritancepattern module.SingleTableInheritanceTest.javafor testing the main application entry pointVehicleServiceTest.javawith comprehensive CRUD operation tests for Vehicle entitiesTest Run:
