forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Souvik Bose <souvbose@amazon.com>
- Loading branch information
Showing
6 changed files
with
196 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...org/opensearch/dataprepper/plugins/kinesis/source/processor/KinesisInputOutputRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.kinesis.source.processor; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.opensearch.dataprepper.model.event.Event; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
import software.amazon.kinesis.retrieval.KinesisClientRecord; | ||
|
||
@Builder(setterPrefix = "with") | ||
@Getter | ||
@AllArgsConstructor | ||
public class KinesisInputOutputRecord { | ||
private Record<Event> dataPrepperRecord; | ||
private KinesisClientRecord kinesisClientRecord; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
.../java/org/opensearch/dataprepper/plugins/kinesis/source/KinesisInputOutputRecordTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.kinesis.source; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.opensearch.dataprepper.model.event.Event; | ||
import org.opensearch.dataprepper.model.event.JacksonEvent; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
import org.opensearch.dataprepper.plugins.kinesis.source.converter.MetadataKeyAttributes; | ||
import org.opensearch.dataprepper.plugins.kinesis.source.processor.KinesisInputOutputRecord; | ||
import software.amazon.kinesis.retrieval.KinesisClientRecord; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
public class KinesisInputOutputRecordTest { | ||
|
||
@Test | ||
void builder_defaultCreatesObjectCorrectly() { | ||
|
||
KinesisInputOutputRecord kinesisInputOutputRecord = KinesisInputOutputRecord.builder().build(); | ||
|
||
assertNull(kinesisInputOutputRecord.getKinesisClientRecord()); | ||
assertNull(kinesisInputOutputRecord.getDataPrepperRecord()); | ||
} | ||
|
||
@Test | ||
void builder_createsObjectCorrectly() { | ||
Event event = JacksonEvent.fromMessage(UUID.randomUUID().toString()); | ||
event.getMetadata().setAttribute(MetadataKeyAttributes.KINESIS_STREAM_NAME_METADATA_ATTRIBUTE, UUID.randomUUID().toString()); | ||
Record<Event> record = new Record<>(event); | ||
KinesisClientRecord kinesisClientRecord = KinesisClientRecord.builder() | ||
.data(ByteBuffer.wrap(event.toJsonString().getBytes())) | ||
.sequenceNumber(Integer.toString(1000)).subSequenceNumber(1).build(); | ||
|
||
KinesisInputOutputRecord kinesisInputOutputRecord = KinesisInputOutputRecord.builder() | ||
.withKinesisClientRecord(kinesisClientRecord) | ||
.withDataPrepperRecord(record) | ||
.build(); | ||
|
||
assertNotNull(kinesisInputOutputRecord.getKinesisClientRecord()); | ||
assertNotNull(kinesisInputOutputRecord.getDataPrepperRecord()); | ||
assertEquals(kinesisInputOutputRecord.getDataPrepperRecord(), record); | ||
assertEquals(kinesisInputOutputRecord.getKinesisClientRecord(), kinesisClientRecord); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.