Skip to content

Commit

Permalink
adding more json IT tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jan 29, 2025
1 parent 65faa90 commit 25b0f90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void test_json_valid() throws IOException {
result,
rows("json nested object"),
rows("json object"),
rows("json nested array"),
rows("json array"),
rows("json scalar string"),
rows("json scalar int"),
Expand Down Expand Up @@ -74,9 +75,13 @@ public void test_cast_json() throws IOException {
result,
rows(
"json nested object",
new JSONObject(Map.of("a", "1", "b", Map.of("c", "3"), "d", List.of(1, 2, 3)))),
new JSONObject(
Map.of("a", "1", "b", Map.of("c", "3"), "d", List.of(Boolean.FALSE, 3)))),
rows("json object", new JSONObject(Map.of("a", "1", "b", "2"))),
rows("json array", new JSONArray(List.of(1, 2, 3, 4))),
rows(
"json nested array",
new JSONArray(List.of(1, 2, 3, Map.of("true", true, "number", 123)))),
rows("json scalar string", "abc"),
rows("json scalar int", 1234),
rows("json scalar float", 12.34f),
Expand All @@ -102,9 +107,13 @@ public void test_json() throws IOException {
result,
rows(
"json nested object",
new JSONObject(Map.of("a", "1", "b", Map.of("c", "3"), "d", List.of(1, 2, 3)))),
new JSONObject(
Map.of("a", "1", "b", Map.of("c", "3"), "d", List.of(Boolean.FALSE, 3)))),
rows("json object", new JSONObject(Map.of("a", "1", "b", "2"))),
rows("json array", new JSONArray(List.of(1, 2, 3, 4))),
rows(
"json nested array",
new JSONArray(List.of(1, 2, 3, Map.of("true", true, "number", 123)))),
rows("json scalar string", "abc"),
rows("json scalar int", 1234),
rows("json scalar float", 12.34),
Expand Down
20 changes: 11 additions & 9 deletions integ-test/src/test/resources/json_test.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{"index":{"_id":"0"}}
{"test_name":"json nested object", "json_string":"{\"a\":\"1\", \"b\": {\"c\": \"3\"}, \"d\": [1, 2, 3]}"}
{"test_name":"json nested object", "json_string":"{\"a\":\"1\", \"b\": {\"c\": \"3\"}, \"d\": [false, 3]}"}
{"index":{"_id":"1"}}
{"test_name":"json object", "json_string":"{\"a\":\"1\",\"b\":\"2\"}"}
{"index":{"_id":"2"}}
{"test_name":"json array", "json_string":"[1, 2, 3, 4]"}
{"index":{"_id":"3"}}
{"test_name":"json scalar string", "json_string":"\"abc\""}
{"test_name":"json nested array", "json_string":"[1, 2, 3, {\"true\": true, \"number\": 123}]"}
{"index":{"_id":"4"}}
{"test_name":"json scalar int", "json_string":"1234"}
{"test_name":"json scalar string", "json_string":"\"abc\""}
{"index":{"_id":"5"}}
{"test_name":"json scalar float", "json_string":"12.34"}
{"test_name":"json scalar int", "json_string":"1234"}
{"index":{"_id":"6"}}
{"test_name":"json scalar double", "json_string":"2.99792458e8"}
{"test_name":"json scalar float", "json_string":"12.34"}
{"index":{"_id":"7"}}
{"test_name":"json scalar boolean true", "json_string":"true"}
{"test_name":"json scalar double", "json_string":"2.99792458e8"}
{"index":{"_id":"8"}}
{"test_name":"json scalar boolean false", "json_string":"false"}
{"test_name":"json scalar boolean true", "json_string":"true"}
{"index":{"_id":"9"}}
{"test_name":"json empty string", "json_string":""}
{"test_name":"json scalar boolean false", "json_string":"false"}
{"index":{"_id":"10"}}
{"test_name":"json invalid object", "json_string":"{\"invalid\":\"json\", \"string\"}"}
{"test_name":"json empty string", "json_string":""}
{"index":{"_id":"11"}}
{"test_name":"json invalid object", "json_string":"{\"invalid\":\"json\", \"string\"}"}
{"index":{"_id":"12"}}
{"test_name":"json null", "json_string":null}

0 comments on commit 25b0f90

Please sign in to comment.