@Test public void toEntry_GivenSampleRecord_ShouldDelegateSerializationToObjectMapper() throws IOException { JsonPutRecordsRequestEntryTranslator<SampleRecord> translator = new JsonPutRecordsRequestEntryTranslator<>(objectMapperSpy, o -> "key"); SampleRecord item = new SampleRecord(); PutRecordsRequestEntry entry = translator.toEntry(item); Mockito.verify(objectMapperSpy).writeValueAsBytes(item); Assert.assertEquals("{\"id\":\"" + item.id + "\"}", entry.data().asUtf8String()); }
@Override public PutRecordsRequestEntry toEntry(T item) throws IOException { return PutRecordsRequestEntry.builder() .partitionKey(partitionKeyProvider.apply(item)) .data(SdkBytes.fromByteArray(mapper.writeValueAsBytes(item))) .build(); }
JsonPutRecordsRequestEntryTranslator extends AbstractPutRecordsRequestTranslator<T> { @Override public PutRecordsRequestEntry toEntry(T item) throws IOException { return PutRecordsRequestEntry.builder() .partitionKey(partitionKeyProvider.apply(item)) .data(SdkBytes.fromByteArray(mapper.writeValueAsBytes(item))) .build(); } }
JsonPutRecordsRequestEntryTranslator extends AbstractPutRecordsRequestTranslator<T> { @Override public PutRecordsRequestEntry toEntry(T item) throws IOException { return PutRecordsRequestEntry.builder() .partitionKey(partitionKeyProvider.apply(item)) .data(SdkBytes.fromByteArray(mapper.writeValueAsBytes(item))) .build(); } JsonPutRecordsRequestEntryTranslator(ObjectMapper objectMapper, Function<T, String> partitionKeyProvider); }
JsonPutRecordsRequestEntryTranslator extends AbstractPutRecordsRequestTranslator<T> { @Override public PutRecordsRequestEntry toEntry(T item) throws IOException { return PutRecordsRequestEntry.builder() .partitionKey(partitionKeyProvider.apply(item)) .data(SdkBytes.fromByteArray(mapper.writeValueAsBytes(item))) .build(); } JsonPutRecordsRequestEntryTranslator(ObjectMapper objectMapper, Function<T, String> partitionKeyProvider); @Override PutRecordsRequestEntry toEntry(T item); }
JsonPutRecordsRequestEntryTranslator extends AbstractPutRecordsRequestTranslator<T> { @Override public PutRecordsRequestEntry toEntry(T item) throws IOException { return PutRecordsRequestEntry.builder() .partitionKey(partitionKeyProvider.apply(item)) .data(SdkBytes.fromByteArray(mapper.writeValueAsBytes(item))) .build(); } JsonPutRecordsRequestEntryTranslator(ObjectMapper objectMapper, Function<T, String> partitionKeyProvider); @Override PutRecordsRequestEntry toEntry(T item);  }