> street = wrappedProperties.getPersistentProperties("pre-street-post");
+
+ PersistentProperty> oneLevelNestingProperty = persistentEntity.getPersistentProperty("unwrapped");
+ PersistentProperty> addressProperty = persistentEntities.getPersistentEntity(OneLevelNesting.class)
+ .getPersistentProperty("address");
+ PersistentProperty> streetProperty = persistentEntities.getPersistentEntity(Address.class)
+ .getPersistentProperty("street");
+
+ assertThat(street, contains(oneLevelNestingProperty, addressProperty, streetProperty));
+ }
+
+ /**
+ * @see DATAREST-910
+ */
+ @Test
+ public void wrappedPropertiesShouldConsiderJacksonFieldNames() {
+
+ PersistentEntity, ?> persistentEntity = persistentEntities.getPersistentEntity(MultiLevelNesting.class);
+ WrappedProperties wrappedProperties = WrappedProperties.fromJacksonProperties(persistentEntities, persistentEntity,
+ new ObjectMapper());
+
+ assertThat(wrappedProperties.hasPersistentPropertiesForField("pre-zip-post"), is(true));
+ }
+
+ /**
+ * @see DATAREST-910
+ */
+ @Test
+ public void wrappedPropertiesShouldIgnoreIgnoredJacksonFields() {
+
+ PersistentEntity, ?> persistentEntity = persistentEntities.getPersistentEntity(MultiLevelNesting.class);
+ WrappedProperties wrappedProperties = WrappedProperties.fromJacksonProperties(persistentEntities, persistentEntity,
+ new ObjectMapper());
+
+ assertThat(wrappedProperties.hasPersistentPropertiesForField("pre-street-ignored"), is(false));
+ }
+
+ /**
+ * @see DATAREST-910
+ */
+ @Test
+ public void wrappedPropertiesShouldIgnoreSyntheticProperties() {
+
+ PersistentEntity, ?> persistentEntity = persistentEntities.getPersistentEntity(SyntheticProperties.class);
+ WrappedProperties wrappedProperties = WrappedProperties.fromJacksonProperties(persistentEntities, persistentEntity,
+ new ObjectMapper());
+
+ assertThat(wrappedProperties.hasPersistentPropertiesForField("street"), is(false));
+ }
+
+ @Data
+ @AllArgsConstructor
+ @NoArgsConstructor
+ static class OneLevelNesting {
+
+ String one;
+ @JsonUnwrapped Address address;
+ }
+
+ static class SyntheticProperties {
+
+ @JsonUnwrapped
+ Address getUnwrapped() {
+ return null;
+ }
+
+ MultiLevelNesting getSynthetic() {
+ return null;
+ }
+
+ @JsonUnwrapped
+ void setWrapped(OneLevelNesting address) {}
+ }
+
+ /**
+ *
+ *
+ {
+ "multi": "multi",
+ "pre-one-post": "one",
+ "pre-street-post": "street",
+ "pre-zip-post": "zip",
+ "nested": {
+ "one": "one",
+ "street": "street",
+ "zip": "zip"
+ }
+ }
+
+ *
+ */
+ @Data
+ @AllArgsConstructor
+ @NoArgsConstructor
+ static class MultiLevelNesting {
+
+ String multi;
+ @JsonUnwrapped(prefix = "pre-", suffix = "-post") OneLevelNesting unwrapped;
+ @JsonIgnore @JsonUnwrapped(prefix = "pre-", suffix = "-ignored") OneLevelNesting ignored;
+ @JsonUnwrapped(enabled = false) OneLevelNesting nested;
+ }
+
+ @Data
+ @AllArgsConstructor
+ @NoArgsConstructor
+ static class Address {
+
+ String street;
+ @JsonProperty("zip") String zipCode;
+ }
+}
diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/util/UriUtilsUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/util/UriUtilsUnitTests.java
new file mode 100644
index 000000000..aba5fd072
--- /dev/null
+++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/util/UriUtilsUnitTests.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.data.rest.webmvc.util;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.junit.Test;
+import org.springframework.util.ClassUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Unit tests for {@link UriUtils}.
+ *
+ * @author Mark Paluch
+ */
+public class UriUtilsUnitTests {
+
+ /**
+ * @see DATAREST-910
+ */
+ @Test
+ public void pathSegmentsShouldDiscoverPathUsingMethodMapping() throws Exception {
+
+ Method method = ClassUtils.getMethod(MappedMethod.class, "method");
+ List pathSegments = UriUtils.getPathSegments(method);
+
+ assertThat(pathSegments, hasItems("hello", "world"));
+ }
+
+ /**
+ * @see DATAREST-910
+ */
+ @Test
+ public void pathSegmentsShouldDiscoverPathUsingTypeAndMethodMapping() throws Exception {
+
+ Method method = ClassUtils.getMethod(MappedClassAndMethod.class, "method");
+ List pathSegments = UriUtils.getPathSegments(method);
+
+ assertThat(pathSegments, hasItems("hello", "world"));
+ }
+
+ static class MappedMethod {
+
+ @RequestMapping("hello/world")
+ public void method() {}
+ }
+
+ @RequestMapping("hello")
+ static class MappedClassAndMethod {
+
+ @RequestMapping("world")
+ public void method() {}
+ }
+}