diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/MappedPropertiesUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/MappedPropertiesUnitTests.java index 6d20a72f9..be4e00a9c 100644 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/MappedPropertiesUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/MappedPropertiesUnitTests.java @@ -25,6 +25,7 @@ import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingCon import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty.Access; import com.fasterxml.jackson.databind.ObjectMapper; /** @@ -68,11 +69,19 @@ public class MappedPropertiesUnitTests { assertThat(properties.getMappedName(entity.getPersistentProperty("emailAddress")), is("email")); } + @Test // DATAREST-1006 + public void doesNotExposeIgnoredPropertyViaJsonProperty() { + + assertThat(properties.hasPersistentPropertyForField("readOnlyProperty")).isFalse(); + assertThat(properties.getPersistentProperty("readOnlyProperty")).isNull(); + } + static class Sample { public @Transient String notExposedBySpringData; public @JsonIgnore String notExposedByJackson; public String exposedProperty; public @JsonProperty("email") String emailAddress; + public @JsonProperty(access = Access.READ_ONLY) String readOnlyProperty; } }