Consider nested property paths containing a number.

PropertyPath now considers nested property paths (userLastname2 -> user.lastname2) that contain or end with a number.

Closes #2472
This commit is contained in:
Mark Paluch
2021-10-19 14:30:06 +02:00
parent 96ad5d7fb0
commit 7c1886201c
3 changed files with 35 additions and 4 deletions

View File

@@ -218,6 +218,20 @@ public class PropertyPathUnitTests {
.isThrownBy(() -> from("PropertyThatWillFail4Sure", Foo.class));
}
@Test // GH-2472
public void acceptsValidPathWithDigits() {
assertThat(from("bar1", Sample.class)).isNotNull();
assertThat(from("bar1foo", Sample.class)).isNotNull();
}
@Test // GH-2472
public void acceptsValidNestedPathWithDigits() {
assertThat(from("sample.bar1", SampleHolder.class)).isNotNull();
assertThat(from("sample.bar1foo", SampleHolder.class)).isNotNull();
assertThat(from("sampleBar1", SampleHolder.class)).isNotNull();
assertThat(from("sampleBar1foo", SampleHolder.class)).isNotNull();
}
@Test
public void rejectsInvalidProperty() {
@@ -353,7 +367,7 @@ public class PropertyPathUnitTests {
}
@Test // DATACMNS-1199
public void rejectsNonExistantNestedPath() {
public void rejectsNonExistentNestedPath() {
assertThatExceptionOfType(PropertyReferenceException.class) //
.isThrownBy(() -> from("user", Bar.class).nested("nonexistant")) //
@@ -419,6 +433,13 @@ public class PropertyPathUnitTests {
private String userName;
private FooBar user;
private Bar bar;
private Bar bar1;
private Bar bar1foo;
}
private class SampleHolder {
private Sample sample;
}
private class Sample2 {

View File

@@ -425,6 +425,11 @@ class PartTreeUnitTests {
assertThat(tree.isDistinct()).isTrue();
}
@Test // GH-2472
void resolvesPropertyPathsWithNumbers() {
assertThat(new PartTree("findByUserLastname2", UserHolder.class)).isNotNull();
}
@Test // DATAJPA-324
void resolvesPropertyPathFromGettersOnInterfaces() {
assertThat(new PartTree("findByCategoryId", Product.class)).isNotNull();
@@ -735,9 +740,14 @@ class PartTreeUnitTests {
return result;
}
class UserHolder {
User user;
}
class User {
String firstname;
String lastname;
String lastname2;
double[] location;
boolean active;
Date birthday;