-
Notifications
You must be signed in to change notification settings - Fork 0
feature/scaffold book api and createBook service logic and tests #1
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
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.
Pull Request Overview
This PR establishes the foundational service layer for a Book API, implementing the createBook operation with comprehensive test coverage using TDD principles. The implementation follows HMCTS architectural standards with clear separation of concerns across DTOs, entities, repositories, and services.
Key Changes:
- Implemented
createBookservice method with validation logic and DTO-to-Entity mapping - Created comprehensive unit tests covering happy path, validation, edge cases, and error scenarios
- Established Book entity with UUID-based identification, soft-delete support, and JPA annotations
- Defined immutable BookRequest DTO with validation constraints and JSON property mapping
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| BookService.java | Core service implementation with createBook method, validation logic, and entity mapping |
| BookServiceTest.java | Comprehensive unit tests with Mockito mocks covering success, validation, repository failures, and edge cases |
| Book.java | JPA entity with UUID primary key, soft-delete flag, timestamp tracking, and Lombok builder pattern |
| BookRequest.java | Immutable DTO with @notblank validation and @JsonProperty for snake_case mapping |
| BookRepository.java | Spring Data JPA repository interface with custom query methods for soft-delete support |
| openapi.yml | OpenAPI 3.0.3 specification defining Book API contract with UUID-based identifiers |
| application.yaml | Basic Spring application configuration |
| build.gradle | Added junit-jupiter-params dependency for parameterized testing |
| BookApiApplication.java | Spring Boot application entry point |
| BookApiApplicationTests.java | Basic Spring context load test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/codesungrape/hmcts/BookAPI/service/BookService.java
Outdated
Show resolved
Hide resolved
src/test/java/com/codesungrape/hmcts/BookAPI/BookServiceTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/codesungrape/hmcts/BookAPI/repository/BookRepository.java
Outdated
Show resolved
Hide resolved
src/main/java/com/codesungrape/hmcts/BookAPI/dto/BookRequest.java
Outdated
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@codesungrape I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you. |
- Use @PrePersist for to set timestamp at persistence time. - Use @Builder.Default for to ensure builder honors the default.
This Pull Request establishes the foundational architecture and implements the core business logic for the POST /books operation within the Service layer, strictly adhering to HMCTS standards. All core logic has been developed using a Test-Driven Development (TDD) approach.
Feature
HMCTS Architectural Compliance
The following HMCTS mandates were enforced in this PR:
Review Focus
Next Steps (Future PRs)
This PR does not include the final API endpoints. The next steps will link this logic to the external contract: