DATACMNS-967 - Getters that are default methods are not considered projection input properties anymore.
We now exclude getter methods that are default methods from the consideration which properties of a projection interface are considered input properties in the first place. Some additional Java 8 polish in DefaultProjectionInformation.
This commit is contained in:
@@ -19,8 +19,8 @@ import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -53,15 +53,23 @@ public class DefaultProjectionInformationUnitTests {
|
||||
assertThat(toNames(information.getInputProperties()), hasItems("age", "firstname", "lastname"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-967
|
||||
*/
|
||||
@Test
|
||||
public void doesNotConsiderDefaultMethodInputProperties() throws Exception {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(WithDefaultMethod.class);
|
||||
|
||||
assertThat(information.isClosed(), is(true));
|
||||
assertThat(toNames(information.getInputProperties()), hasItems("firstname"));
|
||||
}
|
||||
|
||||
private static List<String> toNames(List<PropertyDescriptor> descriptors) {
|
||||
|
||||
List<String> names = new ArrayList<String>(descriptors.size());
|
||||
|
||||
for (PropertyDescriptor descriptor : descriptors) {
|
||||
names.add(descriptor.getName());
|
||||
}
|
||||
|
||||
return names;
|
||||
return descriptors.stream()//
|
||||
.map(it -> it.getName())//
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
interface CustomerProjection {
|
||||
@@ -75,4 +83,13 @@ public class DefaultProjectionInformationUnitTests {
|
||||
|
||||
int getAge();
|
||||
}
|
||||
|
||||
interface WithDefaultMethod {
|
||||
|
||||
String getFirstname();
|
||||
|
||||
default String getLastname() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user