mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 06:45:50 +00:00
Add unit test for processUpdateOwnerForm without validation errors in OwnerController
This commit is contained in:
parent
751081667d
commit
9185400240
1 changed files with 16 additions and 0 deletions
|
@ -84,4 +84,20 @@ class OwnerControllerTest {
|
||||||
verify(ownerRepository).save(owner);
|
verify(ownerRepository).save(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Test processUpdateOwnerForm without validation errors")
|
||||||
|
void testProcessUpdateOwnerFormWithoutValidationErrors() {
|
||||||
|
Owner owner = new Owner();
|
||||||
|
owner.setId(1);
|
||||||
|
|
||||||
|
doReturn(false).when(result).hasErrors();
|
||||||
|
doNothing().when(ownerRepository).save(owner);
|
||||||
|
|
||||||
|
String view = ownerController.processUpdateOwnerForm(owner, result, 1, redirectAttributes);
|
||||||
|
|
||||||
|
assertThat(view).isEqualTo("redirect:/owners/{ownerId}");
|
||||||
|
verify(result).hasErrors();
|
||||||
|
verify(ownerRepository).save(owner);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue