feat(core): DELETE entity endpoint#59
Draft
RVANDO12 wants to merge 2 commits into
Draft
Conversation
9acb5b8 to
335308c
Compare
feat(core): add DELETE endpoint - rebase feat(core): add fully delete and cleanup action
335308c to
c45d3c5
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



PR Description
What this PR Provides
. Rule 1 (Optional relationship): If the parent entity points to the deleted entity, and this relationship required: false in its Template, the relationship is simply removed from the parent entity in the database.
. Rule 2 (Mandatory relationship): If the parent entity points to the deleted entity, and the relationship required: true, and it was the only target entity (to_many cardinality: false or array became empty), the deletion prime on relation and the relations was updated after deletion of entity.
Review
The reviewer must double-check these points:
How to Test the DELETE Entity Endpoint
This guide outlines the functional testing strategy for the
DELETE /api/v1/entities/{templateIdentifier}/{entityIdentifier}endpoint based on the integration test suite (EntityControllerTest) and the OpenAPI specification.The primary objective of this test case is to ensure that deleting an entity not only removes the target entity itself but also idempotently cleans up all incoming relations from other parent/source entities, preventing dangling or orphan references in the system.
1. Endpoint Overview
According to the OpenAPI specification, the endpoint details are as follows:
DELETE/api/v1/entities/{templateIdentifier}/{entityIdentifier}@WithMockUser) and a valid CSRF token.204 No Content: Successful deletion or relation cleanup completed.401 Unauthorized: Missing or invalid authentication token.403 Forbidden: Missing CSRF token or insufficient rights.404 Not Found: Entity or template does not exist.500 Internal Server Error: Unexpected server failure (e.g., blank path parameters).2. Test Setup & Prerequisites
To thoroughly validate the deletion workflow and its side effects (cascading relation cleanups), you must establish a multi-entity relational lifecycle model.
Step 1: Ensure an Entity Template Exists
An entity cannot exist without a valid parent schema template.
EntityTemplate(e.g.,web-service) that defines the necessary schema properties and relation definitions.Step 2: Create the Target Entity (The Entity to Delete)
This entity will be the target of the
DELETErequest.POST /api/v1/entities/web-servicerequest.{ "name": "Relation Target Entity", "identifier": "relation-target-entity", "properties": { "applicationName": "catalog-api", "ownerEmail": "owner@example.com", "port": "8080", "environment": "DEV", "version": "1.2.3", "teamName": "platform-team", "baseUrl": "[https://catalog.example.com](https://catalog.example.com)", "protocol": "HTTP", "programmingLanguage": "JAVA" } }201 Created.Step 3: Create the Source Entity with a Multi-Relation Link
To test the cascading relational cleanup, a second entity must be created that declares a dependency or relation pointing to the target entity created in Step 2.
POST /api/v1/entities/web-servicerequest.{ "name": "Relation Source Entity", "identifier": "relation-source-entity", "properties": { "applicationName": "source-api", "ownerEmail": "source@example.com", "port": "9090" }, "relations": [ { "name": "database", "target_entity_identifiers": ["relation-target-entity"] } ] }201 Created.3. Test Execution Workflow
Once the environment state is prepared, execute the deletion process sequentially.
Step 4: Execute the DELETE Request
Perform the destructive action on the target entity identifier while supplying appropriate mock authentication and CSRF protection headers.
DELETE /api/v1/entities/web-service/relation-target-entity4. Verification & Assertions
A successful test must guarantee data consistency across three distinct structural checks:
Step 5: Assert Deletion Success
204 No Content.Step 6: Verify Target Non-Existence (Read-After-Delete)
GET /api/v1/entities/web-service/relation-target-entity.404 Not Foundstatus code, ensuring that the record has been fully removed from active storage.Step 7: Verify Relationship Cleanup on the Source Entity
This is the critical functional boundary validation. The source entity itself must not be deleted, but its internal metadata array mapping the relation to the target entity must be automatically scrubbed.
GET /api/v1/entities/web-service/relation-source-entity.200 OK(the source entity still safely exists).relationsblock must not contain the string"identifier":"relation-target-entity". The database layer must cleanly un-link the reference.Breaking changes
N/A