pvillard31 commented on code in PR #10914:
URL: https://github.com/apache/nifi/pull/10914#discussion_r2823448577


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertRecord.java:
##########
@@ -569,4 +570,57 @@ public void 
testJSONWithDefinedFieldTypeBytesAndLogicalTypeDecimal() throws Exce
         final MockFlowFile flowFile = 
runner.getFlowFilesForRelationship(ConvertRecord.REL_SUCCESS).getFirst();
         flowFile.assertContentEquals(expectedContent);
     }
+
+    @Test
+    public void testXMLReaderWithNamespacedAttributesAndInferredSchema() 
throws InitializationException {
+        final XMLReader xmlReader = new XMLReader();
+        runner.addControllerService(READER_ID, xmlReader);
+        runner.setProperty(xmlReader, 
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaInferenceUtil.INFER_SCHEMA);
+        runner.setProperty(xmlReader, XMLReader.RECORD_FORMAT, 
XMLReader.RECORD_SINGLE.getValue());
+        runner.setProperty(xmlReader, XMLReader.PARSE_XML_ATTRIBUTES, "true");
+        runner.setProperty(xmlReader, XMLReader.CONTENT_FIELD_NAME, 
"content_value");
+        runner.enableControllerService(xmlReader);
+
+        final JsonRecordSetWriter jsonWriter = new JsonRecordSetWriter();
+        runner.addControllerService(WRITER_ID, jsonWriter);
+        runner.setProperty(jsonWriter, 
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, 
SchemaAccessUtils.INHERIT_RECORD_SCHEMA);
+        runner.enableControllerService(jsonWriter);
+
+        runner.setProperty(ConvertRecord.RECORD_READER, READER_ID);
+        runner.setProperty(ConvertRecord.RECORD_WRITER, WRITER_ID);
+
+        final String xmlWithNamespacedAttributes = """
+                <?xml version='1.0' encoding='UTF-8'?>
+                     <wd:data xmlns:wd="urn:com.wd.report/foo">
+                        <wd:entry>
+                            <wd:something wd:attr1="attr1 content">
+                                <wd:record_with_attr2 wd:attr2="attr2 content 
1">record_with_attr2 content 1</wd:record_with_attr2>
+                                <wd:record_with_attr2 wd:attr2="attr2 content 
2">record_with_attr2 content 2</wd:record_with_attr2>
+                            </wd:something>
+                        </wd:entry>
+                     </wd:data>
+                """;
+        final String xmlWithPlainAttributes = """
+                <?xml version='1.0' encoding='UTF-8'?>
+                <wd:data xmlns:wd="urn:com.wd.report/foo">
+                    <wd:entry>
+                        <wd:something attr1="attr1 content">
+                            <wd:record_with_attr2 attr2="attr2 content 
1">record_with_attr2 content 1</wd:record_with_attr2>
+                            <wd:record_with_attr2 attr2="attr2 content 
2">record_with_attr2 content 2</wd:record_with_attr2>
+                        </wd:something>
+                    </wd:entry>
+                </wd:data>
+                """;
+
+        runner.enqueue(xmlWithNamespacedAttributes);
+        runner.enqueue(xmlWithPlainAttributes);
+        runner.run(2);
+
+        runner.assertAllFlowFilesTransferred(ConvertRecord.REL_SUCCESS, 2);
+        final MockFlowFile firstFlowFile = 
runner.getFlowFilesForRelationship(ConvertRecord.REL_SUCCESS).getFirst();
+        final MockFlowFile secondFlowFile = 
runner.getFlowFilesForRelationship(ConvertRecord.REL_SUCCESS).get(1);
+        assertFalse(firstFlowFile.getContent().contains("null"));
+        assertFalse(secondFlowFile.getContent().contains("null"));
+        assertEquals(firstFlowFile.getContent(), secondFlowFile.getContent());

Review Comment:
   yeah I don't really mind, it's really about being more extensive in what we 
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]

Reply via email to