diff --git a/avro-builder/tests/codegen-charseq-method/src/main/avro/charseqmethod/TestCollections.avsc b/avro-builder/tests/codegen-charseq-method/src/main/avro/charseqmethod/TestCollections.avsc index 9dcaac88..81933b9e 100644 --- a/avro-builder/tests/codegen-charseq-method/src/main/avro/charseqmethod/TestCollections.avsc +++ b/avro-builder/tests/codegen-charseq-method/src/main/avro/charseqmethod/TestCollections.avsc @@ -79,6 +79,16 @@ "type": "array", "items": "int" } + }, + { + "name": "unionOfIntMap", + "type": [ + "null", + { + "type": "map", + "values": "int" + } + ] } ], "type": "record" diff --git a/avro-builder/tests/codegen-no-utf8-in-putbyindex/src/main/avro/charseqmethod/TestCollections.avsc b/avro-builder/tests/codegen-no-utf8-in-putbyindex/src/main/avro/charseqmethod/TestCollections.avsc index e8b8e730..9e9a56ba 100644 --- a/avro-builder/tests/codegen-no-utf8-in-putbyindex/src/main/avro/charseqmethod/TestCollections.avsc +++ b/avro-builder/tests/codegen-no-utf8-in-putbyindex/src/main/avro/charseqmethod/TestCollections.avsc @@ -79,6 +79,16 @@ "type": "array", "items": "int" } + }, + { + "name": "unionOfIntMap", + "type": [ + "null", + { + "type": "map", + "values": "int" + } + ] } ], "type": "record" diff --git a/avro-builder/tests/tests-allavro/src/test/java/com/linkedin/avroutil1/builder/SpecificRecordTest.java b/avro-builder/tests/tests-allavro/src/test/java/com/linkedin/avroutil1/builder/SpecificRecordTest.java index ff8825b3..43218ff5 100644 --- a/avro-builder/tests/tests-allavro/src/test/java/com/linkedin/avroutil1/builder/SpecificRecordTest.java +++ b/avro-builder/tests/tests-allavro/src/test/java/com/linkedin/avroutil1/builder/SpecificRecordTest.java @@ -1946,6 +1946,46 @@ public void testCharSeqAccessorForNoUtf8() { instance.getIntAr().add(Integer.MAX_VALUE); Assert.assertEquals((int) instance.getIntAr().get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); Assert.assertEquals((int) instance.intAr.get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); + + instance.getIntAr().add(Integer.MAX_VALUE); + Assert.assertEquals((int) instance.getIntAr().get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); + Assert.assertEquals((int) instance.intAr.get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); + } + + @Test + public void testCharSeqAccessorForCharseq() { + String tba = "NewElement"; + RandomRecordGenerator generator = new RandomRecordGenerator(); + charseqmethod.TestCollections instance = generator.randomSpecific(charseqmethod.TestCollections.class, RecordGenerationConfig.newConfig().withAvoidNulls(true)); + + // array of string + instance.getStrAr().add(tba); + Assert.assertTrue(instance.getStrAr().contains(tba)); + Assert.assertTrue(instance.strAr.contains(new Utf8(tba))); + + // union[null, List] + instance.getUnionOfArray().add(tba); + Assert.assertTrue(instance.getUnionOfArray().contains(tba)); + Assert.assertTrue(instance.unionOfArray.contains(new Utf8(tba))); + + // array (union[null, string]) + instance.getArOfUnionOfStr().add(tba); + Assert.assertTrue(instance.getArOfUnionOfStr().contains(tba)); + Assert.assertTrue(instance.arOfUnionOfStr.contains(new Utf8(tba))); + + + // Union (null, Map) + instance.getUnionOfMap().put("key1", tba); + Assert.assertEquals(tba, instance.getUnionOfMap().get("key1")); + Assert.assertEquals(new Utf8(tba), instance.unionOfMap.get(new Utf8("key1"))); + + instance.getIntAr().add(Integer.MAX_VALUE); + Assert.assertEquals((int) instance.getIntAr().get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); + Assert.assertEquals((int) instance.intAr.get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); + + instance.getIntAr().add(Integer.MAX_VALUE); + Assert.assertEquals((int) instance.getIntAr().get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); + Assert.assertEquals((int) instance.intAr.get(instance.getIntAr().size() - 1), Integer.MAX_VALUE); } @BeforeClass