DATAREST-518 - MappingResourceMetadata is now not exported by default.
This commit is contained in:
@@ -31,6 +31,8 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||
import org.springframework.data.rest.core.annotation.RestResource;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MappingResourceMetadata}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -38,17 +40,19 @@ public class MappingResourceMetadataUnitTests {
|
||||
|
||||
MongoMappingContext context = new MongoMappingContext();
|
||||
|
||||
MongoPersistentEntity<?> entity = context.getPersistentEntity(Entity.class);
|
||||
ResourceMappings resourceMappings = new PersistentEntitiesResourceMappings(new PersistentEntities(
|
||||
Arrays.asList(context)));
|
||||
MappingResourceMetadata metadata = new MappingResourceMetadata(entity, resourceMappings).init();
|
||||
|
||||
/**
|
||||
* @see DATAREST-514
|
||||
*/
|
||||
@Test
|
||||
public void allowsLookupOfPropertyByMappedName() {
|
||||
|
||||
ResourceMappings resourceMappings = new PersistentEntitiesResourceMappings(new PersistentEntities(
|
||||
Arrays.asList(context)));
|
||||
|
||||
MongoPersistentEntity<?> entity = context.getPersistentEntity(Entity.class);
|
||||
MongoPersistentProperty property = entity.getPersistentProperty("related");
|
||||
|
||||
MappingResourceMetadata metadata = new MappingResourceMetadata(entity, resourceMappings).init();
|
||||
|
||||
PropertyAwareResourceMapping propertyMapping = metadata.getProperty("foo");
|
||||
|
||||
assertThat(propertyMapping, is(notNullValue()));
|
||||
@@ -56,10 +60,31 @@ public class MappingResourceMetadataUnitTests {
|
||||
assertThat(metadata.getMappingFor(property).getPath().matches("foo"), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-518
|
||||
*/
|
||||
@Test
|
||||
public void isNotExportedByDefault() {
|
||||
|
||||
assertThat(metadata.isExported(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-518
|
||||
*/
|
||||
@Test
|
||||
public void isExportedIfExplicitlyAnnotated() {
|
||||
|
||||
MappingResourceMetadata metadata = new MappingResourceMetadata(context.getPersistentEntity(Related.class),
|
||||
resourceMappings).init();
|
||||
assertThat(metadata.isExported(), is(true));
|
||||
}
|
||||
|
||||
static class Entity {
|
||||
@DBRef @RestResource(rel = "foo", path = "foo") private Related related;
|
||||
}
|
||||
|
||||
@RestResource
|
||||
static class Related {
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
assertThat(mapping, is(notNullValue()));
|
||||
assertThat(mapping.getPath(), is(new Path("first")));
|
||||
assertThat(mapping.getRel(), is("first"));
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,6 +85,9 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-233
|
||||
*/
|
||||
@Test
|
||||
public void returnsDefaultDescriptionKey() {
|
||||
|
||||
@@ -97,7 +100,7 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-???
|
||||
* @see DATAREST-233
|
||||
*/
|
||||
@Test
|
||||
public void considersAtDescription() {
|
||||
|
||||
Reference in New Issue
Block a user