mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Align with API changes in latest Spring Data Kay snapshots
See gh-7461
This commit is contained in:
parent
83df8e47fe
commit
a9a31107cf
@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.data.mongo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mongodb.Mongo;
|
||||
@ -44,8 +45,9 @@ import org.springframework.data.mapping.model.FieldNamingStrategy;
|
||||
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.CustomConversions;
|
||||
import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@ -165,8 +167,13 @@ public class MongoDataAutoConfigurationTests {
|
||||
MongoDataAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
MongoMappingContext context = this.context.getBean(MongoMappingContext.class);
|
||||
MongoPersistentEntity<?> entity = context.getPersistentEntity(Sample.class);
|
||||
assertThat(entity.getPersistentProperty("date").isEntity()).isFalse();
|
||||
Optional<BasicMongoPersistentEntity<?>> entity = context
|
||||
.getPersistentEntity(Sample.class);
|
||||
assertThat(entity).isPresent();
|
||||
Optional<MongoPersistentProperty> dateProperty = entity.get()
|
||||
.getPersistentProperty("date");
|
||||
assertThat(dateProperty).isPresent();
|
||||
assertThat(dateProperty.get().isEntity()).isFalse();
|
||||
}
|
||||
|
||||
public void testFieldNamingStrategy(String strategy,
|
||||
|
@ -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')")
|
||||
|
Loading…
Reference in New Issue
Block a user