DATACMNS-491 - Add support for configuring null handling hints in Sort.Order.

Null handling hints can now be configured on Order as being either NATIVE (we let the data store decide how to order nulls), NULLS_FIRST or NULLS_LAST.

This is the foundation for custom null-handling in other data store support modules like SD JPA and SD MongoDB.

Original pull request: #79.
This commit is contained in:
Thomas Darimont
2014-04-25 16:02:31 +02:00
committed by Oliver Gierke
parent 248e314486
commit f689b5d5f3
2 changed files with 141 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.NullHandling;
import org.springframework.data.domain.Sort.Order;
/**
@@ -130,4 +131,36 @@ public class SortUnitTests {
assertThat(foo, is(not(fooIgnoreCase)));
assertThat(foo.hashCode(), is(not(fooIgnoreCase.hashCode())));
}
/**
* @see DATACMNS-491
*/
@Test
public void orderWithNullHandlingHintNullsFirst() {
assertThat(new Order("foo").nullsFirst().getNullHandlingHint(), is(NullHandling.NULLS_FIRST));
}
/**
* @see DATACMNS-491
*/
@Test
public void orderWithNullHandlingHintNullsLast() {
assertThat(new Order("foo").nullsFirst().getNullHandlingHint(), is(NullHandling.NULLS_FIRST));
}
/**
* @see DATACMNS-491
*/
@Test
public void orderWithNullHandlingHintNullsNative() {
assertThat(new Order("foo").nullsNative().getNullHandlingHint(), is(NullHandling.NATIVE));
}
/**
* @see DATACMNS-491
*/
@Test
public void orderWithDefaultNullHandlingHint() {
assertThat(new Order("foo").getNullHandlingHint(), is(NullHandling.NATIVE));
}
}