add data order methods
This commit is contained in:
parent
15391f69ec
commit
a2722368af
|
@ -1,5 +1,6 @@
|
|||
package com.baeldung.passenger;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -9,4 +10,8 @@ interface PassengerRepository extends JpaRepository<Passenger, Long>, CustomPass
|
|||
Passenger findFirstByOrderBySeatNumberAsc();
|
||||
|
||||
List<Passenger> findByOrderBySeatNumberAsc();
|
||||
|
||||
List<Passenger> findByLastNameOrderBySeatNumberAsc(String lastName);
|
||||
|
||||
List<Passenger> findByLastName(String lastName, Sort sort);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class PassengerRepositoryIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenSeveralPassengersWhenOrderedBySeatNumberAscThenThePassengersReturnedInCorrectOrder() {
|
||||
public void givenPassengers_whenOrderedBySeatNumberAsc_thenCorrectOrder() {
|
||||
Passenger fred = Passenger.from("Fred", "Bloggs", 22);
|
||||
Passenger ricki = Passenger.from("Ricki", "Bobbie", 36);
|
||||
Passenger jill = Passenger.from("Jill", "Smith", 50);
|
||||
|
@ -83,7 +83,7 @@ public class PassengerRepositoryIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenSeveralPassengersWhenFindAllWithSortBySeatNumberAscThenReturnPassengersInCorrectOrder() {
|
||||
public void givenPassengers_whenFindAllWithSortBySeatNumberAsc_thenCorrectOrder() {
|
||||
Passenger fred = Passenger.from("Fred", "Bloggs", 22);
|
||||
Passenger ricki = Passenger.from("Ricki", "Bobbie", 36);
|
||||
Passenger jill = Passenger.from("Jill", "Smith", 50);
|
||||
|
@ -94,4 +94,5 @@ public class PassengerRepositoryIntegrationTest {
|
|||
|
||||
assertThat(passengers, contains(fred, ricki, jill, siya, eve));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue