@@ -83,6 +83,26 @@ public void testConvertIntList() throws Exception {
8383 assertThat (ingestDocument .getFieldValue (fieldName , List .class ), equalTo (expectedList ));
8484 }
8585
86+ public void testConvertIntFromDouble () throws Exception {
87+ IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random ());
88+ double tenMillion = 1e7 ;
89+ String fieldName = RandomDocumentPicks .addRandomField (random (), ingestDocument , tenMillion );
90+
91+ Processor processor = new ConvertProcessor (randomAlphaOfLength (10 ), null , fieldName , fieldName , Type .INTEGER , false );
92+ processor .execute (ingestDocument );
93+ assertThat (ingestDocument .getFieldValue (fieldName , Integer .class ), equalTo ((int ) tenMillion ));
94+ }
95+
96+ public void testConvertIntFromFloat () throws Exception {
97+ IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random ());
98+ float tenMillion = (float ) 1e7 ;
99+ String fieldName = RandomDocumentPicks .addRandomField (random (), ingestDocument , tenMillion );
100+
101+ Processor processor = new ConvertProcessor (randomAlphaOfLength (10 ), null , fieldName , fieldName , Type .INTEGER , false );
102+ processor .execute (ingestDocument );
103+ assertThat (ingestDocument .getFieldValue (fieldName , Integer .class ), equalTo ((int ) tenMillion ));
104+ }
105+
86106 public void testConvertIntError () throws Exception {
87107 IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random (), new HashMap <>());
88108 String fieldName = RandomDocumentPicks .randomFieldName (random ());
@@ -153,6 +173,26 @@ public void testConvertLongList() throws Exception {
153173 assertThat (ingestDocument .getFieldValue (fieldName , List .class ), equalTo (expectedList ));
154174 }
155175
176+ public void testConvertLongFromDouble () throws Exception {
177+ IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random ());
178+ double billion = 1e9 ;
179+ String fieldName = RandomDocumentPicks .addRandomField (random (), ingestDocument , billion );
180+
181+ Processor processor = new ConvertProcessor (randomAlphaOfLength (10 ), null , fieldName , fieldName , Type .LONG , false );
182+ processor .execute (ingestDocument );
183+ assertThat (ingestDocument .getFieldValue (fieldName , Long .class ), equalTo ((long ) billion ));
184+ }
185+
186+ public void testConvertLongFromFloat () throws Exception {
187+ IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random ());
188+ float tenMillion = (float ) 1e7 ;
189+ String fieldName = RandomDocumentPicks .addRandomField (random (), ingestDocument , tenMillion );
190+
191+ Processor processor = new ConvertProcessor (randomAlphaOfLength (10 ), null , fieldName , fieldName , Type .LONG , false );
192+ processor .execute (ingestDocument );
193+ assertThat (ingestDocument .getFieldValue (fieldName , Long .class ), equalTo ((long ) tenMillion ));
194+ }
195+
156196 public void testConvertLongError () throws Exception {
157197 IngestDocument ingestDocument = RandomDocumentPicks .randomIngestDocument (random (), new HashMap <>());
158198 String fieldName = RandomDocumentPicks .randomFieldName (random ());
0 commit comments