@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()); }
@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);  }