Skip to content

Commit d50c8c7

Browse files
committed
chore: No need for pretty printing when constructing example payloads for ExampleFuzzer
1 parent bcbb7e3 commit d50c8c7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/com/endava/cats/util/JsonUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ public abstract class JsonUtils {
7777
private static final Pattern JSON_SQUARE_BR_KEYS = Pattern.compile("\\w+(\\[(?>[a-zA-Z0-9_*]*[a-zA-Z][a-zA-Z0-9_*]*)])+\\w*");
7878
private static final Pattern EMPTY_SQUARE_BRACKETS = Pattern.compile("\\w+\\[]\\w*");
7979

80+
8081
/**
81-
* To not be used to serialize data ending in console of files. Use the TestCaseExporter serializer for that.
82+
* To not be used to serialize data ending in console or files. Use the TestCaseExporter serializer for that.
8283
*/
8384
public static final Gson GSON = new GsonBuilder()
8485
.setStrictness(Strictness.LENIENT)
@@ -90,6 +91,15 @@ public abstract class JsonUtils {
9091
.serializeNulls()
9192
.create();
9293

94+
public static final Gson GSON_NO_PRETTY_PRINTING = new GsonBuilder()
95+
.setStrictness(Strictness.LENIENT)
96+
.disableHtmlEscaping()
97+
.setExclusionStrategies(new ExcludeTestCaseStrategy())
98+
.registerTypeAdapter(Long.class, new LongTypeSerializer())
99+
.registerTypeAdapter(OffsetDateTime.class, new OffsetDatetimeTypeAdapter())
100+
.serializeNulls()
101+
.create();
102+
93103
public static final Configuration SUPPRESS_EXCEPTIONS_CONFIGURATION = new Configuration.ConfigurationBuilder().options(Option.SUPPRESS_EXCEPTIONS).build();
94104

95105
public static final Configuration GSON_CONFIGURATION = Configuration.builder().jsonProvider(new GsonJsonProvider(GSON)).mappingProvider(new GsonMappingProvider(GSON)).build();

0 commit comments

Comments
 (0)