From 2e2c58683d30955b7c4e3247f00b6b22d21b3380 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Tue, 7 Jan 2025 10:12:57 -0800 Subject: [PATCH] put routing field test back Signed-off-by: Maxwell Brown --- .../sink/opensearch/OpenSearchSinkTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkTest.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkTest.java index 815698a123..59019e0b0a 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkTest.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/OpenSearchSinkTest.java @@ -259,6 +259,21 @@ void doOutput_with_invalid_version_expression_catches_NumberFormatException_and_ verify(dynamicDocumentVersionDroppedEvents).increment(); } + @Test + void test_routing_field_in_document() throws IOException { + String routingFieldKey = UUID.randomUUID().toString(); + String routingKey = UUID.randomUUID().toString(); + String routingFieldValue = UUID.randomUUID().toString(); + when(indexConfiguration.getRoutingField()).thenReturn(routingFieldKey); + when(indexConfiguration.getRouting()).thenReturn(routingKey); + final OpenSearchSink objectUnderTest = createObjectUnderTest(); + final Event event = JacksonEvent.builder() + .withEventType("event") + .withData(Collections.singletonMap(routingFieldKey, routingFieldValue)) + .build(); + assertThat(objectUnderTest.getDocument(event).getRoutingField(), equalTo(Optional.of(routingFieldValue))); + } + @Test void test_routing_in_document() throws IOException { String routingValue = UUID.randomUUID().toString();