@@ -119,6 +119,77 @@ public void testValidateMatchingField() throws IOException {
119
119
.build ();
120
120
config .validateMappings (responseMap , e );
121
121
assertThat (e .validationErrors ().size (), equalTo (0 ));
122
+
123
+
124
+ fieldCaps = mock (FieldCapabilities .class );
125
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
126
+ responseMap .put ("my_field" , Collections .singletonMap ("double" , fieldCaps ));
127
+ config = new MetricConfig .Builder ()
128
+ .setField ("my_field" )
129
+ .setMetrics (Collections .singletonList ("max" ))
130
+ .build ();
131
+ config .validateMappings (responseMap , e );
132
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
133
+
134
+ fieldCaps = mock (FieldCapabilities .class );
135
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
136
+ responseMap .put ("my_field" , Collections .singletonMap ("float" , fieldCaps ));
137
+ config = new MetricConfig .Builder ()
138
+ .setField ("my_field" )
139
+ .setMetrics (Collections .singletonList ("max" ))
140
+ .build ();
141
+ config .validateMappings (responseMap , e );
142
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
143
+
144
+ fieldCaps = mock (FieldCapabilities .class );
145
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
146
+ responseMap .put ("my_field" , Collections .singletonMap ("short" , fieldCaps ));
147
+ config = new MetricConfig .Builder ()
148
+ .setField ("my_field" )
149
+ .setMetrics (Collections .singletonList ("max" ))
150
+ .build ();
151
+ config .validateMappings (responseMap , e );
152
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
153
+
154
+ fieldCaps = mock (FieldCapabilities .class );
155
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
156
+ responseMap .put ("my_field" , Collections .singletonMap ("byte" , fieldCaps ));
157
+ config = new MetricConfig .Builder ()
158
+ .setField ("my_field" )
159
+ .setMetrics (Collections .singletonList ("max" ))
160
+ .build ();
161
+ config .validateMappings (responseMap , e );
162
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
163
+
164
+ fieldCaps = mock (FieldCapabilities .class );
165
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
166
+ responseMap .put ("my_field" , Collections .singletonMap ("half_float" , fieldCaps ));
167
+ config = new MetricConfig .Builder ()
168
+ .setField ("my_field" )
169
+ .setMetrics (Collections .singletonList ("max" ))
170
+ .build ();
171
+ config .validateMappings (responseMap , e );
172
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
173
+
174
+ fieldCaps = mock (FieldCapabilities .class );
175
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
176
+ responseMap .put ("my_field" , Collections .singletonMap ("scaled_float" , fieldCaps ));
177
+ config = new MetricConfig .Builder ()
178
+ .setField ("my_field" )
179
+ .setMetrics (Collections .singletonList ("max" ))
180
+ .build ();
181
+ config .validateMappings (responseMap , e );
182
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
183
+
184
+ fieldCaps = mock (FieldCapabilities .class );
185
+ when (fieldCaps .isAggregatable ()).thenReturn (true );
186
+ responseMap .put ("my_field" , Collections .singletonMap ("integer" , fieldCaps ));
187
+ config = new MetricConfig .Builder ()
188
+ .setField ("my_field" )
189
+ .setMetrics (Collections .singletonList ("max" ))
190
+ .build ();
191
+ config .validateMappings (responseMap , e );
192
+ assertThat (e .validationErrors ().size (), equalTo (0 ));
122
193
}
123
194
124
195
}
0 commit comments