Add variant and branch support in Entry and Query APIs#295
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
|
Coverage Summary
|
There was a problem hiding this comment.
Pull request overview
This PR adds variant and branch support to the Java Delivery SDK’s Entry and Query request builders by introducing new variants(...) overloads that populate request headers, plus new unit/integration tests to validate the behavior.
Changes:
- Add
variants(String)/variants(String[])and branch-scopedvariants(..., branch)overloads onEntryandQueryto setx-cs-variant-uidandbranchheaders. - Add branch-availability detection to test credentials and introduce new integration test suites covering header behavior and real API calls.
- Expand existing unit tests for
Entry/Queryto cover the new variants+branch APIs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/contentstack/sdk/Entry.java | Adds variants + branch overloads that set request headers for entry fetches. |
| src/main/java/com/contentstack/sdk/Query.java | Adds variants + branch overloads that set request headers for query finds. |
| src/test/java/com/contentstack/sdk/Credentials.java | Adds hasBranchSupport() helper used to conditionally skip branch tests. |
| src/test/java/com/contentstack/sdk/TestEntry.java | Adds unit tests for variants-with-branch behavior on Entry. |
| src/test/java/com/contentstack/sdk/TestQuery.java | Adds unit tests for variants-with-branch behavior on Query. |
| src/test/java/com/contentstack/sdk/VariantBranchIT.java | Adds integration tests focused on header correctness and edge cases (some offline). |
| src/test/java/com/contentstack/sdk/VariantBranchApiIT.java | Adds API integration tests validating variant+branch behavior against a real stack. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…anch headers Addresses Copilot review on PR #295: - Guard variants(String) and variants(String[]) against null input - Treat whitespace-only variant/branch as blank via trim().isEmpty() - Join multi-variant header with "," for consistency with other SDK headers Blank input intentionally skips (does not remove) the header: headers are a shared Stack-level map, so remove() would clear the header for sibling Entry/Query objects and the Stack-level default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Introduce support for variants and branches in the Entry and Query APIs, along with integration tests to validate the new functionality. This enhancement allows users to specify variant UIDs and branch names when making requests.