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