Skip to content

Commit dc647d3

Browse files
committed
Addressed review comments
Signed-off-by: Kondaka <krishkdk@amazon.com>
1 parent c546e20 commit dc647d3

6 files changed

Lines changed: 23 additions & 2 deletions

File tree

data-prepper-plugins/csv-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/csv/CsvProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class CsvProcessor extends AbstractProcessor<Record<Event>, Record<Event>
5252
private final CsvMapper mapper;
5353
private final CsvSchema schema;
5454

55-
private final Boolean normalizeKeys;
55+
private final boolean normalizeKeys;
5656

5757
@DataPrepperPluginConstructor
5858
public CsvProcessor(final PluginMetrics pluginMetrics,

data-prepper-plugins/parse-json-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/parse/json/ParseJsonProcessorConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class ParseJsonProcessorConfig implements CommonParseConfig {
7474

7575
@JsonProperty("normalize_keys")
7676
@JsonPropertyDescription("If specified, replaces invalid characters with underscore character")
77-
private Boolean normalizeKeys;
77+
private Boolean normalizeKeys = false;
7878

7979
@JsonProperty("parse_when")
8080
@JsonPropertyDescription("A <a href=\"https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/\">conditional expression</a> such as <code>/some_key == \"test\"</code>. " +

data-prepper-plugins/parse-json-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/parse/ion/ParseIonProcessorConfigTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void test_when_defaultParseIonProcessorConfig_then_returns_default_values
2828
assertThat(objectUnderTest.getSource(), equalTo(ParseIonProcessorConfig.DEFAULT_SOURCE));
2929
assertThat(objectUnderTest.getDestination(), equalTo(null));
3030
assertThat(objectUnderTest.getPointer(), equalTo(null));
31+
assertThat(objectUnderTest.getNormalizeKeys(), equalTo(false));
3132
assertThat(objectUnderTest.getTagsOnFailure(), equalTo(null));
3233
assertThat(objectUnderTest.getOverwriteIfDestinationExists(), equalTo(true));
3334
assertThat(objectUnderTest.getHandleFailedEventsOption(), equalTo(HandleFailedEventsOption.SKIP));

data-prepper-plugins/parse-json-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/parse/ion/ParseIonProcessorTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import static org.hamcrest.CoreMatchers.equalTo;
2222
import static org.hamcrest.MatcherAssert.assertThat;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
2324
import static org.mockito.Mockito.lenient;
2425
import static org.mockito.Mockito.mock;
2526
import static org.mockito.Mockito.verifyNoInteractions;
@@ -64,6 +65,21 @@ void invalid_parse_when_throws_InvalidPluginConfigurationException() {
6465
assertThrows(InvalidPluginConfigurationException.class, this::createObjectUnderTest);
6566
}
6667

68+
@Test
69+
void test_replace_invalid_key_characters() throws Exception {
70+
final String source = "root_source";
71+
when(processorConfig.getSource()).thenReturn(source);
72+
when(processorConfig.getDestination()).thenReturn(source);
73+
when(processorConfig.getDepth()).thenReturn(0);
74+
parseJsonProcessor = createObjectUnderTest(); // need to recreate so that new config options are used
75+
final String serializedMessage = "{bare Key: 1, sym$bol: SYMBOL, time%stamp: 2023-11-30T21:05:23.383Z, attr^ibute: dollars::100.0 }";
76+
final Event parsedEvent = createAndParseMessageEvent(serializedMessage);
77+
// Currently doesn't support invalid keys replacement
78+
Object rootSourceObject = parsedEvent.get(source, Object.class);
79+
assertTrue(rootSourceObject instanceof String);
80+
81+
}
82+
6783
@Test
6884
void test_when_using_ion_features_then_processorParsesCorrectly() {
6985
parseJsonProcessor = createObjectUnderTest();

data-prepper-plugins/parse-json-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/parse/json/ParseJsonProcessorConfigTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void test_when_defaultParseJsonProcessorConfig_then_returns_default_value
2828
assertThat(objectUnderTest.getSource(), equalTo(ParseJsonProcessorConfig.DEFAULT_SOURCE));
2929
assertThat(objectUnderTest.getDestination(), equalTo(null));
3030
assertThat(objectUnderTest.getPointer(), equalTo(null));
31+
assertThat(objectUnderTest.getNormalizeKeys(), equalTo(false));
3132
assertThat(objectUnderTest.getTagsOnFailure(), equalTo(null));
3233
assertThat(objectUnderTest.getOverwriteIfDestinationExists(), equalTo(true));
3334
assertThat(objectUnderTest.isDeleteSourceRequested(), equalTo(false));
@@ -64,6 +65,8 @@ void test_when_destinationIsWhiteSpaceOrFrontSlash_then_isValidDestinationFalse(
6465

6566
setField(ParseJsonProcessorConfig.class, config, "deleteSource", true);
6667
assertThat(config.isDeleteSourceRequested(), equalTo(true));
68+
setField(ParseJsonProcessorConfig.class, config, "normalizeKeys", true);
69+
assertThat(config.getNormalizeKeys(), equalTo(true));
6770
}
6871

6972
@Test

data-prepper-plugins/parse-json-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/parse/xml/ParseXmlProcessorConfigTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void test_when_defaultParseXmlProcessorConfig_then_returns_default_values
2323
assertThat(objectUnderTest.getSource(), equalTo(ParseXmlProcessorConfig.DEFAULT_SOURCE));
2424
assertThat(objectUnderTest.getDestination(), equalTo(null));
2525
assertThat(objectUnderTest.getPointer(), equalTo(null));
26+
assertThat(objectUnderTest.getNormalizeKeys(), equalTo(false));
2627
assertThat(objectUnderTest.getTagsOnFailure(), equalTo(null));
2728
assertThat(objectUnderTest.getOverwriteIfDestinationExists(), equalTo(true));
2829
assertThat(objectUnderTest.getHandleFailedEventsOption(), equalTo(HandleFailedEventsOption.SKIP));

0 commit comments

Comments
 (0)