-
Notifications
You must be signed in to change notification settings - Fork 0
EI-11 GET batches/{id} endpoint #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Connected the batches/{id} endpoint to the database. Tested that it works using Postman. Updated Unit Tests also
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
...int-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java
Show resolved
Hide resolved
...int-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java
Show resolved
Hide resolved
...int-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java
Show resolved
Hide resolved
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java
Outdated
Show resolved
Hide resolved
Put DTO in its own class and used mapStruct so it can auto generated the mapping.
WalkthroughAdded MapStruct integration with Lombok binding and refactored Batch API to use UUID identifiers, DTOs, repository patterns, and a dedicated mapper. Updated controller, service, and tests to use new BatchResponseDTO with revised fields and explicit exception handling. Changes
Sequence DiagramsequenceDiagram
autonumber
actor Client
participant Controller as BatchesController
participant Service as BatchService
participant Repository as TestBatchRepository
participant Mapper as BatchMapper
participant DB as Database
rect rgb(200, 220, 240)
Note over Client,DB: GET /api/batches/{id} - Fetch Single Batch
Client->>Controller: getBatch(UUID id)
Controller->>Service: getBatchById(id)
Service->>Repository: findById(id)
Repository->>DB: SELECT * FROM test_batch WHERE id=?
DB-->>Repository: TestBatch entity
alt Found
Repository-->>Service: Optional<TestBatch>
Service->>Mapper: toDto(entity)
Mapper-->>Service: BatchResponseDTO
Service-->>Controller: BatchResponseDTO
Controller-->>Client: 200 OK + DTO
else Not Found
Service->>Service: throw BatchNotFoundException
Service-->>Controller: BatchNotFoundException
Controller-->>Client: 404 NOT_FOUND
end
end
rect rgb(240, 220, 200)
Note over Client,DB: DELETE /api/batches/{id} - Delete Batch
Client->>Controller: deleteBatch(UUID id)
Controller->>Service: deleteBatchById(id)
Service->>Repository: existsById(id)
Repository->>DB: SELECT EXISTS(*)
DB-->>Repository: boolean
alt Exists
Repository-->>Service: true
Service->>Repository: deleteById(id)
Repository->>DB: DELETE FROM test_batch WHERE id=?
Service-->>Controller: void
Controller-->>Client: 204 NO_CONTENT
else Not Found
Repository-->>Service: false
Service->>Service: throw BatchNotFoundException
Service-->>Controller: BatchNotFoundException
Controller-->>Client: 404 NOT_FOUND
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java (1)
25-48: Stubbed list/create/update endpoints should eventually use the service/DB
listBatches,createBatch, andupdateBatchstill constructBatchResponseDTOinstances in memory with hard‑coded or calculated values andUUID.randomUUID()instead of going throughBatchService/ the database. Prior reviewers have already called this out, and you’ve noted it’s out of scope for this sprint.Once the backing persistence is ready, it would be good to:
- Have
listBatchesquery via a service/repository instead of returning literals.- Route
createBatchandupdateBatchthroughBatchService, letting the DB assign the UUID and persiststartTime/lastTimeRunconsistently.- Remove now‑unused imports like
Collectionsand commentedjobsfields when that work is done.Also applies to: 56-84
🧹 Nitpick comments (4)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchRequestDTO.java (1)
16-19: DTO shape looks consistent; consider name vs batchName alignmentThe added fields (
scheduleId,startTime,active) look consistent withBatchResponseDTOand the new service layer usage. One optional cleanup is to consider aligningnamehere withbatchNameinBatchResponseDTO(or vice versa), or ensure the mapper/service explicitly handles the difference so you don’t get silent mapping issues later.endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/mapper/BatchMapper.java (1)
7-11: Verify MapStruct field mappings, especially ID and name fieldsThe mapper definition is fine, but with a bare
toDto(TestBatch entity)MapStruct will only map by matching property names. In the tests you’re callingentity.setBatch_id(id)whileBatchResponseDTOexposesid, and you also havebatchName/namedifferences elsewhere. If the entity’s property names don’t exactly match the DTO, you’ll get nulls or warnings at build time.Consider adding explicit mappings, e.g.
@Mapping(source = "batch_id", target = "id"), and any others that differ, to make the mapping contract explicit and future‑proof.endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (1)
29-49: Strengthen assertions and interaction checks in service tests (optional)A couple of small improvements would make these tests more robust:
- In
getBatchById_returnsDto, you already setstartTimeandlastTimeRunon the entity; consider also asserting them on the returned DTO to detect future mapping regressions.- In
deleteBatchById_NotFound, you can optionally verify thatdeleteByIdis never called whenexistsByIdis false, to pin down the intended behavior.For example:
@@ void getBatchById_returnsDto() { - assertThat(dto.getId()).isEqualTo(id); - assertThat(dto.getBatchName()).isEqualTo("Example"); - assertThat(dto.getScheduleId()).isEqualTo(1001L); - assertThat(dto.getActive()).isTrue(); + assertThat(dto.getId()).isEqualTo(id); + assertThat(dto.getBatchName()).isEqualTo("Example"); + assertThat(dto.getScheduleId()).isEqualTo(1001L); + assertThat(dto.getStartTime()).isEqualTo(LocalDate.parse("2025-11-08")); + assertThat(dto.getLastTimeRun()).isEqualTo(LocalDate.parse("2025-11-09")); + assertThat(dto.getActive()).isTrue(); @@ void deleteBatchById_NotFound() { - assertThrows(BatchNotFoundException.class, () -> batchService.deleteBatchById(id)); + assertThrows(BatchNotFoundException.class, () -> batchService.deleteBatchById(id)); + verify(testBatchRepository, org.mockito.Mockito.never()).deleteById(id);These are optional but help lock in the intended contract of
BatchService.Also applies to: 59-75
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchResponseDTO.java (1)
11-22: DTO shape matches usage; consider naming consistency withBatchRequestDTO
BatchResponseDTO’s fields (id,batchName,scheduleId,startTime,lastTimeRun,active) line up with how the controller and tests are using the response. The only minor inconsistency is that the request DTO usesnamewhile the response usesbatchName, which can be slightly confusing for API consumers.If you don’t have external clients depending on these names yet, you might consider aligning them (either
nameeverywhere orbatchNameeverywhere) in a follow‑up change.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
endpoint-insights-api/pom.xml(2 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchRequestDTO.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchResponseDTO.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/mapper/BatchMapper.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/repository/TestBatchRepository.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java(1 hunks)endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java(2 hunks)endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/JobsController.java (1)
RestController(25-157)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchResponseDTO.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchRequestDTO.java (1)
Getter(11-20)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchRequestDTO.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchResponseDTO.java (1)
Getter(11-23)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java (3)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/JobControllerUnitTest.java (1)
TestPropertySource(29-103)endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/EndpointInsightsApiApplicationTests.java (1)
ActiveProfiles(8-18)
🪛 GitHub Actions: Codecov Backend
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/repository/TestBatchRepository.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java
[error] 43-43: NullPointerException encountered in test: Cannot invoke "com.vsp.endpointinsightsapi.mapper.BatchMapper.toDto(...)" because "this.batchMapper" is null
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/mapper/BatchMapper.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchResponseDTO.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java
[error] 34-34: NullPointerException: Cannot invoke "com.vsp.endpointinsightsapi.mapper.BatchMapper.toDto(com.vsp.endpointinsightsapi.model.TestBatch)" because "this.batchMapper" is null
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/dto/BatchRequestDTO.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/pom.xml
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java
[error] 1-1: Maven Surefire test suite failed. See target/surefire-reports for details.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Jenkins / Linting and Unit Tests
🔇 Additional comments (5)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/repository/TestBatchRepository.java (1)
9-10: Standard Spring Data repository – looks good
TestBatchRepositorycleanly extendsJpaRepository<TestBatch, UUID>with no custom methods. This is idiomatic Spring Data JPA and should integrate fine withBatchService.endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
5-13: Exception design and error payload look appropriateError code, HTTP status, and message are clear and match the not‑found semantics used in the service and controller tests. This should give a consistent API error contract for missing batches.
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java (1)
76-83: Good coverage of not‑found scenarios for GET and DELETEThe tests for
getBatchById_notFound_shouldReturn404andshouldReturn404WhenDeletingNonexistentBatchcorrectly exercise theBatchNotFoundExceptionpath and assert 404 responses, matching the new service behavior.Also applies to: 136-145
endpoint-insights-api/pom.xml (1)
103-120: MapStruct + Lombok wiring in the POM looks consistentThe added
mapstruct,mapstruct-processor(asprovided), andlombok-mapstruct-bindingdependencies, along with the correspondingannotationProcessorPaths, form a coherent setup for MapStruct + Lombok code generation.Also applies to: 186-195
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java (1)
19-23: GET and DELETE by ID correctly delegate toBatchServiceThe controller now uses constructor injection for
BatchService, and bothgetBatchanddeleteBatchcleanly delegate tobatchService.getBatchById(id)/batchService.deleteBatchById(id), returning200 OKand204 No Contentrespectively. This aligns with the new service behavior and the updated tests.Also applies to: 50-54, 86-90
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java
Outdated
Show resolved
Hide resolved
...ghts-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java
Show resolved
Hide resolved
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java
Show resolved
Hide resolved
Mocked the mapper in the testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (1)
31-60: Tighten happy‑path assertions and remove scaffolding comment
- Line 34’s
// adjust getters/setters to your modellooks like leftover scaffolding; it can be removed to avoid confusion.- You currently assert only
idandbatchName. Since you build a fullBatchResponseDTO(scheduleId, startTime, lastTimeRun, active), consider asserting those fields too (or comparing the whole DTO) to catch mapping regressions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Jenkins / Linting and Unit Tests
🔇 Additional comments (4)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (4)
26-28: Mocks and injection wiring look correctMocking both
TestBatchRepositoryandBatchMapperand using@InjectMocksforBatchServicecorrectly wires constructor injection and prevents the previous NPE onbatchMapper. This setup is solid for isolating service behavior.
62-68: Not‑found getBatchById test is clear and focusedThe
getBatchById_notFound_throwstest cleanly stubsfindByIdtoOptional.empty()and assertsBatchNotFoundException, which matches the intended error path and keeps the behavior well specified.
70-78: Delete existing batch test covers the main behavior
deleteBatchById_Existscorrectly stubsexistsByIdand verifiesdeleteById(id)is called, which is the critical side effect for this path. This gives good coverage of the successful delete flow.
80-86: Delete not‑found test correctly guards the error path
deleteBatchById_NotFoundstubsexistsByIdtofalseand assertsBatchNotFoundException, matching the service contract for missing batches and rounding out the negative‑path coverage.
Code rabbit suggestions inputted
Fixed small bug with mapping for getting batch by id. And fixed unit test problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/mapper/BatchMapper.java (1)
8-13: LGTM! MapStruct mapper properly configured.The
componentModel = "spring"ensures Spring will manage this mapper as a bean, and the explicit@Mappingforbatch_id → idis necessary given the entity's field naming.Optional: Consider renaming TestBatch.batch_id to camelCase.
The source field
batch_iduses snake_case, which violates Java naming conventions. While this is a pre-existing issue in theTestBatchentity (not introduced by this PR), refactoring tobatchIdwould align with Java standards and eliminate the need for explicit field mapping.endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java (2)
41-41: Remove commented-out code.Lines 41 and 50 contain commented
.jobs(Collections.emptyList())calls. Commented code should be removed to improve readability.Apply this diff:
.lastTimeRun(LocalDate.now()) .active(true) -// .jobs(Collections.emptyList()) .build(),.lastTimeRun(LocalDate.now().minusDays(3)) .active(false) -// .jobs(Collections.emptyList()) .build()Also applies to: 50-50
65-67: Consider returning BatchResponseDTO for consistency.The
createBatchmethod returns aTestBatchentity, while other endpoints (getBatch,updateBatch,listBatches) returnBatchResponseDTO. This inconsistency exposes internal entity structure in the API response.For consistency across the API, consider mapping the saved entity to
BatchResponseDTObefore returning:@PostMapping -public ResponseEntity<TestBatch> createBatch(@RequestBody BatchRequestDTO request) { +public ResponseEntity<BatchResponseDTO> createBatch(@RequestBody BatchRequestDTO request) { TestBatch batch = batchService.createBatch(request); - return ResponseEntity.status(HttpStatus.CREATED).body(batch); + BatchResponseDTO dto = batchMapper.toDto(batch); + return ResponseEntity.status(HttpStatus.CREATED).body(dto); }Note: This would require injecting
BatchMapperinto the controller or adding acreateBatchmethod toBatchServicethat returns the DTO.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java(2 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/mapper/BatchMapper.java(1 hunks)endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java(3 hunks)endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java(4 hunks)endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/JobsController.java (1)
RestController(25-141)
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java (1)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/exception/BatchNotFoundException.java (1)
BatchNotFoundException(8-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Jenkins / Linting and Unit Tests
🔇 Additional comments (11)
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/service/BatchService.java (3)
27-31: LGTM! Constructor properly enforces non-null dependencies.The use of
Objects.requireNonNullfor all three dependencies ensures fail-fast behavior if any dependency is null, which addresses the NPE issues mentioned in previous reviews.
34-41: LGTM! Clean implementation of batch retrieval.The method correctly:
- Uses
Optional.orElseThrowfor explicit exception handling- Logs at the appropriate DEBUG level before throwing
- Delegates DTO mapping to the dedicated mapper
44-53: LGTM! Delete operation with proper existence check.The existence check before deletion prevents unnecessary exceptions and provides clear error messaging. The INFO-level logging on successful deletion aids observability.
endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/service/BatchServiceTest.java (3)
24-30: LGTM! Proper Mockito setup with all dependencies mocked.The addition of
@Mock BatchMapperalongside the repository mocks ensures all constructor dependencies are satisfied, preventing the NPE issues from previous commits.
33-62: LGTM! Comprehensive test with proper mocking and verification.The test correctly:
- Mocks both repository and mapper behavior
- Verifies the returned DTO fields
- Uses
verify()to confirm interactions with both dependencies
64-88: LGTM! Thorough error-case coverage.Both not-found scenarios (getBatchById and deleteBatchById) are properly tested with appropriate exception assertions.
endpoint-insights-api/src/main/java/com/vsp/endpointinsightsapi/controller/BatchesController.java (2)
58-61: LGTM! GET endpoint properly connected to service and database.The implementation correctly delegates to
BatchService.getBatchById, which fetches from the repository and returns a DTO. This fulfills the PR objective.
84-87: LGTM! DELETE endpoint properly connected to service and database.The delegation to
BatchService.deleteBatchByIdensures existence checks and exception handling are performed at the service layer, returning the appropriate 204 No Content on success.endpoint-insights-api/src/test/java/com/vsp/endpointinsightsapi/controller/BatchesControllerUnitTest.java (3)
51-71: LGTM! Test properly validates GET endpoint with DTO response.The test correctly:
- Mocks
BatchService.getBatchByIdto return aBatchResponseDTO- Verifies all DTO fields in the JSON response
- Uses the UUID path variable as expected
74-80: LGTM! Proper 404 handling for not-found scenario.The test verifies that
BatchNotFoundExceptionthrown by the service results in a 404 HTTP status, confirming correct exception handling.
113-132: LGTM! Comprehensive DELETE endpoint testing.Both success (204 No Content) and error (404 Not Found) cases are properly tested with appropriate service mocking.
Connected the batches/{id} endpoint to the database. Tested that it works using Postman. Updated Unit Tests also
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.