Add library-management module: console app evolved into a Spring Boot 4 REST API
Stage 2 console classes and the shared LoanPolicy, then a Spring Boot 4.1.2 + JPA API (H2, @Version optimistic locking, problem+json errors). Tests write output/ transcripts while asserting the same numbers; scripts regenerate everything. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4DPL6dtpFg4U4LHc2
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
> POST /books {"isbn":"978-0134685991","title":"Effective Java","author":"Joshua Bloch","copies":2}
|
||||
{"id":1,"isbn":"978-0134685991","title":"Effective Java","author":"Joshua Bloch","totalCopies":2,"availableCopies":2}
|
||||
< HTTP 201
|
||||
|
||||
> POST /books {"isbn":"978-0596009205","title":"Head First Java","author":"Kathy Sierra","copies":1}
|
||||
{"id":2,"isbn":"978-0596009205","title":"Head First Java","author":"Kathy Sierra","totalCopies":1,"availableCopies":1}
|
||||
< HTTP 201
|
||||
|
||||
> POST /books {"isbn":"","title":"","author":"Nobody","copies":0}
|
||||
{"detail":"request body failed validation","instance":"/api/books","status":400,"title":"Bad Request","errors":{"copies":"must be greater than or equal to 1","isbn":"must not be blank","title":"must not be blank"}}
|
||||
< HTTP 400
|
||||
|
||||
> POST /members {"name":"Asha","email":"[email protected]"}
|
||||
{"id":1,"name":"Asha","email":"[email protected]"}
|
||||
< HTTP 201
|
||||
|
||||
> POST /members {"name":"Ravi","email":"not-an-email"}
|
||||
{"detail":"request body failed validation","instance":"/api/members","status":400,"title":"Bad Request","errors":{"email":"must be a well-formed email address"}}
|
||||
< HTTP 400
|
||||
|
||||
> POST /members {"name":"Ravi","email":"[email protected]"}
|
||||
{"id":2,"name":"Ravi","email":"[email protected]"}
|
||||
< HTTP 201
|
||||
|
||||
> POST /loans {"memberId":1,"bookId":2}
|
||||
{"id":1,"bookTitle":"Head First Java","memberName":"Asha","borrowedOn":"2026-11-14","dueOn":"2026-11-28","returnedOn":null,"fine":0}
|
||||
< HTTP 201
|
||||
|
||||
> POST /loans {"memberId":2,"bookId":2}
|
||||
{"detail":"no copies of 'Head First Java' are available","instance":"/api/loans","status":409,"title":"Conflict"}
|
||||
< HTTP 409
|
||||
|
||||
> POST /loans/1/return
|
||||
{"id":1,"bookTitle":"Head First Java","memberName":"Asha","borrowedOn":"2026-11-14","dueOn":"2026-11-28","returnedOn":"2026-11-14","fine":0}
|
||||
< HTTP 200
|
||||
|
||||
> GET /books
|
||||
[{"id":1,"isbn":"978-0134685991","title":"Effective Java","author":"Joshua Bloch","totalCopies":2,"availableCopies":2},{"id":2,"isbn":"978-0596009205","title":"Head First Java","author":"Kathy Sierra","totalCopies":1,"availableCopies":1}]
|
||||
< HTTP 200
|
||||
|
||||
Reference in New Issue
Block a user