You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/04/01 12:14:34 UTC

[GitHub] [nifi] simonbence commented on a change in pull request #5896: NIFI-9832: Fix disappearing XML element content when the element has attribute

simonbence commented on a change in pull request #5896:
URL: https://github.com/apache/nifi/pull/5896#discussion_r840520628



##########
File path: nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/xml/XMLRecordReader.java
##########
@@ -487,6 +491,12 @@ private Record parseRecord(StartElement startElement, RecordSchema schema, boole
                     Object value = parseStringForType(content.toString(), contentFieldName, field.get().getDataType());
                     recordValues.put(contentFieldName, value);
                 }
+            } else if (valueElement != null) {

Review comment:
       I would suggest to extract the code or add an in line comment. Later this could be confusing

##########
File path: nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/resources/xml/person_record.xml
##########
@@ -0,0 +1,5 @@
+<record>

Review comment:
       Please add this file to the RAT exclusions

##########
File path: nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/xml/TestXMLReader.java
##########
@@ -31,80 +33,99 @@
 import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import static junit.framework.TestCase.assertEquals;
 
 public class TestXMLReader {
 
-    private XMLReader reader;
-
     private final String ATTRIBUTE_PREFIX = "attribute_prefix";
     private final String CONTENT_NAME = "content_field";
     private final String EVALUATE_IS_ARRAY = "xml.stream.is.array";
 
-    public TestRunner setup(String filePath) throws InitializationException, IOException {
-
+    private TestRunner setup(Map<PropertyDescriptor, String> xmlReaderProperties) throws InitializationException {
         TestRunner runner = TestRunners.newTestRunner(TestXMLReaderProcessor.class);
-        reader = new XMLReader();
+        XMLReader reader = new XMLReader();
+
         runner.addControllerService("xml_reader", reader);
         runner.setProperty(TestXMLReaderProcessor.XML_READER, "xml_reader");
 
-        final String outputSchemaText = new String(Files.readAllBytes(Paths.get(filePath)));
-        runner.setProperty(reader, SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
-        runner.setProperty(reader, SchemaAccessUtils.SCHEMA_TEXT, outputSchemaText);
+        for (Map.Entry<PropertyDescriptor, String> entry : xmlReaderProperties.entrySet()) {
+            runner.setProperty(reader, entry.getKey(), entry.getValue());
+        }
 
+        runner.enableControllerService(reader);
         return runner;
     }
 
     @Test
-    public void testRecordFormat() throws IOException, InitializationException {
-        TestRunner runner = setup("src/test/resources/xml/testschema");
-
-        runner.setProperty(reader, XMLReader.RECORD_FORMAT, XMLReader.RECORD_EVALUATE);
-
-        runner.enableControllerService(reader);
-
+    public void testRecordFormatDeterminedBasedOnAttribute() throws IOException, InitializationException {
+        // GIVEN

Review comment:
       Currently the given/when/then separation is not part of the convention




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org