mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Add unit test for PetController.findOwner with valid ownerId
This commit is contained in:
parent
9359be811a
commit
0a7e1ae9dd
1 changed files with 15 additions and 0 deletions
|
@ -71,6 +71,21 @@ class PetControllerTest {
|
||||||
verify(ownerRepository).findById(ownerId);
|
verify(ownerRepository).findById(ownerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Test findOwner with valid ownerId")
|
||||||
|
void testFindOwnerWithValidOwnerId() {
|
||||||
|
int ownerId = 1;
|
||||||
|
Owner owner = new Owner();
|
||||||
|
owner.setId(ownerId);
|
||||||
|
doReturn(owner).when(ownerRepository).findById(ownerId);
|
||||||
|
|
||||||
|
Owner foundOwner = petController.findOwner(ownerId);
|
||||||
|
|
||||||
|
assertThat(foundOwner).isNotNull();
|
||||||
|
assertThat(foundOwner.getId()).isEqualTo(ownerId);
|
||||||
|
verify(ownerRepository).findById(ownerId);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Test findPet with null petId returns new Pet")
|
@DisplayName("Test findPet with null petId returns new Pet")
|
||||||
void testFindPetWithNullPetIdReturnsNewPet() {
|
void testFindPetWithNullPetIdReturnsNewPet() {
|
||||||
|
|
Loading…
Reference in a new issue