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 2020/03/12 19:10:08 UTC

[GitHub] [nifi] tpalfy commented on a change in pull request #4139: NIFI-7249: Force String keys in maps in DataTypeUtils.inferDataType()

tpalfy commented on a change in pull request #4139: NIFI-7249: Force String keys in maps in DataTypeUtils.inferDataType()
URL: https://github.com/apache/nifi/pull/4139#discussion_r391830893
 
 

 ##########
 File path: nifi-commons/nifi-record/src/test/java/org/apache/nifi/serialization/record/TestDataTypeUtils.java
 ##########
 @@ -442,6 +442,14 @@ private void testChooseDataType(List<DataType> dataTypes, Object value, DataType
         assertEquals(expected, actual);
     }
 
+    @Test
 
 Review comment:
   Can we also please add a test to `TestAvroTypeUtil`:
   ```java
       @Test
       public void testConvertAvroMap() {
          // GIVEN
           Map<?, ?> expected = new HashMap<String, Object>() {{
               put(
                   "nullableMapField",
                   new HashMap<String, Object>() {{
                       put("key1", "value1");
                       put("key2", "value2");
                   }}
               );
           }};
   
           Schema nullableMapFieldAvroSchema = Schema.createUnion(
               Schema.create(Type.NULL),
               Schema.create(Type.INT),
               Schema.createMap(Schema.create(Type.STRING))
           );
   
           Schema avroRecordSchema = Schema.createRecord(
               "record", "doc", "namespace", false,
               Arrays.asList(
                   new Field("nullableMapField", nullableMapFieldAvroSchema, "nullable map field", (Object)null)
               )
           );
   
           Map<?, ?> value = new HashMap<Utf8, Object>(){{
               put(new Utf8("key1"), "value1");
               put(new Utf8("key2"), "value2");
           }};
   
           Record avroRecord = new GenericRecordBuilder(avroRecordSchema)
               .set("nullableMapField", value)
               .build();
   
           RecordSchema nifiRecordSchema = new SimpleRecordSchema(
               Arrays.asList(
                   new RecordField("nullableMapField", RecordFieldType.CHOICE.getChoiceDataType(
                       RecordFieldType.MAP.getMapDataType(RecordFieldType.STRING.getDataType())
                   ))
               )
           );
   
           // WHEN
           Object actual = AvroTypeUtil.convertAvroRecordToMap(avroRecord, nifiRecordSchema);
   
           // THEN
           assertEquals(expected, actual);
       }
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services