Merge branch '2.1.x'

Closes gh-17079
This commit is contained in:
Andy Wilkinson
2019-06-07 11:00:44 +01:00
2799 changed files with 28402 additions and 47836 deletions

View File

@@ -30,8 +30,7 @@ public class City implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name = "city_generator", sequenceName = "city_sequence",
initialValue = 23)
@SequenceGenerator(name = "city_generator", sequenceName = "city_sequence", initialValue = 23)
@GeneratedValue(generator = "city_generator")
private Long id;

View File

@@ -33,8 +33,7 @@ public class Hotel implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@SequenceGenerator(name = "hotel_generator", sequenceName = "hotel_sequence",
initialValue = 28)
@SequenceGenerator(name = "hotel_generator", sequenceName = "hotel_sequence", initialValue = 28)
@GeneratedValue(generator = "hotel_generator")
private Long id;

View File

@@ -27,11 +27,9 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource(collectionResourceRel = "cities", path = "cities")
interface CityRepository extends PagingAndSortingRepository<City, Long> {
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(
@Param("name") String name, @Param("country") String country,
Pageable pageable);
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(@Param("name") String name,
@Param("country") String country, Pageable pageable);
City findByNameAndCountryAllIgnoringCase(@Param("name") String name,
@Param("country") String country);
City findByNameAndCountryAllIgnoringCase(@Param("name") String name, @Param("country") String country);
}

View File

@@ -55,25 +55,21 @@ class SampleDataRestApplicationTests {
@Test
void testHome() throws Exception {
this.mvc.perform(get("/api")).andExpect(status().isOk())
.andExpect(content().string(containsString("hotels")));
this.mvc.perform(get("/api")).andExpect(status().isOk()).andExpect(content().string(containsString("hotels")));
}
@Test
void findByNameAndCountry() throws Exception {
this.mvc.perform(get(
"/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Melbourne&country=Australia"))
.andExpect(status().isOk())
.andExpect(jsonPath("state", equalTo("Victoria")))
this.mvc.perform(get("/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Melbourne&country=Australia"))
.andExpect(status().isOk()).andExpect(jsonPath("state", equalTo("Victoria")))
.andExpect(jsonPath("name", equalTo("Melbourne")));
}
@Test
void findByContaining() throws Exception {
this.mvc.perform(get(
"/api/cities/search/findByNameContainingAndCountryContainingAllIgnoringCase?name=&country=UK"))
.andExpect(status().isOk())
.andExpect(jsonPath("_embedded.cities", hasSize(3)));
this.mvc.perform(
get("/api/cities/search/findByNameContainingAndCountryContainingAllIgnoringCase?name=&country=UK"))
.andExpect(status().isOk()).andExpect(jsonPath("_embedded.cities", hasSize(3)));
}
}

View File

@@ -46,17 +46,15 @@ class CityRepositoryIntegrationTests {
@Test
void findByNameAndCountry() {
City city = this.repository.findByNameAndCountryAllIgnoringCase("Melbourne",
"Australia");
City city = this.repository.findByNameAndCountryAllIgnoringCase("Melbourne", "Australia");
assertThat(city).isNotNull();
assertThat(city.getName()).isEqualTo("Melbourne");
}
@Test
void findContaining() {
Page<City> cities = this.repository
.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK",
PageRequest.of(0, 10));
Page<City> cities = this.repository.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK",
PageRequest.of(0, 10));
assertThat(cities.getTotalElements()).isEqualTo(3L);
}