Source:
public void testJsonConverterNestedObjectConcreteType() throws Exception { NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName()); ObjectMapper objectMapper = new ObjectMapper(); RecordRef recordRef1 = new RecordRef(); recordRef1.setInternalId("12345"); recordRef1.setName("R&D"); ObjectNode recordRefNode1 = JsonNodeFactory.instance.objectNode(); recordRefNode1.set("name", JsonNodeFactory.instance.textNode("R&D")); recordRefNode1.set("internalId", JsonNodeFactory.instance.textNode("12345")); recordRefNode1.set("externalId", JsonNodeFactory.instance.nullNode()); recordRefNode1.set("type", JsonNodeFactory.instance.nullNode()); String recordRefJson1 = objectMapper.writer().writeValueAsString(recordRef1); FieldDesc fieldDesc = typeDesc.getField("department"); AvroConverter<RecordRef, String> converter1 = (AvroConverter<RecordRef, String>) transducer.getValueConverter(fieldDesc); String testRecordRefJson1 = converter1.convertToAvro(recordRef1); assertNotNull(testRecordRefJson1); JsonNode testRecordRefNode1 = objectMapper.reader().readTree(testRecordRefJson1); assertTrue(testRecordRefNode1.has("name")); assertTrue(testRecordRefNode1.has("internalId")); assertTrue(testRecordRefNode1.has("externalId")); assertTrue(testRecordRefNode1.has("type")); Assert.assertEquals(recordRef1.getName(), testRecordRefNode1.get("name").asText()); Assert.assertEquals(recordRef1.getInternalId(), testRecordRefNode1.get("internalId").asText()); Assert.assertEquals(recordRef1.getExternalId(), testRecordRefNode1.get("externalId").asText(null)); assertNull(testRecordRefNode1.get("type").asText(null)); RecordRef testRecordRef1 = converter1.convertToDatum(recordRefJson1); assertNotNull(testRecordRef1); Assert.assertEquals(recordRef1.getName(), testRecordRef1.getName()); Assert.assertEquals(recordRef1.getInternalId(), testRecordRef1.getInternalId()); Assert.assertEquals(recordRef1.getExternalId(), testRecordRef1.getExternalId()); Assert.assertEquals(recordRef1.getType(), testRecordRef1.getType()); }

Target:
public void testJsonConverterNestedObjectConcreteType() throws Exception { NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName()); ObjectMapper objectMapper = new ObjectMapper(); RecordRef recordRef1 = new RecordRef(); recordRef1.setInternalId("12345"); recordRef1.setName("R&D"); ObjectNode recordRefNode1 = JsonNodeFactory.instance.objectNode(); recordRefNode1.set("name", JsonNodeFactory.instance.textNode("R&D")); recordRefNode1.set("internalId", JsonNodeFactory.instance.textNode("12345")); recordRefNode1.set("externalId", JsonNodeFactory.instance.nullNode()); recordRefNode1.set("type", JsonNodeFactory.instance.nullNode()); String recordRefJson1 = objectMapper.writer().writeValueAsString(recordRef1); FieldDesc fieldDesc = typeDesc.getField("department"); AvroConverter<RecordRef, String> converter1 = (AvroConverter<RecordRef, String>) transducer.getValueConverter(fieldDesc); String testRecordRefJson1 = converter1.convertToAvro(recordRef1); assertNotNull(testRecordRefJson1); JsonNode testRecordRefNode1 = objectMapper.reader().readTree(testRecordRefJson1); assertTrue(testRecordRefNode1.has("name")); assertTrue(testRecordRefNode1.has("internalId")); assertTrue(testRecordRefNode1.has("externalId")); assertTrue(testRecordRefNode1.has("type")); assertEquals(recordRef1.getName(), testRecordRefNode1.get("name").asText()); assertEquals(recordRef1.getInternalId(), testRecordRefNode1.get("internalId").asText()); assertEquals(recordRef1.getExternalId(), testRecordRefNode1.get("externalId").asText(null)); assertNull(testRecordRefNode1.get("type").asText(null)); RecordRef testRecordRef1 = converter1.convertToDatum(recordRefJson1); assertNotNull(testRecordRef1); assertEquals(recordRef1.getName(), testRecordRef1.getName()); assertEquals(recordRef1.getInternalId(), testRecordRef1.getInternalId()); assertEquals(recordRef1.getExternalId(), testRecordRef1.getExternalId()); assertEquals(recordRef1.getType(), testRecordRef1.getType()); }