DATAGRAPH-1206 - Move off deprecations in Spring Data Commons.

Related ticket: DATACMNS-1496.
This commit is contained in:
Oliver Drotbohm
2019-03-14 14:33:00 +01:00
parent d3cb83aac9
commit e9f7d79f3e
5 changed files with 13 additions and 14 deletions

View File

@@ -181,7 +181,7 @@ public class GalaxyServiceTests {
assertEquals(count, 13);
Pageable pageable = new PageRequest(2, 3);
Pageable pageable = PageRequest.of(2, 3);
Page<World> worlds = galaxyService.findAllWorlds(pageable);
assertTrue(worlds.hasNext());
@@ -194,7 +194,7 @@ public class GalaxyServiceTests {
assertEquals(count, 13);
Pageable pageable = new PageRequest(4, 3);
Pageable pageable = PageRequest.of(4, 3);
Page<World> worlds = galaxyService.findAllWorlds(pageable);
assertFalse(worlds.hasNext());
@@ -211,7 +211,7 @@ public class GalaxyServiceTests {
// note: this doesn't work, because deleted node ids are not reclaimed
// long sum = (size * size - size) / 2; // 0-based node ids
Pageable pageable = new PageRequest(0, 3);
Pageable pageable = PageRequest.of(0, 3);
for (;;) {
Page<World> page = galaxyService.findAllWorlds(pageable);
@@ -236,7 +236,7 @@ public class GalaxyServiceTests {
String[] sortedNames = getNamesSorted(worlds);
Pageable pageable = new PageRequest(0, 3, Sort.Direction.ASC, "name");
Pageable pageable = PageRequest.of(0, 3, Sort.Direction.ASC, "name");
int i = 0;
for (;;) {
@@ -264,7 +264,7 @@ public class GalaxyServiceTests {
String[] sortedNames = getNamesSorted(worlds);
Sort sort = new Sort(Sort.Direction.ASC, "name");
Sort sort = Sort.by(Sort.Direction.ASC, "name");
int i = 0;
for (World world : galaxyService.findAllWorlds(sort)) {
assertEquals(sortedNames[i], world.getName());

View File

@@ -549,7 +549,7 @@ public class DerivedQueryTests {
}
userRepository.save(new User("A", "C"));
Pageable pageable = new PageRequest(0, 4);
Pageable pageable = PageRequest.of(0, 4);
Page<User> page = userRepository.findByNameAndSurname("A", "B", pageable);
assertEquals(4, page.getNumberOfElements());
assertEquals(10, page.getTotalElements());
@@ -574,7 +574,7 @@ public class DerivedQueryTests {
assertTrue(page.isLast());
assertFalse(page.hasNext());
page = userRepository.findByNameAndSurname("A", "B", new PageRequest(0, 10));
page = userRepository.findByNameAndSurname("A", "B", PageRequest.of(0, 10));
assertEquals(10, page.getNumberOfElements());
assertEquals(10, page.getTotalElements());
assertEquals(0, page.getNumber());
@@ -593,7 +593,7 @@ public class DerivedQueryTests {
}
userRepository.save(new User("A", "C"));
Pageable pageable = new PageRequest(0, 4);
Pageable pageable = PageRequest.of(0, 4);
Slice<User> page = userRepository.findByNameAndRatingsStars("A", 5, pageable);
assertEquals(4, page.getNumberOfElements());
assertTrue(page.hasNext());
@@ -606,7 +606,7 @@ public class DerivedQueryTests {
assertEquals(2, page.getNumberOfElements());
assertFalse(page.hasNext());
page = userRepository.findByNameAndRatingsStars("A", 5, new PageRequest(0, 10));
page = userRepository.findByNameAndRatingsStars("A", 5, PageRequest.of(0, 10));
assertEquals(10, page.getNumberOfElements());
assertFalse(page.hasNext());
}

View File

@@ -79,7 +79,7 @@ public class Java8SupportTests {
@Test
public void shouldStreamCinemasWithSort() {
Collection<Cinema> allCinemas = cinemaRepository.getCinemasSortedByName(new Sort("n.name"))
Collection<Cinema> allCinemas = cinemaRepository.getCinemasSortedByName(Sort.by("n.name"))
.collect(Collectors.toList());
assertEquals(10, allCinemas.size());

View File

@@ -339,7 +339,7 @@ public class PagedQueryTests {
@Transactional
public void shouldFindSortedCinemas() {
setup();
Sort sort = new Sort(Sort.Direction.ASC, "name");
Sort sort = Sort.by(Sort.Direction.ASC, "name");
List<Cinema> cinemas = cinemaRepository.findByLocation("London", sort);
assertEquals(10, cinemas.size());
assertEquals("Cineplex", cinemas.get(0).getName());
@@ -451,7 +451,7 @@ public class PagedQueryTests {
@Transactional
public void shouldFindCinemasSortedByNameWithCustomQuery() {
setup();
Sort sort = new Sort(Sort.Direction.ASC, "n.name");
Sort sort = Sort.by(Sort.Direction.ASC, "n.name");
List<Cinema> cinemas = cinemaRepository.getCinemasSortedByName(sort);
assertEquals(10, cinemas.size());
assertEquals("Cineplex", cinemas.get(0).getName());

View File

@@ -50,7 +50,6 @@ public class GraphQueryExecutionTests {
private ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
@Test
@SuppressWarnings("unchecked")
public void pagedExecutionShouldNotGenerateCountQueryIfQueryReportedNoResults() {
when(sessionMock.query(eq(User.class), anyString(), anyMap())).thenReturn(Collections.<User> emptyList());
@@ -58,7 +57,7 @@ public class GraphQueryExecutionTests {
GraphQueryMethod queryMethod = new GraphQueryMethod(method, new DefaultRepositoryMetadata(UserRepository.class),
factory);
GraphParameterAccessor accessor = new GraphParametersParameterAccessor(queryMethod,
new Object[] { "", new PageRequest(0, 1) });
new Object[] { "", PageRequest.of(0, 1) });
GraphQueryExecution.PagedExecution execution = new GraphQueryExecution.PagedExecution(sessionMock, accessor);
Query query = new Query("", "noop", new HashMap<>());
execution.execute(query, User.class);