|
16 | 16 | package org.springframework.data.rest.core.mapping;
|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.*;
|
| 19 | +import static org.mockito.Mockito.*; |
19 | 20 |
|
20 | 21 | import java.util.Arrays;
|
21 | 22 | import java.util.List;
|
|
27 | 28 | import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentEntity;
|
28 | 29 | import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentProperty;
|
29 | 30 | import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext;
|
| 31 | +import org.springframework.data.mapping.PersistentEntity; |
| 32 | +import org.springframework.data.mapping.PersistentProperty; |
30 | 33 | import org.springframework.data.mapping.context.PersistentEntities;
|
31 | 34 | import org.springframework.data.rest.core.Path;
|
32 | 35 | import org.springframework.data.rest.core.annotation.Description;
|
@@ -98,6 +101,20 @@ public void considersAtDescription() {
|
98 | 101 | assertThat(description.getMessage()).isEqualTo("Some description");
|
99 | 102 | }
|
100 | 103 |
|
| 104 | + @Test // #1994 |
| 105 | + public void doesNotConsiderPropertyExportedIfTargetTypeIsNotMapped() { |
| 106 | + |
| 107 | + PersistentEntity<?, ?> entity = mappingContext.getRequiredPersistentEntity(Entity.class); |
| 108 | + PersistentProperty<?> property = entity.getRequiredPersistentProperty("third"); |
| 109 | + |
| 110 | + ResourceMappings mappings = mock(ResourceMappings.class); |
| 111 | + when(mappings.getMetadataFor(property.getType())).thenReturn(null); |
| 112 | + |
| 113 | + ResourceMapping mapping = new PersistentPropertyResourceMapping(property, mappings); |
| 114 | + |
| 115 | + assertThat(mapping.isExported()).isFalse(); |
| 116 | + } |
| 117 | + |
101 | 118 | private ResourceMapping getPropertyMappingFor(Class<?> entity, String propertyName) {
|
102 | 119 |
|
103 | 120 | KeyValuePersistentEntity<?, ?> persistentEntity = mappingContext.getRequiredPersistentEntity(entity);
|
|
0 commit comments