### Question:
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);  }### Answer:
@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()); }
@Test public void toEntry_GivenPartitionKeyProvider_ShouldUseSpecifiedPartitionKey() throws IOException { String partitionKey = UUID.randomUUID().toString(); JsonPutRecordsRequestEntryTranslator<SampleRecord> translator = new JsonPutRecordsRequestEntryTranslator<>(objectMapperSpy, o -> partitionKey); PutRecordsRequestEntry entry = translator.toEntry(new SampleRecord()); Assert.assertEquals(partitionKey, entry.partitionKey()); }