DATACMNS-1284 - Polishing.

Backport of 06116b7.

Related ticket: DATACMNS-1206.
Original commit: 06116b7.
This commit is contained in:
Mark Paluch
2018-04-03 10:39:37 +02:00
committed by Oliver Gierke
parent 428b0decd5
commit 999d26436b
2 changed files with 26 additions and 2 deletions

View File

@@ -122,7 +122,14 @@ class DefaultProjectionInformation implements ProjectionInformation {
final Map<String, Integer> orders = getMethodOrder(metadata);
for (PropertyDescriptor descriptor : filterDefaultMethods(BeanUtils.getPropertyDescriptors(type))) {
if (metadata == null || orders.containsKey(descriptor.getReadMethod().getName())) {
Method readMethod = descriptor.getReadMethod();
if (readMethod == null) {
continue;
}
if (metadata == null || orders.containsKey(readMethod.getName())) {
result.add(descriptor);
}
}
@@ -237,6 +244,6 @@ class DefaultProjectionInformation implements ProjectionInformation {
Method method = descriptor.getReadMethod();
return method == null ? false : ReflectionUtils.isDefaultMethod(method);
return method != null && ReflectionUtils.isDefaultMethod(method);
}
}

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;
/**
* Unit tests for {@link DefaultProjectionInformation}.
@@ -40,6 +41,14 @@ public class DefaultProjectionInformationUnitTests {
assertThat(toNames(information.getInputProperties()), contains("firstname", "lastname"));
}
@Test // DATACMNS-1206, DATACMNS-1284
public void omitsInputPropertiesAcceptingArguments() {
ProjectionInformation information = new DefaultProjectionInformation(ProjectionAcceptingArguments.class);
assertThat(toNames(information.getInputProperties()), contains("lastname"));
}
@Test // DATACMNS-89
public void discoversAllInputProperties() {
@@ -83,6 +92,14 @@ public class DefaultProjectionInformationUnitTests {
String getLastname();
}
interface ProjectionAcceptingArguments {
@Value("foo")
String getFirstname(int i);
String getLastname();
}
interface ExtendedProjection extends CustomerProjection {
int getAge();