ijokarumawak commented on issue #3478: NIFI-6304 added trim, toLowerCase and 
toUpperCase to record path oper…
URL: https://github.com/apache/nifi/pull/3478#issuecomment-494622338
 
 
   To explain why we need to return multiple converted FieldValues stream with 
`trim`, `toUpperCase` or `toLowerCase`, I suggest adding following test case:
   
   ```java
       @Test
       public void testTrimArray() {
           final List<RecordField> fields = new ArrayList<>();
           final DataType dataType = new 
ArrayDataType(RecordFieldType.STRING.getDataType());
           fields.add(new RecordField("names", dataType));
   
           final RecordSchema schema = new SimpleRecordSchema(fields);
   
           final Map<String, Object> values = new HashMap<>();
           values.put("names", new String[]{"   John Smith     ", "   Jane 
Smith     "});
           final Record record = new MapRecord(schema, values);
   
           final List<FieldValue> results = 
RecordPath.compile("trim(/names[*])").evaluate(record).getSelectedFields().collect(Collectors.toList());
           assertEquals("John Smith", results.get(0).getValue());
           assertEquals("Jane Smith", results.get(1).getValue());
       }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to