Skip to content

Conversation

@codesungrape
Copy link
Collaborator

This PR implements the "Soft Delete" functionality for the Book resource using a TDD approach. It ensures data is marked as deleted rather than physically removed, supporting audit requirements and data recovery.

Changes:

  • BookService.java: Added deleteBookById method.
    • Logic is idempotent: Subsequent calls return success without triggering DB writes.
    • Added @transactional to ensure atomicity of the read/write operation.
  • BookServiceTest.java: Added comprehensive unit tests covering:
    • Successful soft delete.
    • Resource not found (throws exception).
    • Idempotency (already deleted items do not trigger save).
  • ResourceNotFoundException.java: Created custom exception to decouple business logic failures from framework exceptions.

Technical Decisions:

  • Used Soft Delete (isDeleted flag) to preserve referential integrity.
  • Implemented Strict Idempotency to ensure safe retries from the frontend.

Copilot AI review requested due to automatic review settings November 19, 2025 13:38
Copilot finished reviewing on behalf of codesungrape November 19, 2025 13:41
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 implements idempotent soft delete functionality for the Book resource following TDD principles. The implementation marks books as deleted rather than physically removing them, supporting audit requirements and data recovery needs.

Key Changes:

  • Added deleteBookById method with idempotent behavior ensuring repeated deletions don't trigger unnecessary database writes
  • Comprehensive test coverage including success, not found, and idempotency scenarios
  • Custom ResourceNotFoundException to handle business logic failures distinct from framework exceptions

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/main/java/com/codesungrape/hmcts/bookapi/service/BookService.java Implements soft delete with @Transactional annotation and idempotent logic
src/test/java/com/codesungrape/hmcts/bookapi/BookServiceTest.java Adds unit tests covering successful deletion, not found exception, and idempotency
src/main/java/com/codesungrape/hmcts/bookapi/exception/ResourceNotFoundException.java New custom runtime exception for resource not found scenarios
build.gradle Enhances JaCoCo report output with file path printing
README.md Updates JaCoCo report file path to reflect actual location

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codesungrape codesungrape merged commit 3ccb4f8 into main Nov 19, 2025
1 check passed
@codesungrape codesungrape deleted the Implement-soft-delete-with-TDD branch November 19, 2025 13:55
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