Skip to content

Added feature CRUD automation tests - #170

Open
PAP889 wants to merge 2 commits into
mainfrom
crudFeature
Open

Added feature CRUD automation tests#170
PAP889 wants to merge 2 commits into
mainfrom
crudFeature

Conversation

@PAP889

@PAP889 PAP889 commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added API support for creating, updating, listing, and deleting features.
    • Added API support for mapping features to organizations, including reading, updating, listing, and removing mappings.
  • Tests

    • Added end-to-end coverage for the complete feature and organization-mapping lifecycle.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds feature and organization-feature API endpoint configuration and a chained TestNG integration test covering feature creation, updates, organization mapping operations, listing, and deletion.

Changes

Feature CRUD integration

Layer / File(s) Summary
Endpoint wiring and test data setup
src/main/resources/config/automation.userServiceAPI.properties, src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java, SanitySuiteUserService_API.xml
Feature and organization-feature endpoints are configured, the test suite includes the integration class, and the test initializes authentication, unique feature data, request payloads, and response logging.
Feature lifecycle operations
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java
The test creates, updates, lists, and deletes a feature with response assertions.
Organization-feature mapping lifecycle
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java
The test creates, updates, reads, lists, and deletes an organization-feature mapping using organization and tenant headers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TestFeatureCRUDOperations
  participant UserServiceAPI
  participant OrganizationFeatureAPI
  TestFeatureCRUDOperations->>UserServiceAPI: Create and update feature
  TestFeatureCRUDOperations->>OrganizationFeatureAPI: Create mapping
  TestFeatureCRUDOperations->>OrganizationFeatureAPI: Update, read, list, and delete mapping
  TestFeatureCRUDOperations->>UserServiceAPI: List and delete feature
Loading

Suggested reviewers: infa-rvarahag, subash-cs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: new feature CRUD automation tests were added.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch crudFeature

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/resources/config/automation.userServiceAPI.properties`:
- Line 140: Update the userservice.organization.feature.list.endpoint property
used by testListOrganizationFeatureMappings to point to the organization-feature
list route, ensuring the request does not require a feature code and exercises
the intended list contract.
- Line 141: Update the userservice organization feature delete endpoint
configuration to use the dedicated organization-feature delete URI rather than
the update route. Ensure testDeleteOrganizationFeatureMapping sends DELETE to
the configured deletion endpoint while leaving the update endpoint configuration
unchanged.

In
`@src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java`:
- Around line 55-74: Update TestFeatureCRUDOperations around testCreateFeature
to track whether feature and mapping records were successfully created, then add
an `@AfterClass`(alwaysRun = true) cleanup method that idempotently deletes any
tracked records regardless of dependent test failures. Reuse the existing
deletion APIs, identifiers, authentication, and cleanup conventions, and guard
each deletion so only successfully created records are removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d876328-c860-4552-9ccb-5adf6b2d8877

📥 Commits

Reviewing files that changed from the base of the PR and between 7c218db and 1829ac9.

📒 Files selected for processing (2)
  • src/main/resources/config/automation.userServiceAPI.properties
  • src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java

Comment thread src/main/resources/config/automation.userServiceAPI.properties
Comment thread src/main/resources/config/automation.userServiceAPI.properties

@infa-rvarahag infa-rvarahag left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. suite xml file is missing
  2. DependsOnMoethd needs o recheck [ make sure each test method independently executable]
    example: read List test method no need to depend on any test method.
    delete or update test method should depend on create operation
  3. values are hard coded it will run in SG tenant and cannot run on SL
  4. Code should be runnable on prod as well.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java (2)

97-210: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Serialize the full feature lifecycle.

testListFeatures, testDeleteFeature, and testMapFeatureToOrganization have no dependencies, so the created resource can be deleted or mapped before list checks. Add a dependency chain such as update → list/map → mapping update → mapping read/list → mapping delete → feature delete so the suite cannot execute destructive steps out of order.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java`
around lines 97 - 210, Add TestNG dependencies to serialize the feature
lifecycle: make testListFeatures depend on testUpdateFeature, make
testMapFeatureToOrganization depend on testListFeatures, and preserve the
mapping flow so testUpdateOrganizationFeatureMapping depends on
testMapFeatureToOrganization, mapping reads/lists follow the mapping update, and
testDeleteOrganizationFeatureMapping precedes testDeleteFeature. Update the
`@Test` annotations on these methods without changing their request or assertion
logic.

