@@ -119,8 +119,7 @@ void testFromObjectThenString() {
119119
120120 @ Test
121121 void testSchemaObjectThenString () {
122- // Setting schema(Object) then schema(String) sets external schema
123- // Note: SchemaUnion may keep both inline and external, last one set takes precedence
122+ // Setting schema(Object) then schema(String) should clear inline and set external
124123 Map <String , Object > inlineSchema = Map .of ("type" , "object" );
125124 String externalUri = "http://example.com/schema.json" ;
126125 Input input = new InputBuilder ().schema (inlineSchema ).schema (externalUri ).build ();
@@ -134,7 +133,7 @@ void testSchemaObjectThenString() {
134133
135134 @ Test
136135 void testSchemaStringThenObject () {
137- // Setting schema(String) then schema(Object) should replace external with inline
136+ // Setting schema(String) then schema(Object) should clear external and set inline
138137 String externalUri = "http://example.com/schema.json" ;
139138 Map <String , Object > inlineSchema = Map .of ("type" , "object" );
140139 Input input = new InputBuilder ().schema (externalUri ).schema (inlineSchema ).build ();
@@ -255,4 +254,50 @@ void testSchemaOnlyDoesNotRequireSetFromNull() {
255254 // Verify this would not cause "Both object and str are null" validation error
256255 // (in the actual runtime, this input would be validated without errors)
257256 }
257+
258+ @ Test
259+ void testFromNullClearsFrom () {
260+ // Passing null to from() should clear the from field
261+ Input input = new InputBuilder ().from ("$.data" ).from ((String ) null ).build ();
262+
263+ assertNull (input .getFrom (), "From should be cleared when passing null" );
264+ }
265+
266+ @ Test
267+ void testFromObjectNullClearsFrom () {
268+ // Passing null object to from() should clear the from field
269+ Input input = new InputBuilder ().from (Map .of ("key" , "value" )).from ((Object ) null ).build ();
270+
271+ assertNull (input .getFrom (), "From should be cleared when passing null object" );
272+ }
273+
274+ @ Test
275+ void testSchemaNullClearsSchema () {
276+ // Passing null to schema(Object) should clear the schema field
277+ Input input = new InputBuilder ().schema (Map .of ("type" , "object" )).schema ((Object ) null ).build ();
278+
279+ assertNull (input .getSchema (), "Schema should be cleared when passing null" );
280+ }
281+
282+ @ Test
283+ void testSchemaStringNullClearsSchema () {
284+ // Passing null to schema(String) should clear the schema field
285+ Input input =
286+ new InputBuilder ().schema ("http://example.com/schema" ).schema ((String ) null ).build ();
287+
288+ assertNull (input .getSchema (), "Schema should be cleared when passing null string" );
289+ }
290+
291+ @ Test
292+ void testSchemaAsJsonStringNullClearsSchema () {
293+ // Passing null to schemaAsJsonString should clear the schema field
294+ Input input =
295+ new InputBuilder ()
296+ .schemaAsJsonString ("{\" type\" :\" object\" }" )
297+ .schemaAsJsonString (null )
298+ .build ();
299+
300+ assertNull (
301+ input .getSchema (), "Schema should be cleared when passing null to schemaAsJsonString" );
302+ }
258303}
0 commit comments