Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Merge c020d5c into e9fe5c6
Browse files Browse the repository at this point in the history
  • Loading branch information
robindevilliers committed Jul 20, 2018
2 parents e9fe5c6 + c020d5c commit 957748a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.fasterxml.jackson.annotation.JsonCreator.Mode.PROPERTIES;
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_ABSENT;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_WITH_ZONE_ID;
Expand Down Expand Up @@ -55,6 +56,7 @@ private ObjectMapper configureObjectMapper(final ObjectMapper objectMapper) {
.setTimeZone(getTimeZone(UTC))
.setSerializationInclusion(NON_ABSENT)
.enable(WRITE_ENUMS_USING_TO_STRING)
.configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
.enable(READ_ENUMS_USING_TO_STRING);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;
import static uk.gov.justice.services.common.converter.ObjectMapperProducerTest.Colour.BLUE;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import uk.gov.justice.services.common.converter.jackson.ObjectMapperProducer;

import java.util.Collections;
Expand Down Expand Up @@ -77,6 +79,14 @@ public void shouldOmitsNullValuesFromJsonObjects() throws Exception {
assertEquals(JSON_OBJECT_STRING, json, true);
}

@Test
public void shouldTolerateAdditionalPropertiesFromJsonObjects() throws Exception {

final String json = "{\"name\":\"Fred\",\"age\":42,\"favouriteColour\":\"Blue\", \"something\": \"else\"}";

mapper.readValue(json, Person.class);
}

@Test
public void shouldBeAbleToSerializeSingleArgConstructor() throws Exception {

Expand Down Expand Up @@ -300,7 +310,6 @@ public static class PersonWithAdditionalProperties {
private int age;
private Map<String, Object> additionalProperties;


public PersonWithAdditionalProperties(final String name, final int age, final Map<String, Object> additionalProperties) {
this.name = name;
this.age = age;
Expand Down

0 comments on commit 957748a

Please sign in to comment.