From 0de51eb3f6c163de75cd20b570941467f905bc43 Mon Sep 17 00:00:00 2001 From: weirdo0314 <2019215183@stu.cqupt.edu.cn> Date: Sat, 1 Jun 2024 23:41:11 +0800 Subject: [PATCH] [Java] add JSONTest fro RequiredNullableBody class --- .../src/test/java/org/openapitools/client/JSONTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java index 765e7b71c77a9..ece7f392b31bb 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java @@ -671,4 +671,13 @@ public void testOneOfAnyOfArray() throws Exception { assertTrue(exception.getMessage().contains("java.io.IOException: The JSON string is invalid for")); } } + + @Test + public void testRequiredNullableBody() throws Exception { + final String json1 = "{\"integer_prop\":null,\"number_prop\":null,\"boolean_prop\":null,\"string_prop\":null,\"date_prop\":null,\"datetime_prop\":null,\"array_nullable_prop\":null,\"array_and_items_nullable_prop\":null,\"array_items_nullable\":[],\"object_nullable_prop\":null,\"object_and_items_nullable_prop\":null,\"object_items_nullable\":{},\"custom_ref_enum\":null,\"custom_enum\":null}"; + final RequiredNullableBody body = new RequiredNullableBody(); + + assertEquals("{\"array_items_nullable\":[],\"object_items_nullable\":{}}", json.serialize(body)); + assertEquals(json.deserialize(json1, RequiredNullableBody.class), body); + } }