27
27
28
28
import java .util .Collections ;
29
29
import java .util .HashMap ;
30
+ import java .util .Map ;
30
31
31
32
import static org .hamcrest .Matchers .containsString ;
32
33
import static org .hamcrest .Matchers .equalTo ;
@@ -37,21 +38,34 @@ public void testRemoveFields() throws Exception {
37
38
IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random ());
38
39
String field = RandomDocumentPicks .randomExistingFieldName (random (), ingestDocument );
39
40
Processor processor = new RemoveProcessor (randomAlphaOfLength (10 ),
40
- Collections .singletonList (new TestTemplateService .MockTemplateScript .Factory (field )));
41
+ Collections .singletonList (new TestTemplateService .MockTemplateScript .Factory (field )), false );
41
42
processor .execute (ingestDocument );
42
43
assertThat (ingestDocument .hasField (field ), equalTo (false ));
43
44
}
44
45
45
46
public void testRemoveNonExistingField () throws Exception {
46
47
IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random (), new HashMap <>());
47
48
String fieldName = RandomDocumentPicks .randomFieldName (random ());
48
- Processor processor = new RemoveProcessor (randomAlphaOfLength (10 ),
49
- Collections .singletonList (new TestTemplateService .MockTemplateScript .Factory (fieldName )));
49
+ Map <String , Object > config = new HashMap <>();
50
+ config .put ("field" , fieldName );
51
+ String processorTag = randomAlphaOfLength (10 );
52
+ Processor processor = new RemoveProcessor .Factory (TestTemplateService .instance ()).create (null , processorTag , config );
50
53
try {
51
54
processor .execute (ingestDocument );
52
55
fail ("remove field should have failed" );
53
56
} catch (IllegalArgumentException e ) {
54
57
assertThat (e .getMessage (), containsString ("not present as part of path [" + fieldName + "]" ));
55
58
}
56
59
}
60
+
61
+ public void testIgnoreMissing () throws Exception {
62
+ IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random (), new HashMap <>());
63
+ String fieldName = RandomDocumentPicks .randomFieldName (random ());
64
+ Map <String , Object > config = new HashMap <>();
65
+ config .put ("field" , fieldName );
66
+ config .put ("ignore_missing" , true );
67
+ String processorTag = randomAlphaOfLength (10 );
68
+ Processor processor = new RemoveProcessor .Factory (TestTemplateService .instance ()).create (null , processorTag , config );
69
+ processor .execute (ingestDocument );
70
+ }
57
71
}
0 commit comments