File tree Expand file tree Collapse file tree 3 files changed +28
-29
lines changed
java-snapshot-testing-plugin-jackson
src/main/java/au/com/origin/snapshots/jackson/serializers/v1 Expand file tree Collapse file tree 3 files changed +28
-29
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ dependencies {
2121 testImplementation ' org.assertj:assertj-core:3.11.1'
2222 testImplementation ' org.skyscreamer:jsonassert:1.5.0' // For docs/ reporter example
2323
24- testImplementation ' com.fasterxml.jackson.core:jackson-core:2.11.3 '
25- testImplementation ' com.fasterxml.jackson.core:jackson-databind:2.11.3 '
26- testRuntimeOnly ' com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.3 '
27- testRuntimeOnly ' com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.3 '
24+ testImplementation ' com.fasterxml.jackson.core:jackson-core:2.16.0 '
25+ testImplementation ' com.fasterxml.jackson.core:jackson-databind:2.16.0 '
26+ testRuntimeOnly ' com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.0 '
27+ testRuntimeOnly ' com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.0 '
2828}
2929
3030test { useJUnitPlatform() }
Original file line number Diff line number Diff line change 88import com .fasterxml .jackson .annotation .JsonAutoDetect ;
99import com .fasterxml .jackson .annotation .JsonInclude ;
1010import com .fasterxml .jackson .core .PrettyPrinter ;
11- import com .fasterxml .jackson .core .util .DefaultIndenter ;
12- import com .fasterxml .jackson .core .util .DefaultPrettyPrinter ;
13- import com .fasterxml .jackson .core .util .Separators ;
1411import com .fasterxml .jackson .databind .ObjectMapper ;
1512import com .fasterxml .jackson .databind .SerializationFeature ;
1613import java .util .Arrays ;
1714import java .util .List ;
1815
1916public class JacksonSnapshotSerializer implements SnapshotSerializer {
2017
21- private final PrettyPrinter pp =
22- new DefaultPrettyPrinter ("" ) {
23- {
24- Indenter lfOnlyIndenter = new DefaultIndenter (" " , "\n " );
25- this .indentArraysWith (lfOnlyIndenter );
26- this .indentObjectsWith (lfOnlyIndenter );
27- }
28-
29- // It's a requirement
30- // @see https://github.com/FasterXML/jackson-databind/issues/2203
31- public DefaultPrettyPrinter createInstance () {
32- return new DefaultPrettyPrinter (this );
33- }
34-
35- @ Override
36- public DefaultPrettyPrinter withSeparators (Separators separators ) {
37- this ._separators = separators ;
38- this ._objectFieldValueSeparatorWithSpaces =
39- separators .getObjectFieldValueSeparator () + " " ;
40- return this ;
41- }
42- };
18+ private final PrettyPrinter pp = new SnapshotPrettyPrinter ();
4319 private final ObjectMapper objectMapper =
4420 new ObjectMapper () {
4521 {
Original file line number Diff line number Diff line change 1+ package au .com .origin .snapshots .jackson .serializers .v1 ;
2+
3+ import com .fasterxml .jackson .core .util .DefaultIndenter ;
4+ import com .fasterxml .jackson .core .util .DefaultPrettyPrinter ;
5+
6+ class SnapshotPrettyPrinter extends DefaultPrettyPrinter {
7+
8+ public SnapshotPrettyPrinter () {
9+ super ("" );
10+ Indenter lfOnlyIndenter = new DefaultIndenter (" " , "\n " );
11+ this .indentArraysWith (lfOnlyIndenter );
12+ this .indentObjectsWith (lfOnlyIndenter );
13+
14+ this ._objectFieldValueSeparatorWithSpaces =
15+ this ._separators .getObjectFieldValueSeparator () + " " ;
16+ }
17+
18+ // It's a requirement
19+ // @see https://github.com/FasterXML/jackson-databind/issues/2203
20+ public DefaultPrettyPrinter createInstance () {
21+ return new DefaultPrettyPrinter (this );
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments