Align with API changes in latest Spring Data Kay snapshots
See gh-7461
This commit is contained in:
@@ -42,7 +42,7 @@ public class CityRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void findsFirstPageOfCities() {
|
||||
|
||||
Page<City> cities = this.repository.findAll(new PageRequest(0, 10));
|
||||
Page<City> cities = this.repository.findAll(PageRequest.of(0, 10));
|
||||
assertThat(cities.getTotalElements()).isGreaterThan(20L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,11 @@ public class HotelRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void executesQueryMethodsCorrectly() {
|
||||
City city = this.cityRepository
|
||||
.findAll(new PageRequest(0, 1, Direction.ASC, "name")).getContent()
|
||||
.get(0);
|
||||
.findAll(PageRequest.of(0, 1, Direction.ASC, "name")).getContent().get(0);
|
||||
assertThat(city.getName()).isEqualTo("Atlanta");
|
||||
|
||||
Page<HotelSummary> hotels = this.repository.findByCity(city,
|
||||
new PageRequest(0, 10, Direction.ASC, "name"));
|
||||
PageRequest.of(0, 10, Direction.ASC, "name"));
|
||||
Hotel hotel = this.repository.findByCityAndName(city,
|
||||
hotels.getContent().get(0).getName());
|
||||
assertThat(hotel.getName()).isEqualTo("Doubletree");
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CityRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void findsFirstPageOfCities() {
|
||||
|
||||
Page<City> cities = this.repository.findAll(new PageRequest(0, 10));
|
||||
Page<City> cities = this.repository.findAll(PageRequest.of(0, 10));
|
||||
assertThat(cities.getTotalElements()).isGreaterThan(20L);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CityRepositoryIntegrationTests {
|
||||
public void findContaining() {
|
||||
Page<City> cities = this.repository
|
||||
.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK",
|
||||
new PageRequest(0, 10));
|
||||
PageRequest.of(0, 10));
|
||||
assertThat(cities.getTotalElements()).isEqualTo(3L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package sample.secure.oauth2.resource;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ public interface FlightRepository extends CrudRepository<Flight, Long> {
|
||||
Iterable<Flight> findAll();
|
||||
|
||||
@Override
|
||||
Flight findOne(Long aLong);
|
||||
Optional<Flight> findOne(Long aLong);
|
||||
|
||||
@Override
|
||||
<S extends Flight> S save(S entity);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package sample.secure.oauth2;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
@@ -33,7 +35,7 @@ public interface FlightRepository extends CrudRepository<Flight, Long> {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("#oauth2.hasScope('read')")
|
||||
Flight findOne(Long aLong);
|
||||
Optional<Flight> findOne(Long aLong);
|
||||
|
||||
@Override
|
||||
@PreAuthorize("#oauth2.hasScope('write')")
|
||||
|
||||
Reference in New Issue
Block a user