@Test public void testRecord() throws DataConversionException { Iterable<RecordWithMetadata<JsonNode>> records = converter.convertRecord(null, sampleRecord, state); RecordWithMetadata<JsonNode> node = records.iterator().next(); Assert.assertEquals(node.getMetadata().getGlobalMetadata().getContentType(), "test.name+json"); Assert.assertEquals(node.getRecord().get("field1").getTextValue(), sampleRecord.get("field1").toString()); }
@Override public Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit) throws DataConversionException { try { Iterable<String> innerRecordIterable = innerConverter.convertRecord(outputSchema, inputRecord, workUnit); String record = innerRecordIterable.iterator().next(); JsonNode jsonRoot = objectMapper.readValue(record, JsonNode.class); return Collections.singleton(new RecordWithMetadata<JsonNode>(jsonRoot, defaultMetadata)); } catch (IOException e) { throw new DataConversionException("Error converting to JSON", e); } }
AvroToJsonRecordWithMetadataConverter extends Converter<Schema, String, GenericRecord, RecordWithMetadata<JsonNode>> { @Override public Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit) throws DataConversionException { try { Iterable<String> innerRecordIterable = innerConverter.convertRecord(outputSchema, inputRecord, workUnit); String record = innerRecordIterable.iterator().next(); JsonNode jsonRoot = objectMapper.readValue(record, JsonNode.class); return Collections.singleton(new RecordWithMetadata<JsonNode>(jsonRoot, defaultMetadata)); } catch (IOException e) { throw new DataConversionException("Error converting to JSON", e); } } }
AvroToJsonRecordWithMetadataConverter extends Converter<Schema, String, GenericRecord, RecordWithMetadata<JsonNode>> { @Override public Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit) throws DataConversionException { try { Iterable<String> innerRecordIterable = innerConverter.convertRecord(outputSchema, inputRecord, workUnit); String record = innerRecordIterable.iterator().next(); JsonNode jsonRoot = objectMapper.readValue(record, JsonNode.class); return Collections.singleton(new RecordWithMetadata<JsonNode>(jsonRoot, defaultMetadata)); } catch (IOException e) { throw new DataConversionException("Error converting to JSON", e); } } AvroToJsonRecordWithMetadataConverter(); }
AvroToJsonRecordWithMetadataConverter extends Converter<Schema, String, GenericRecord, RecordWithMetadata<JsonNode>> { @Override public Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit) throws DataConversionException { try { Iterable<String> innerRecordIterable = innerConverter.convertRecord(outputSchema, inputRecord, workUnit); String record = innerRecordIterable.iterator().next(); JsonNode jsonRoot = objectMapper.readValue(record, JsonNode.class); return Collections.singleton(new RecordWithMetadata<JsonNode>(jsonRoot, defaultMetadata)); } catch (IOException e) { throw new DataConversionException("Error converting to JSON", e); } } AvroToJsonRecordWithMetadataConverter(); @Override String convertSchema(final Schema inputSchema, WorkUnitState workUnit); @Override Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord,
      WorkUnitState workUnit); }
AvroToJsonRecordWithMetadataConverter extends Converter<Schema, String, GenericRecord, RecordWithMetadata<JsonNode>> { @Override public Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord, WorkUnitState workUnit) throws DataConversionException { try { Iterable<String> innerRecordIterable = innerConverter.convertRecord(outputSchema, inputRecord, workUnit); String record = innerRecordIterable.iterator().next(); JsonNode jsonRoot = objectMapper.readValue(record, JsonNode.class); return Collections.singleton(new RecordWithMetadata<JsonNode>(jsonRoot, defaultMetadata)); } catch (IOException e) { throw new DataConversionException("Error converting to JSON", e); } } AvroToJsonRecordWithMetadataConverter(); @Override String convertSchema(final Schema inputSchema, WorkUnitState workUnit); @Override Iterable<RecordWithMetadata<JsonNode>> convertRecord(String outputSchema, GenericRecord inputRecord,
      WorkUnitState workUnit);  }