From d50c8c72c4bff215f39350f3480b134e293e6b77 Mon Sep 17 00:00:00 2001 From: Madalin Ilie Date: Mon, 23 Sep 2024 20:26:17 +0300 Subject: [PATCH] chore: No need for pretty printing when constructing example payloads for ExampleFuzzer --- src/main/java/com/endava/cats/util/JsonUtils.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/endava/cats/util/JsonUtils.java b/src/main/java/com/endava/cats/util/JsonUtils.java index 24583e6d0..3cd8c4f96 100644 --- a/src/main/java/com/endava/cats/util/JsonUtils.java +++ b/src/main/java/com/endava/cats/util/JsonUtils.java @@ -77,8 +77,9 @@ public abstract class JsonUtils { private static final Pattern JSON_SQUARE_BR_KEYS = Pattern.compile("\\w+(\\[(?>[a-zA-Z0-9_*]*[a-zA-Z][a-zA-Z0-9_*]*)])+\\w*"); private static final Pattern EMPTY_SQUARE_BRACKETS = Pattern.compile("\\w+\\[]\\w*"); + /** - * To not be used to serialize data ending in console of files. Use the TestCaseExporter serializer for that. + * To not be used to serialize data ending in console or files. Use the TestCaseExporter serializer for that. */ public static final Gson GSON = new GsonBuilder() .setStrictness(Strictness.LENIENT) @@ -90,6 +91,15 @@ public abstract class JsonUtils { .serializeNulls() .create(); + public static final Gson GSON_NO_PRETTY_PRINTING = new GsonBuilder() + .setStrictness(Strictness.LENIENT) + .disableHtmlEscaping() + .setExclusionStrategies(new ExcludeTestCaseStrategy()) + .registerTypeAdapter(Long.class, new LongTypeSerializer()) + .registerTypeAdapter(OffsetDateTime.class, new OffsetDatetimeTypeAdapter()) + .serializeNulls() + .create(); + public static final Configuration SUPPRESS_EXCEPTIONS_CONFIGURATION = new Configuration.ConfigurationBuilder().options(Option.SUPPRESS_EXCEPTIONS).build(); public static final Configuration GSON_CONFIGURATION = Configuration.builder().jsonProvider(new GsonJsonProvider(GSON)).mappingProvider(new GsonMappingProvider(GSON)).build();