DATAREST-250 - Fixed exposure of inline properties.
Fixed PersistentEntityResource serialization to correctly export associations that are not backed by an exported repository.
This commit is contained in:
@@ -190,10 +190,7 @@ public class PersistentEntityJackson2Module extends SimpleModule {
|
||||
public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {
|
||||
|
||||
PersistentProperty<?> property = association.getInverse();
|
||||
|
||||
if (maybeAddAssociationLink(builder, mappings, property, links)) {
|
||||
return;
|
||||
}
|
||||
maybeAddAssociationLink(builder, mappings, property, links);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -250,23 +247,12 @@ public class PersistentEntityJackson2Module extends SimpleModule {
|
||||
|
||||
PersistentProperty<?> persistentProperty = entity.getPersistentProperty(writer.getName());
|
||||
|
||||
if (persistentProperty.isAssociation()) {
|
||||
|
||||
if (!resourceMetadata.isManagedResource(persistentProperty)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mappings.getMappingFor(persistentProperty.getActualType()).isExported()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ResourceMapping propertyMapping = resourceMetadata.getMappingFor(persistentProperty);
|
||||
|
||||
if (!propertyMapping.isExported()) {
|
||||
continue;
|
||||
}
|
||||
// Skip exported associations
|
||||
if (persistentProperty.isAssociation() && resourceMetadata.isExported(persistentProperty)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip ids unless explicitly configured to expose
|
||||
if (persistentProperty.isIdProperty() && !configuration.isIdExposedFor(entity.getType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -259,6 +259,11 @@ public abstract class AbstractWebIntegrationTests {
|
||||
Object jsonPathResult = JsonPath.read(response.getContentAsString(), path);
|
||||
assertThat(jsonPathResult, is(notNullValue()));
|
||||
|
||||
if (jsonPathResult instanceof JSONArray) {
|
||||
JSONArray array = (JSONArray) jsonPathResult;
|
||||
assertThat(array, hasSize(greaterThan(0)));
|
||||
}
|
||||
|
||||
return (T) jsonPathResult;
|
||||
}
|
||||
|
||||
@@ -267,8 +272,7 @@ public abstract class AbstractWebIntegrationTests {
|
||||
try {
|
||||
JsonPath.read(response.getContentAsString(), path);
|
||||
fail(path + " should have failed");
|
||||
} catch (InvalidPathException e) {
|
||||
}
|
||||
} catch (InvalidPathException e) {}
|
||||
}
|
||||
|
||||
protected String assertJsonPathEquals(String path, String expected, MockHttpServletResponse response)
|
||||
|
||||
@@ -21,6 +21,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.rest.webmvc.jpa.JpaWebTests;
|
||||
|
||||
/**
|
||||
* Test helper methods.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class TestUtils {
|
||||
|
||||
Reference in New Issue
Block a user