Skip to content

Commit 12bbaea

Browse files
committed
feat: update changelog for v1.13.0 and improve variant UID validation
1 parent 0277335 commit 12bbaea

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.13.0
4+
5+
### Jul 27, 2026
6+
7+
- Feature: Branch support in entry variants
8+
39
## v1.12.2
410

511
### Jul 06, 2026

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<artifactId>cms</artifactId>
88
<packaging>jar</packaging>
99
<name>contentstack-management-java</name>
10-
<version>1.12.2</version>
10+
<version>1.13.0</version>
1111
<description>Contentstack Java Management SDK for Content Management API, Contentstack is a headless CMS with an
1212
API-first approach
1313
</description>
@@ -254,7 +254,7 @@
254254
</includes>
255255
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
256256
<!-- Skip during default lifecycle (e.g. publish); run tests locally with: mvn test -DskipTests=false -->
257-
<skipTests>true</skipTests>
257+
<skipTests>true</skipTests>
258258
<testFailureIgnore>true</testFailureIgnore>
259259
</configuration>
260260
</plugin>

src/main/java/com/contentstack/cms/stack/Entry.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private void validateCT() {
7272

7373
private void validateVariantUid(@NotNull String variantUid) {
7474
Objects.requireNonNull(variantUid, ErrorMessages.VARIANT_UID_REQUIRED);
75-
if (variantUid.isEmpty()) {
75+
if (variantUid.trim().isEmpty()) {
7676
throw new IllegalArgumentException(ErrorMessages.VARIANT_UID_REQUIRED);
7777
}
7878
}
@@ -82,7 +82,7 @@ private void validateVariantUid(@NotNull String variantUid) {
8282
* Null or blank {@code branchUid} keeps {@link #headers} as-is (stack / {@link #addBranch(String)} behavior).
8383
*/
8484
private Map<String, Object> variantHeadersWithOptionalBranch(@Nullable String branchUid) {
85-
if (branchUid == null || branchUid.isEmpty()) {
85+
if (branchUid == null || branchUid.trim().isEmpty()) {
8686
return this.headers;
8787
}
8888
HashMap<String, Object> copy = new HashMap<>(this.headers);
@@ -99,6 +99,10 @@ private Map<String, Object> variantHeadersWithOptionalBranch(@Nullable String br
9999
* @return this entry instance for chaining
100100
*/
101101
public Entry addBranch(@NotNull String branchUid) {
102+
Objects.requireNonNull(branchUid, ErrorMessages.BRANCH_UID_REQUIRED);
103+
if (branchUid.trim().isEmpty()) {
104+
throw new IllegalArgumentException(ErrorMessages.BRANCH_UID_REQUIRED);
105+
}
102106
this.headers.put(Util.BRANCH, branchUid);
103107
return this;
104108
}

src/test/java/com/contentstack/cms/TestClient.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@ public class TestClient {
2929

3030
/** Content type UID for entry-variant tests (default {@code blog}). */
3131
public static final String ENTRY_VARIANT_CONTENT_TYPE_UID =
32-
env.get("entryVariantContentTypeUid") != null ? env.get("entryVariantContentTypeUid") : "blog";
32+
isBlank(env.get("entryVariantContentTypeUid")) ? "blog" : env.get("entryVariantContentTypeUid").trim();
3333

3434
/** Stack branch for entry-variant tests (default {@code develop}). */
3535
public static final String ENTRY_VARIANT_BRANCH =
36-
env.get("entryVariantBranch") != null ? env.get("entryVariantBranch") : "develop";
36+
isBlank(env.get("entryVariantBranch")) ? "develop" : env.get("entryVariantBranch").trim();
3737

3838
/** Locale query param for entry-variant tests (default {@code en-us}). */
3939
public static final String ENTRY_VARIANT_LOCALE =
40-
env.get("entryVariantLocale") != null ? env.get("entryVariantLocale") : "en-us";
40+
isBlank(env.get("entryVariantLocale")) ? "en-us" : env.get("entryVariantLocale").trim();
41+
42+
/** {@code true} if {@code value} is null, empty, or whitespace-only. */
43+
private static boolean isBlank(String value) {
44+
return value == null || value.trim().isEmpty();
45+
}
4146

4247
/**
4348
* {@code true} when {@code apiKey} / {@code managementToken} were not loaded from {@code .env} (defaults apply).

0 commit comments

Comments
 (0)