The test suite covers only the happy path. Manual API testing reveals unhandled edge cases: missing
entities return 500 instead of 404, business rule violations surface as unstructured errors, and
lazy associations accessed outside a transaction throw 500s. This issue adds negative-path coverage
and fixes the underlying service-layer issues that these tests expose.
Use FreightOrderControllerTest as the reference pattern for test setup.
404 β Entity not found (one test per controller):
VesselControllerTest β GET /vessels/9999 β 404
VoyageControllerTest β GET /voyages/9999 β 404
FreightOrderControllerTest β GET /freight-orders/9999 β 404
PortControllerTest β GET /ports/9999 β 404
CustomerControllerTest β GET /customers/9999 β 404
AgentControllerTest β GET /agents/9999 β 404
InvoiceControllerTest β invoice for non-existent order ID β 404
400 β Validation failures:
VoyageControllerTest β create voyage with missing required fields β 400
FreightOrderControllerTest β create order with missing voyageId, containerId, or
customerId β 400
FreightOrderControllerTest β discountPercent > 100 β 400
Business rule violations:
FreightOrderControllerTest β book the same container on two active voyages β 400
(double-booking)
InvoiceControllerTest β generate invoice for an order not in DELIVERED status β appropriate
4xx (not 500)
Underlying fixes required by these tests:
- Any service method that throws
IllegalArgumentException for a not-found case must throw
ResponseStatusException(NOT_FOUND) instead β the GlobalExceptionHandler then returns 404
- Any service method that accesses a lazy association must be annotated
@Transactional or
@Transactional(readOnly = true) as appropriate
Acceptance criteria:
The test suite covers only the happy path. Manual API testing reveals unhandled edge cases: missing
entities return 500 instead of 404, business rule violations surface as unstructured errors, and
lazy associations accessed outside a transaction throw 500s. This issue adds negative-path coverage
and fixes the underlying service-layer issues that these tests expose.
Use
FreightOrderControllerTestas the reference pattern for test setup.404 β Entity not found (one test per controller):
VesselControllerTestβGET /vessels/9999β 404VoyageControllerTestβGET /voyages/9999β 404FreightOrderControllerTestβGET /freight-orders/9999β 404PortControllerTestβGET /ports/9999β 404CustomerControllerTestβGET /customers/9999β 404AgentControllerTestβGET /agents/9999β 404InvoiceControllerTestβ invoice for non-existent order ID β 404400 β Validation failures:
VoyageControllerTestβ create voyage with missing required fields β 400FreightOrderControllerTestβ create order with missingvoyageId,containerId, orcustomerIdβ 400FreightOrderControllerTestβdiscountPercent> 100 β 400Business rule violations:
FreightOrderControllerTestβ book the same container on two active voyages β 400(double-booking)
InvoiceControllerTestβ generate invoice for an order not inDELIVEREDstatus β appropriate4xx (not 500)
Underlying fixes required by these tests:
IllegalArgumentExceptionfor a not-found case must throwResponseStatusException(NOT_FOUND)instead β theGlobalExceptionHandlerthen returns 404@Transactionalor@Transactional(readOnly = true)as appropriateAcceptance criteria:
ResponseStatusException(NOT_FOUND), not 500@Transactional