Added feature CRUD automation tests - #170
Conversation
📝 WalkthroughWalkthroughAdds feature and organization-feature API endpoint configuration and a chained TestNG integration test covering feature creation, updates, organization mapping operations, listing, and deletion. ChangesFeature CRUD integration
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/main/resources/config/automation.userServiceAPI.propertiessrc/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java
infa-rvarahag
left a comment
There was a problem hiding this comment.
- suite xml file is missing
- 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 - values are hard coded it will run in SG tenant and cannot run on SL
- Code should be runnable on prod as well.
There was a problem hiding this comment.
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 winSerialize the full feature lifecycle.
testListFeatures,testDeleteFeature, andtestMapFeatureToOrganizationhave 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 winAssert the PATCH actually updates the mapping.
testUpdateOrganizationFeatureMapping()only sendsrolesthrough this body and checks unchangedfeature_code/feature_name, whiletestReadOrganizationFeatureMapping()still depends on creation instead of update. Assert the returnedrolesor another intentionally changed field in the PATCH response, and make the read depend ontestUpdateOrganizationFeatureMapping()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
📒 Files selected for processing (2)
SanitySuiteUserService_API.xmlsrc/test/java/org/shikshalokam/backend/userservice/TestFeatureCRUDOperations.java
| @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"); | ||
| } |
There was a problem hiding this comment.
🎯 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.javaRepository: 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.
Summary by CodeRabbit
New Features
Tests