mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Add unit test for showVetList without pagination in VetController
This commit is contained in:
parent
4ebe0c6def
commit
3717a2b115
1 changed files with 19 additions and 0 deletions
|
@ -52,4 +52,23 @@ class VetControllerTest {
|
||||||
verify(model).addAttribute("listVets", paginatedVets.getContent());
|
verify(model).addAttribute("listVets", paginatedVets.getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Test showVetList without pagination")
|
||||||
|
void testShowVetListWithoutPagination() {
|
||||||
|
int defaultPage = 1;
|
||||||
|
Pageable pageable = PageRequest.of(defaultPage - 1, 5);
|
||||||
|
Page<Vet> paginatedVets = new PageImpl<>(Collections.emptyList(), pageable, 0);
|
||||||
|
|
||||||
|
doReturn(paginatedVets).when(vetRepository).findAll(pageable);
|
||||||
|
|
||||||
|
String viewName = vetController.showVetList(defaultPage, model);
|
||||||
|
|
||||||
|
assertThat(viewName).isEqualTo("vets/vetList");
|
||||||
|
verify(vetRepository).findAll(pageable);
|
||||||
|
verify(model).addAttribute("currentPage", defaultPage);
|
||||||
|
verify(model).addAttribute("totalPages", paginatedVets.getTotalPages());
|
||||||
|
verify(model).addAttribute("totalItems", paginatedVets.getTotalElements());
|
||||||
|
verify(model).addAttribute("listVets", paginatedVets.getContent());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue