Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Gray <tylgry@amazon.com>
  • Loading branch information
graytaylor0 committed Jun 27, 2023
1 parent 235fb01 commit 510e8cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion data-prepper-plugins/opensearch-source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,3 @@ The default behavior is to process all indices.
#### <a name="index_configuration">Index Configuration</a>

* `index_name_regex`: A regex pattern to represent the index names for filtering

Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,25 @@ void test_tags_when_json_parse_fails() {
assertTrue(parsedEvent.getMetadata().hasTags(testTags));
}

@Test
void when_evaluate_conditional_throws_RuntimeException_events_are_not_dropped() {
final String source = "different_source";
final String destination = "destination_key";
when(processorConfig.getSource()).thenReturn(source);
when(processorConfig.getDestination()).thenReturn(destination);
final String whenCondition = UUID.randomUUID().toString();
when(processorConfig.getParseWhen()).thenReturn(whenCondition);
final Map<String, Object> data = Collections.singletonMap("key", "value");
final String serializedMessage = convertMapToJSONString(data);
final Record<Event> testEvent = createMessageEvent(serializedMessage);
when(expressionEvaluator.evaluateConditional(whenCondition, testEvent.getData())).thenThrow(RuntimeException.class);
parseJsonProcessor = createObjectUnderTest();

final Event parsedEvent = createAndParseMessageEvent(testEvent);

assertThat(parsedEvent.toMap(), equalTo(testEvent.getData().toMap()));
}

private String constructDeeplyNestedJsonPointer(final int numberOfLayers) {
String pointer = "/" + DEEPLY_NESTED_KEY_NAME;
for (int layer = 0; layer < numberOfLayers; layer++) {
Expand Down

0 comments on commit 510e8cf

Please sign in to comment.