Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonApprovals reorderJson is not compatible with customized GsonBuilder #479

Open
olsavmic opened this issue Mar 9, 2024 · 0 comments
Open

Comments

@olsavmic
Copy link

olsavmic commented Mar 9, 2024

The API (and implementation) of org.approvaltests.JsonApprovals.verifyJson does not provide a variant with reorderJson functionality and gsonBuilder parameter, resulting in unexpected changes of the output - fields are missing due to the default behavior of the GsonBuilder to skip NULL fields.

  public static void verifyJson(String json, boolean reorderJson);

  public static void verifyJson(String json, boolean reorderJson, Options options);

  // no way to configure both reorderJson = true and gsonBuilder

  public static void verifyAsJson(Object o, Function1<GsonBuilder, GsonBuilder> gsonBuilder);

  public static void verifyAsJson(Object o, Function1<GsonBuilder, GsonBuilder> gsonBuilder, Options options);

Btw I think that the API is not going to scale well with these different parameters.
I'd propose to merge the configuration parameters into a combined JsonOptions structure.


Thank you for the tooling! I really appreciate such a zero-config snapshotting functionality :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants