DATACMNS-867 - Moved to new factory methods for Sort.
Codebase now uses Sort.by(…) where possible instead of the deprecated new Sort(…).
This commit is contained in:
@@ -43,7 +43,7 @@ public class PageRequestUnitTests extends AbstractPageRequestUnitTests {
|
||||
@Test
|
||||
public void equalsRegardsSortCorrectly() {
|
||||
|
||||
Sort sort = new Sort(Direction.DESC, "foo");
|
||||
Sort sort = Sort.by(Direction.DESC, "foo");
|
||||
AbstractPageRequest request = PageRequest.of(0, 10, sort);
|
||||
|
||||
// Equals itself
|
||||
|
||||
@@ -38,9 +38,7 @@ public class SortUnitTests {
|
||||
*/
|
||||
@Test
|
||||
public void appliesDefaultForOrder() throws Exception {
|
||||
|
||||
assertThat(Sort.by("foo").iterator().next().getDirection()).isEqualTo(Sort.DEFAULT_DIRECTION);
|
||||
assertThat(new Sort((Direction) null, "foo").iterator().next().getDirection()).isEqualTo(Sort.DEFAULT_DIRECTION);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +49,7 @@ public class SortUnitTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void preventsNullProperties() throws Exception {
|
||||
|
||||
new Sort(Direction.ASC, (String[]) null);
|
||||
Sort.by(Direction.ASC, (String[]) null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +60,7 @@ public class SortUnitTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void preventsNullProperty() throws Exception {
|
||||
|
||||
new Sort(Direction.ASC, (String) null);
|
||||
Sort.by(Direction.ASC, (String) null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +71,7 @@ public class SortUnitTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void preventsEmptyProperty() throws Exception {
|
||||
|
||||
new Sort(Direction.ASC, "");
|
||||
Sort.by(Direction.ASC, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +82,7 @@ public class SortUnitTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void preventsNoProperties() throws Exception {
|
||||
|
||||
new Sort(Direction.ASC);
|
||||
Sort.by(Direction.ASC);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,4 +150,12 @@ public class SortUnitTests {
|
||||
assertThat(result.getNullHandling()).isEqualTo(source.getNullHandling());
|
||||
assertThat(result.isIgnoreCase()).isEqualTo(source.isIgnoreCase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preventsNullDirection() {
|
||||
|
||||
assertThatExceptionOfType(IllegalArgumentException.class)//
|
||||
.isThrownBy(() -> Sort.by((Direction) null, "foo"))//
|
||||
.withMessageContaining("Direction");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SpringDataJaxbUnitTests {
|
||||
Marshaller marshaller;
|
||||
Unmarshaller unmarshaller;
|
||||
|
||||
Sort sort = new Sort(Direction.ASC, "firstname", "lastname");
|
||||
Sort sort = Sort.by(Direction.ASC, "firstname", "lastname");
|
||||
Pageable pageable = PageRequest.of(2, 15, sort);
|
||||
Resource resource = new ClassPathResource("pageable.xml", this.getClass());
|
||||
Resource schemaFile = new ClassPathResource("spring-data-jaxb.xsd", this.getClass());
|
||||
|
||||
Reference in New Issue
Block a user