Skip to content

Commit a1e29b0

Browse files
Run tests in non-strict JSON mode, like real applications (#942) (#944)
Co-authored-by: Sylvain Wallez <[email protected]>
1 parent 8942194 commit a1e29b0

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

java-client/src/test/java/co/elastic/clients/json/JsonpMappingExceptionTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testLookAhead() {
9898
// Unknown field 'baz' (JSON path: properties['foo-bar'].baz) (...line no=1, column no=36, offset=35)
9999

100100
JsonpMappingException e = assertThrows(JsonpMappingException.class, () -> {
101-
fromJson(json, TypeMapping.class);
101+
fromJson(json, TypeMapping.class, SimpleJsonpMapper.INSTANCE_REJECT_UNKNOWN_FIELDS);
102102
});
103103

104104
// Check escaping of non identifier path elements and path from map elements

java-client/src/test/java/co/elastic/clients/testkit/ModelTestCase.java

+3-13
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,15 @@ private static JsonpMapper createMapper(JsonImpl jsonImpl, int rand) {
5858
switch(jsonImpl) {
5959
case Jsonb:
6060
System.out.println("Using a JsonB mapper (rand = " + rand + ").");
61-
return new JsonbJsonpMapper() {
62-
@Override
63-
public boolean ignoreUnknownFields() {
64-
return false;
65-
}
66-
};
61+
return new JsonbJsonpMapper();
6762

6863
case Jackson:
6964
System.out.println("Using a Jackson mapper (rand = " + rand + ").");
70-
return new JacksonJsonpMapper() {
71-
@Override
72-
public boolean ignoreUnknownFields() {
73-
return false;
74-
}
75-
};
65+
return new JacksonJsonpMapper();
7666

7767
default:
7868
System.out.println("Using a simple mapper (rand = " + rand + ").");
79-
return SimpleJsonpMapper.INSTANCE_REJECT_UNKNOWN_FIELDS;
69+
return SimpleJsonpMapper.INSTANCE;
8070
}
8171
}
8272

0 commit comments

Comments
 (0)