Skip to content

Commit 5eb9ca0

Browse files
Refactor test cases in TestCSBackgroundTask and TestQuery: replace string creation with character array for long values and update list creation to use Arrays.asList for better readability and compatibility.
1 parent 306f031 commit 5eb9ca0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/test/java/com/contentstack/sdk/TestCSBackgroundTask.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.junit.jupiter.api.Test;
44
import java.lang.reflect.Constructor;
5+
import java.util.Arrays;
56
import java.util.HashMap;
67
import java.util.LinkedHashMap;
78

@@ -105,7 +106,10 @@ void testCheckHeaderWithSpecialCharacters() {
105106
void testCheckHeaderWithLongValues() {
106107
CSBackgroundTask task = new CSBackgroundTask();
107108
HashMap<String, Object> headers = new HashMap<>();
108-
String longValue = "a".repeat(1000);
109+
// Create a string with 1000 'a' characters (Java 8 compatible)
110+
char[] chars = new char[1000];
111+
Arrays.fill(chars, 'a');
112+
String longValue = new String(chars);
109113
headers.put("Long-Header", longValue);
110114

111115
assertDoesNotThrow(() -> task.checkHeader(headers));

src/test/java/com/contentstack/sdk/TestQuery.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.jupiter.api.BeforeEach;
66
import org.junit.jupiter.api.Test;
77
import java.util.ArrayList;
8+
import java.util.Arrays;
89
import java.util.LinkedHashMap;
910
import java.util.List;
1011
import static org.junit.jupiter.api.Assertions.*;
@@ -755,8 +756,8 @@ void testSetQueryJsonWithAllFields() throws IllegalAccessException {
755756
q.where("title", "Test");
756757
q.except(new String[]{"field1"});
757758
q.only(new String[]{"field2"});
758-
q.onlyWithReferenceUid(List.of("ref_field"), "reference");
759-
q.exceptWithReferenceUid(List.of("except_field"), "reference2");
759+
q.onlyWithReferenceUid(Arrays.asList("ref_field"), "reference");
760+
q.exceptWithReferenceUid(Arrays.asList("except_field"), "reference2");
760761
q.includeReference("include_ref");
761762

762763
QueryResultsCallBack callback = new QueryResultsCallBack() {

0 commit comments

Comments
 (0)