Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -36,8 +36,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;
|
||||
|
||||
|
||||
@@ -38,8 +38,7 @@ public class Review implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@SequenceGenerator(name = "review_generator", sequenceName = "review_sequence",
|
||||
initialValue = 64)
|
||||
@SequenceGenerator(name = "review_generator", sequenceName = "review_sequence", initialValue = 64)
|
||||
@GeneratedValue(generator = "review_generator")
|
||||
private Long id;
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ interface CityRepository extends Repository<City, Long> {
|
||||
|
||||
Page<City> findAll(Pageable pageable);
|
||||
|
||||
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name,
|
||||
String country, Pageable pageable);
|
||||
Page<City> findByNameContainingAndCountryContainingAllIgnoringCase(String name, String country, Pageable pageable);
|
||||
|
||||
City findByNameAndCountryAllIgnoringCase(String name, String country);
|
||||
|
||||
|
||||
@@ -57,9 +57,8 @@ class CityServiceImpl implements CityService {
|
||||
name = name.substring(0, splitPos);
|
||||
}
|
||||
|
||||
return this.cityRepository
|
||||
.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(),
|
||||
country.trim(), pageable);
|
||||
return this.cityRepository.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(), country.trim(),
|
||||
pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,8 +45,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
// Enable JMX so we can test the MBeans (you can't do this in a properties file)
|
||||
@SpringBootTest(
|
||||
properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
|
||||
@SpringBootTest(properties = { "spring.jmx.enabled:true", "spring.datasource.jmx-enabled:true" })
|
||||
@ActiveProfiles("scratch")
|
||||
// Separate profile for web tests to avoid clashing databases
|
||||
public class SampleDataJpaApplicationTests {
|
||||
@@ -64,15 +63,13 @@ public class SampleDataJpaApplicationTests {
|
||||
@Test
|
||||
public void testHome() throws Exception {
|
||||
|
||||
this.mvc.perform(get("/")).andExpect(status().isOk())
|
||||
.andExpect(content().string("Bath"));
|
||||
this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(content().string("Bath"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJmx() throws Exception {
|
||||
assertThat(ManagementFactory.getPlatformMBeanServer()
|
||||
.queryMBeans(new ObjectName("jpa.sample:type=HikariDataSource,*"), null))
|
||||
.hasSize(1);
|
||||
.queryMBeans(new ObjectName("jpa.sample:type=HikariDataSource,*"), null)).hasSize(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,13 +51,10 @@ public class HotelRepositoryIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void executesQueryMethodsCorrectly() {
|
||||
City city = this.cityRepository
|
||||
.findAll(PageRequest.of(0, 1, Direction.ASC, "name")).getContent().get(0);
|
||||
City city = this.cityRepository.findAll(PageRequest.of(0, 1, Direction.ASC, "name")).getContent().get(0);
|
||||
assertThat(city.getName()).isEqualTo("Atlanta");
|
||||
Page<HotelSummary> hotels = this.repository.findByCity(city,
|
||||
PageRequest.of(0, 10, Direction.ASC, "name"));
|
||||
Hotel hotel = this.repository.findByCityAndName(city,
|
||||
hotels.getContent().get(0).getName());
|
||||
Page<HotelSummary> hotels = this.repository.findByCity(city, PageRequest.of(0, 10, Direction.ASC, "name"));
|
||||
Hotel hotel = this.repository.findByCityAndName(city, hotels.getContent().get(0).getName());
|
||||
assertThat(hotel.getName()).isEqualTo("Doubletree");
|
||||
List<RatingCount> counts = this.repository.findRatingCounts(hotel);
|
||||
assertThat(counts).hasSize(1);
|
||||
|
||||
Reference in New Issue
Block a user