You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The org.approvaltests.JsonJacksonApprovals class should accept ObjectMapper as an optional parameter, similarly to the org.approvaltests.JsonApprovals accepting a Function1<GsonBuilder, GsonBuilder> gsonBuilder.
The main motivation is to have consistent serialization with the rest of the application, allowing to perform pretty-printing without changing the semantics of the output (typically NULL values present vs missing).
I don't think there is any reason to modify the mapper during verification, therefore I find it safe to pass the actual instance instead of some ObjectMapper factory/builder.
Thank you for the tooling! I really appreciate such a zero-config snapshotting functionality :)
The text was updated successfully, but these errors were encountered:
Since Jackson supports ordering of properties and map entries out of the box (ORDER_MAP_ENTRIES_BY_KEYS, SORT_PROPERTIES_ALPHABETICALLY options), allowing to pass an instance of ObjectMapper will make the JsonJacksonApprovals implementation on par with JsonApprovals in terms of features.
A simple solution would is to simply define the ObjectMapper as a public static field in the class. That on each JsonJacksonApprovals.asJson a new ObjectMapper instance is created is wasteful anyway.
The
org.approvaltests.JsonJacksonApprovals
class should acceptObjectMapper
as an optional parameter, similarly to theorg.approvaltests.JsonApprovals
accepting aFunction1<GsonBuilder, GsonBuilder> gsonBuilder
.The main motivation is to have consistent serialization with the rest of the application, allowing to perform pretty-printing without changing the semantics of the output (typically NULL values present vs missing).
I don't think there is any reason to modify the mapper during verification, therefore I find it safe to pass the actual instance instead of some ObjectMapper factory/builder.
Thank you for the tooling! I really appreciate such a zero-config snapshotting functionality :)
The text was updated successfully, but these errors were encountered: