@Test public void testMapRecord() throws Exception { String jsonTweet = "{\"id\":1,\"user\":\"foo\",\"message\":\"Hello\"}"; when(record.getPayload()).thenReturn(jsonTweet); Record<Tweet> actual = mapper.processRecord(record); Tweet tweet = actual.getPayload(); assertThat(actual.getHeader()).isEqualTo(header); assertThat(tweet.getId()).isEqualTo(1); assertThat(tweet.getUser()).isEqualTo("foo"); assertThat(tweet.getMessage()).isEqualTo("Hello"); }
@Override public Record<T> processRecord(final Record<String> record) { return new GenericRecord<>(record.getHeader(), mapper.fromJson(record.getPayload(), type)); }
GsonRecordMapper implements RecordMapper<String, T> { @Override public Record<T> processRecord(final Record<String> record) { return new GenericRecord<>(record.getHeader(), mapper.fromJson(record.getPayload(), type)); } }
GsonRecordMapper implements RecordMapper<String, T> { @Override public Record<T> processRecord(final Record<String> record) { return new GenericRecord<>(record.getHeader(), mapper.fromJson(record.getPayload(), type)); } GsonRecordMapper(Class<T> type);  GsonRecordMapper(final Gson mapper, final Class<T> type); }
GsonRecordMapper implements RecordMapper<String, T> { @Override public Record<T> processRecord(final Record<String> record) { return new GenericRecord<>(record.getHeader(), mapper.fromJson(record.getPayload(), type)); } GsonRecordMapper(Class<T> type);  GsonRecordMapper(final Gson mapper, final Class<T> type); @Override Record<T> processRecord(final Record<String> record); }
GsonRecordMapper implements RecordMapper<String, T> { @Override public Record<T> processRecord(final Record<String> record) { return new GenericRecord<>(record.getHeader(), mapper.fromJson(record.getPayload(), type)); } GsonRecordMapper(Class<T> type);  GsonRecordMapper(final Gson mapper, final Class<T> type); @Override Record<T> processRecord(final Record<String> record);  }