Fixed bug in OrderBySource.

OrderBySource can now take part in nested property resolving as well and correctly resolves properties containing a camel case letter.
This commit is contained in:
Oliver Gierke
2011-01-25 11:53:31 +02:00
parent bd68d421da
commit 312fad40e2
4 changed files with 61 additions and 25 deletions

View File

@@ -40,11 +40,10 @@ public class OrderBySourceUnitTests {
@Test
public void handlesSingleDirectionAndMultiplePropertiesCorrectly()
throws Exception {
public void handlesCamelCasePropertyCorrecty() throws Exception {
assertThat(new OrderBySource("LastnameUsernameDesc").toSort(),
is(new Sort(DESC, "lastname", "username")));
is(new Sort(DESC, "lastnameUsername")));
}
@@ -63,4 +62,25 @@ public class OrderBySourceUnitTests {
new OrderBySource("Desc");
}
@Test
public void usesNestedPropertyCorrectly() throws Exception {
OrderBySource source = new OrderBySource("BarNameDesc", Foo.class);
assertThat(source.toSort(), is(new Sort(new Order(DESC, "bar.name"))));
}
@SuppressWarnings("unused")
private class Foo {
private Bar bar;
}
@SuppressWarnings("unused")
private class Bar {
private String name;
}
}