|
26 | 26 | import java.util.Set;
|
27 | 27 |
|
28 | 28 | import static org.hamcrest.Matchers.allOf;
|
29 |
| -import static org.hamcrest.Matchers.anEmptyMap; |
30 | 29 | import static org.hamcrest.Matchers.containsString;
|
31 | 30 | import static org.hamcrest.Matchers.empty;
|
32 | 31 | import static org.hamcrest.Matchers.equalTo;
|
@@ -244,39 +243,45 @@ public void testFieldCardinalityLimitsIsNonEmpty() {
|
244 | 243 | }
|
245 | 244 |
|
246 | 245 | public void testGetExplicitlyMappedFields() {
|
247 |
| - assertThat(new Classification("foo").getExplicitlyMappedFields(null, "results"), is(anEmptyMap())); |
248 |
| - assertThat(new Classification("foo").getExplicitlyMappedFields(Collections.emptyMap(), "results"), is(anEmptyMap())); |
| 246 | + assertThat(new Classification("foo").getExplicitlyMappedFields(null, "results"), |
| 247 | + equalTo(Collections.singletonMap("results.feature_importance", MapUtils.featureImportanceMapping()))); |
| 248 | + assertThat(new Classification("foo").getExplicitlyMappedFields(Collections.emptyMap(), "results"), |
| 249 | + equalTo(Collections.singletonMap("results.feature_importance", MapUtils.featureImportanceMapping()))); |
249 | 250 | assertThat(
|
250 | 251 | new Classification("foo").getExplicitlyMappedFields(Collections.singletonMap("foo", "not_a_map"), "results"),
|
251 |
| - is(anEmptyMap())); |
252 |
| - assertThat( |
253 |
| - new Classification("foo").getExplicitlyMappedFields( |
254 |
| - Collections.singletonMap("foo", Collections.singletonMap("bar", "baz")), |
255 |
| - "results"), |
| 252 | + equalTo(Collections.singletonMap("results.feature_importance", MapUtils.featureImportanceMapping()))); |
| 253 | + Map<String, Object> explicitlyMappedFields = new Classification("foo").getExplicitlyMappedFields( |
| 254 | + Collections.singletonMap("foo", Collections.singletonMap("bar", "baz")), |
| 255 | + "results"); |
| 256 | + assertThat(explicitlyMappedFields, |
256 | 257 | allOf(
|
257 | 258 | hasEntry("results.foo_prediction", Collections.singletonMap("bar", "baz")),
|
258 | 259 | hasEntry("results.top_classes.class_name", Collections.singletonMap("bar", "baz"))));
|
259 |
| - assertThat( |
260 |
| - new Classification("foo").getExplicitlyMappedFields( |
261 |
| - new HashMap<>() {{ |
262 |
| - put("foo", new HashMap<>() {{ |
263 |
| - put("type", "alias"); |
264 |
| - put("path", "bar"); |
265 |
| - }}); |
266 |
| - put("bar", Collections.singletonMap("type", "long")); |
267 |
| - }}, |
268 |
| - "results"), |
| 260 | + assertThat(explicitlyMappedFields, hasEntry("results.feature_importance", MapUtils.featureImportanceMapping())); |
| 261 | + |
| 262 | + explicitlyMappedFields = new Classification("foo").getExplicitlyMappedFields( |
| 263 | + new HashMap<>() {{ |
| 264 | + put("foo", new HashMap<>() {{ |
| 265 | + put("type", "alias"); |
| 266 | + put("path", "bar"); |
| 267 | + }}); |
| 268 | + put("bar", Collections.singletonMap("type", "long")); |
| 269 | + }}, |
| 270 | + "results"); |
| 271 | + assertThat(explicitlyMappedFields, |
269 | 272 | allOf(
|
270 | 273 | hasEntry("results.foo_prediction", Collections.singletonMap("type", "long")),
|
271 | 274 | hasEntry("results.top_classes.class_name", Collections.singletonMap("type", "long"))));
|
| 275 | + assertThat(explicitlyMappedFields, hasEntry("results.feature_importance", MapUtils.featureImportanceMapping())); |
| 276 | + |
272 | 277 | assertThat(
|
273 | 278 | new Classification("foo").getExplicitlyMappedFields(
|
274 | 279 | Collections.singletonMap("foo", new HashMap<>() {{
|
275 | 280 | put("type", "alias");
|
276 | 281 | put("path", "missing");
|
277 | 282 | }}),
|
278 | 283 | "results"),
|
279 |
| - is(anEmptyMap())); |
| 284 | + equalTo(Collections.singletonMap("results.feature_importance", MapUtils.featureImportanceMapping()))); |
280 | 285 | }
|
281 | 286 |
|
282 | 287 | public void testToXContent_GivenVersionBeforeRandomizeSeedWasIntroduced() throws IOException {
|
|
0 commit comments