Merge pull request #5774 from eugenp/BAEL-2331-v2

add data order methods
This commit is contained in:
Loredana Crusoveanu 2018-11-25 20:21:30 +02:00 committed by GitHub
commit 469cd9ec25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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);
}

View File

@ -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));
}
}