mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Add unit test for processFindForm with non-empty last name and empty results in OwnerController
This commit is contained in:
parent
74e791dcaa
commit
45d0528d7e
1 changed files with 17 additions and 0 deletions
|
@ -187,4 +187,21 @@ class OwnerControllerTest {
|
|||
verify(ownerRepository).findByLastName("Doe", PageRequest.of(0, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test processFindForm with non-empty last name and empty results")
|
||||
void testProcessFindFormWithNonEmptyLastNameAndEmptyResults() {
|
||||
Owner owner = new Owner();
|
||||
owner.setLastName("Smith");
|
||||
|
||||
doReturn(Page.empty()).when(ownerRepository).findByLastName("Smith", PageRequest.of(0, 5));
|
||||
doNothing().when(result).rejectValue("lastName", "notFound", "not found");
|
||||
|
||||
Model model = new ConcurrentModel();
|
||||
String view = ownerController.processFindForm(1, owner, result, model);
|
||||
|
||||
assertThat(view).isEqualTo("owners/findOwners");
|
||||
verify(ownerRepository).findByLastName("Smith", PageRequest.of(0, 5));
|
||||
verify(result).rejectValue("lastName", "notFound", "not found");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue