Core - Use singleton RESTObjectMapper in REST RequestResponseTestBase class#4636
Conversation
danielcweeks
left a comment
There was a problem hiding this comment.
LGTM (just waiting on checks)
| "A JSON response with the keys spelled incorrectly should fail to deserialize and validate", | ||
| JsonProcessingException.class, | ||
| IllegalArgumentException.class, | ||
| "Invalid namespace: null", |
There was a problem hiding this comment.
Because RESTObjectMapper will ignore unknown fields, the exception thrown in these tests where the keys are misspelled turn out to be more specific.
I've updated them to use the proper thrown exception type, as well as add part of the exception message to help clarify the tests purpose and intent.
| "A JSON response with the keys spelled incorrectly should fail to deserialize and validate", | ||
| JsonProcessingException.class, | ||
| () -> deserialize(jsonMisspelledKeys) | ||
| ); |
There was a problem hiding this comment.
Because the RESTObjectMapper does not fail on unknown keys, this test is no longer valid.
We might consider adding a warning log in the config response's validate method to log if null was received for both (not an explicit empty collection, but null).
In practice, users should be using the config response class and its associated builder, which cannot build an incorrect payload.
…ct mapper is currently permissive - all but one of these cases fail validation anyways
08729fe to
e80c5de
Compare
There is now a global singleton object mapper for the
RESCatalog, which already has the necessary serializers and deserializers registered.The rest / response objects are all tested via the
RequestResponseTestBaseclass, which currently repeats the object mapper instantiation and initialization logic that theRESTObjectMapperis ultimately responsible for.We should be testing the rest objects using the correct object mapper (which should also reduce allocations during testing and other minor advantages).
cc @rdblue @danielcweeks