145-180: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the PATCH actually updates the mapping.

testUpdateOrganizationFeatureMapping() only sends roles through this body and checks unchanged feature_code/feature_name, while testReadOrganizationFeatureMapping() still depends on creation instead of update. Assert the returned roles or another intentionally changed field in the PATCH response, and make the read depend on testUpdateOrganizationFeatureMapping() so it exercises the updated state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java`
around lines 145 - 180, Update testUpdateOrganizationFeatureMapping() to assert
the intentionally changed roles field from the PATCH response, rather than only
unchanged feature_code and feature_name values. Change
testReadOrganizationFeatureMapping() to depend on
testUpdateOrganizationFeatureMapping() so it validates the mapping after the
update.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java`:
- Around line 97-112: Strengthen testListFeatures in
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java:97-112
by parsing the feature-list response collection and asserting it contains the
created featureCode, while retaining the status and body checks. Apply the same
resource-content assertion to the organization-feature list at
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java:183-193,
verifying that collection contains the mapped featureCode.

---

Outside diff comments:
In
`@src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java`:
- Around line 97-210: Add TestNG dependencies to serialize the feature
lifecycle: make testListFeatures depend on testUpdateFeature, make
testMapFeatureToOrganization depend on testListFeatures, and preserve the
mapping flow so testUpdateOrganizationFeatureMapping depends on
testMapFeatureToOrganization, mapping reads/lists follow the mapping update, and
testDeleteOrganizationFeatureMapping precedes testDeleteFeature. Update the
`@Test` annotations on these methods without changing their request or assertion
logic.
- Around line 145-180: Update testUpdateOrganizationFeatureMapping() to assert
the intentionally changed roles field from the PATCH response, rather than only
unchanged feature_code and feature_name values. Change
testReadOrganizationFeatureMapping() to depend on
testUpdateOrganizationFeatureMapping() so it validates the mapping after the
update.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d309bf88-b2b7-4933-be4e-ddabab68ed06

📥 Commits

Reviewing files that changed from the base of the PR and between 1829ac9 and e6971f9.

📒 Files selected for processing (2)
  • SanitySuiteUserService_API.xml
  • src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java

Comment on lines +97 to +112
@Test
public void testListFeatures() {
Response response = given().header("X-auth-token", adminToken)
.header("x-org-code", getFeatureOrgCode())
.header("x-tenant-code", getFeatureTenantCode())
.queryParam("search", "")
.contentType(ContentType.JSON)
.when()
.get(PROP_LIST.getProperty("userservice.feature.list.endpoint"));

printResponse("Feature List", response);

assertEquals(response.getStatusCode(), 200, "Feature List API failed");

assertNotNull(response.getBody(), "Feature List response body should not be null");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files:"
git ls-files | rg 'TestFeatureCRUDOperations\.java|Feature.*test|feature.*api|Feature.*Resource|Feature.*Controller|Feature.*Service' || true

echo
echo "Target file outline/size:"
wc -l src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java
ast-grep outline src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java || true

echo
echo "Target file relevant sections:"
sed -n '1,240p' src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java

echo
echo "Search list endpoints/docs in repo:"
rg -n "feature\\.list|organization\\.feature\\.list|userservice\\\\.feature|featureList|feature-list|feature.*list|Feature.*List" -S .

Repository: ELEVATE-Project/sl-backend-automation

Length of output: 11891


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Remaining target file section for helper body methods and test dependencies:"
sed -n '240,363p' src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java

echo
echo "Dependency graph around list tests:"
grep -nE '`@Test`|dependsOnMethods|testListFeatures|testListOrganizationFeatureMappings|testCreateFeature|testMapFeatureToOrganization' src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java

Repository: ELEVATE-Project/sl-backend-automation

Length of output: 3998


Assert list responses contain the resources created for these tests.

Both list assertions currently stop at 200 + body existence, so empty or unrelated response lists pass. Parse the feature list collection and assert it contains featureCode; parse the organization-feature list collection and assert it contains the mapped featureCode as well.

📍 Affects 1 file
  • src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java#L97-L112 (this comment)
  • src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java#L183-L193
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java`
around lines 97 - 112, Strengthen testListFeatures in
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java:97-112
by parsing the feature-list response collection and asserting it contains the
created featureCode, while retaining the status and body checks. Apply the same
resource-content assertion to the organization-feature list at
src/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java:183-193,
verifying that collection contains the mapped featureCode.

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