eemario commented on code in PR #1435:
URL: https://github.com/apache/flink-agents/pull/1435#discussion_r4674671131


##########
plan/src/test/java/org/apache/flink/agents/plan/actions/ChatModelActionTest.java:
##########
@@ -59,6 +67,49 @@ void structuredOutputPreservesOriginalBlocks() throws 
Exception {
         
assertFalse(original.getMetadata().containsKey(Agent.STRUCTURED_OUTPUT));
     }
 
+    private static OutputSchema rowSchema() {
+        return new OutputSchema(
+                new RowTypeInfo(
+                        new TypeInformation<?>[] {
+                            BasicTypeInfo.STRING_TYPE_INFO, 
BasicTypeInfo.INT_TYPE_INFO
+                        },
+                        new String[] {"name", "age"}));
+    }
+
+    @Test
+    void rowSchemaOutputFillsEveryField() throws Exception {
+        Row row =
+                (Row)
+                        ChatModelAction.generateStructuredOutput(
+                                
ChatFixtures.response("{\"name\":\"Ada\",\"age\":36}"),
+                                rowSchema());
+        assertEquals("Ada", row.getField("name"));
+        assertEquals(36, row.getField("age"));
+    }
+
+    @Test
+    void rowSchemaOutputKeepsExplicitNull() throws Exception {
+        Row row =
+                (Row)
+                        ChatModelAction.generateStructuredOutput(
+                                
ChatFixtures.response("{\"name\":\"Ada\",\"age\":null}"),
+                                rowSchema());
+        assertNull(row.getField("age"));
+    }
+
+    @Test
+    void rowSchemaOutputRejectsMissingField() {
+        IllegalArgumentException error =
+                assertThrows(
+                        IllegalArgumentException.class,
+                        () ->
+                                
ChatModelAction.generateStructuredOutputWithReport(
+                                        reportingContext(),
+                                        
ChatFixtures.response("{\"name\":\"Ada\"}"),
+                                        rowSchema()));

Review Comment:
   Could we also verify that the missing-field error is reported as 
`MODEL_OUTPUT_PARSE_ERROR`? The test currently checks the exception and its 
message, but not the reporting behavior. We could follow the existing pattern 
in `ChatModelActionRetryTest` by retaining the mock context and verifying the 
`reportExecutionFailed` call.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to