Skip to content

Conversation

@codesungrape
Copy link
Collaborator

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

  • createBook(BookRequest)

HMCTS Architectural Compliance
The following HMCTS mandates were enforced in this PR:

  • TDD Principle: Service methods are covered by dedicated unit tests (BookServiceTest), ensuring robust and testable business logic.
  • Separation of Concerns: Clearly separated application into dto, entity, repository, and service layers.
  • Immutability: BookRequest DTO utilizes Lombok @value for immutable inbound data handling.
  • Naming Consistency: Uses @JsonProperty to correctly map HMCTS-mandated snake_case JSON properties to internal Java camelCase fields.
  • Entity Design: Book entity uses @builder pattern for clean construction and has corrected package imports.

Review Focus

  • Logic: Please verify the createBook implementation in BookService.java, particularly the DTO-to-Entity mapping via the builder.
  • Testing: Review BookServiceTest.java to confirm correct usage of Mockito (when/verify) and assertion coverage for the createBook happy path and the deleteBook 404 exception path.

Next Steps (Future PRs)
This PR does not include the final API endpoints. The next steps will link this logic to the external contract:

  1. Implement BookController (Linking the POST /books request to the service).
  2. Implement Global Exception Handler (Ensuring all exceptions, like 404, return the HMCTS Problem JSON format).

Copy link

Copilot AI left a 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 createBook service 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.

@codesungrape
Copy link
Collaborator Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link

Copilot AI commented Nov 11, 2025

@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.

@codesungrape codesungrape merged commit 8f87c0a into main Nov 12, 2025
@codesungrape codesungrape deleted the Scaffold-core-data-structure-and-rules branch November 12, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants