Skip to content

Commit 91541fb

Browse files
committed
iter
1 parent 8dafc10 commit 91541fb

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

test/framework/src/main/java/org/elasticsearch/index/mapper/BlockLoaderTestRunner.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,28 @@ public void runTest(MapperService mapperService, Map<String, Object> document, O
4747
var documentXContent = XContentBuilder.builder(XContentType.JSON.xContent()).map(document);
4848

4949
Object blockLoaderResult = setupAndInvokeBlockLoader(mapperService, documentXContent, blockLoaderFieldName);
50-
expected = makeReadable(expected);
51-
blockLoaderResult = makeReadable(blockLoaderResult);
50+
expected = attemptMakeReadable(expected);
51+
blockLoaderResult = attemptMakeReadable(blockLoaderResult);
5252
Assert.assertEquals(expected, blockLoaderResult);
5353
}
5454

55-
// Makes assertions readable:
56-
private static Object makeReadable(Object expected) {
57-
if (expected instanceof BytesRef bytesRef) {
58-
expected = bytesRef.utf8ToString();
59-
} else if (expected instanceof List<?> list && list.getFirst() instanceof BytesRef) {
60-
List<String> expectedList = new ArrayList<>(list.size());
61-
for (Object e : list) {
62-
expectedList.add(((BytesRef) e).utf8ToString());
55+
// Attempt to make assertions readable:
56+
private static Object attemptMakeReadable(Object expected) {
57+
try {
58+
if (expected instanceof BytesRef bytesRef) {
59+
expected = bytesRef.utf8ToString();
60+
} else if (expected instanceof List<?> list && list.getFirst() instanceof BytesRef) {
61+
List<String> expectedList = new ArrayList<>(list.size());
62+
for (Object e : list) {
63+
expectedList.add(((BytesRef) e).utf8ToString());
64+
}
65+
expected = expectedList;
6366
}
64-
expected = expectedList;
67+
return expected;
68+
} catch (Exception | AssertionError e) {
69+
// ip/geo fields can't be converted to strings:
70+
return expected;
6571
}
66-
return expected;
6772
}
6873

6974
private Object setupAndInvokeBlockLoader(MapperService mapperService, XContentBuilder document, String fieldName) throws IOException {

0 commit comments

Comments
 (0)