Skip to content

Commit

Permalink
Adapt to Jackson 2.15 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Apr 25, 2023
1 parent f864d09 commit a56b9c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ void geoJson() throws JsonProcessingException {
var gm = new GeometryFactory();
var polygon = gm.createPolygon(
new Coordinate[] {
new Coordinate(0, 0),
new Coordinate(1, 1),
new Coordinate(2, 2),
new Coordinate(0, 0),
new Coordinate(0.0, 0.0),
new Coordinate(1.0, 1.0),
new Coordinate(2.0, 2.0),
new Coordinate(0.0, 0.0),
}
);
var geoJson = LegacyGraphQLScalars.geoJsonScalar.getCoercing().serialize(polygon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import au.com.origin.snapshots.serializers.SerializerType;
import au.com.origin.snapshots.serializers.SnapshotSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultIndenter;
Expand Down Expand Up @@ -37,6 +37,7 @@
import org.opentripplanner.TestOtpModel;
import org.opentripplanner.TestServerContext;
import org.opentripplanner.api.mapping.ItineraryMapper;
import org.opentripplanner.api.model.ApiLeg;
import org.opentripplanner.api.parameter.ApiRequestMode;
import org.opentripplanner.api.parameter.QualifiedMode;
import org.opentripplanner.api.parameter.Qualifier;
Expand Down Expand Up @@ -373,15 +374,7 @@ private SnapshotItinerarySerializer() {
objectMapper.registerModule(new JavaTimeModule());
objectMapper.registerModule(new Jdk8Module());

objectMapper.setVisibility(
objectMapper
.getSerializationConfig()
.getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE)
);
objectMapper.addMixIn(ApiLeg.class, ApiLegMixin.class);

pp =
new DefaultPrettyPrinter("") {
Expand Down Expand Up @@ -418,4 +411,14 @@ public String getOutputFormat() {
return SerializerType.JSON.name();
}
}

/**
* To exclude {@link ApiLeg#getDuration()} from being deserialized because the returned number
* is non-constant making it impossible to assert.
*/
private abstract static class ApiLegMixin {

@JsonIgnore
abstract double getDuration();
}
}

0 comments on commit a56b9c2

Please sign in to comment.