Skip to content

Commit 6d6c7f1

Browse files
committed
Add a missing test case
1 parent 2584600 commit 6d6c7f1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/SetProcessorFactoryTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void testCreate() throws Exception {
4141
assertThat(setProcessor.getField().newInstance(Map.of()).execute(), equalTo("field1"));
4242
assertThat(setProcessor.getValue().copyAndResolve(Map.of()), equalTo("value1"));
4343
assertThat(setProcessor.isOverrideEnabled(), equalTo(true));
44+
assertThat(setProcessor.isIgnoreEmptyValue(), equalTo(false));
4445
}
4546

4647
public void testCreateWithOverride() throws Exception {
@@ -57,6 +58,20 @@ public void testCreateWithOverride() throws Exception {
5758
assertThat(setProcessor.isOverrideEnabled(), equalTo(overrideEnabled));
5859
}
5960

61+
public void testCreateWithIgnoreEmptyValue() throws Exception {
62+
boolean ignoreEmptyValueEnabled = randomBoolean();
63+
Map<String, Object> config = new HashMap<>();
64+
config.put("field", "field1");
65+
config.put("value", "value1");
66+
config.put("ignore_empty_value", ignoreEmptyValueEnabled);
67+
String processorTag = randomAlphaOfLength(10);
68+
SetProcessor setProcessor = factory.create(null, processorTag, null, config);
69+
assertThat(setProcessor.getTag(), equalTo(processorTag));
70+
assertThat(setProcessor.getField().newInstance(Map.of()).execute(), equalTo("field1"));
71+
assertThat(setProcessor.getValue().copyAndResolve(Map.of()), equalTo("value1"));
72+
assertThat(setProcessor.isIgnoreEmptyValue(), equalTo(ignoreEmptyValueEnabled));
73+
}
74+
6075
public void testCreateNoFieldPresent() throws Exception {
6176
Map<String, Object> config = new HashMap<>();
6277
config.put("value", "value1");

0 commit comments

Comments
 (0)