mattyb149 commented on code in PR #10738:
URL: https://github.com/apache/nifi/pull/10738#discussion_r2669288641
##########
nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/TestMapRecord.java:
##########
@@ -333,6 +334,50 @@ void testNestedSchema() {
}
}
+ @Test
+ void testNestedSchemaWithEmptyArray() {
+ final String FOO_TEST_VAL = "test!";
+ final String NESTED_RECORD_VALUE = "Hello, world!";
+
+ final List<RecordField> fields = new ArrayList<>();
+ fields.add(new RecordField("foo",
RecordFieldType.STRING.getDataType(), null, set("bar", "baz")));
+ List<RecordField> nestedFields = new ArrayList<>();
+ nestedFields.add(new RecordField("test",
RecordFieldType.STRING.getDataType()));
+ RecordSchema nestedSchema = new SimpleRecordSchema(nestedFields);
+ RecordDataType nestedType = new RecordDataType(nestedSchema);
+ fields.add(new RecordField("nested", nestedType));
+ fields.add(new RecordField("array", new ArrayDataType(nestedType)));
+ RecordSchema fullSchema = new SimpleRecordSchema(fields);
+
+ Map<String, Object> nestedValues = new HashMap<>();
+ nestedValues.put("test", NESTED_RECORD_VALUE);
+ Record nestedRecord = new MapRecord(nestedSchema, nestedValues);
+ Map<String, Object> values = new HashMap<>();
+ values.put("foo", FOO_TEST_VAL);
+ values.put("nested", nestedRecord);
+
+ values.put("array", new Object[0]);
+
+ Record record = new MapRecord(fullSchema, values);
+
+ Map<String, Object> fullConversion = null;
+ try {
+ fullConversion = ((MapRecord) record).toMap(true);
+ } catch (Exception e) {
+ fail("Nested toMap() failed unexpectedly");
+ }
Review Comment:
Not really, just to make it obvious what used to fail before the fix. Will
move it up to the test
--
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]