fix: use doNothing for void Panache persist() in verification test example

Panache persist() returns void, so when().thenReturn() won't compile.
Replaced with doNothing().when().persist() which is the correct
Mockito pattern for void methods.
This commit is contained in:
AlexisLeDain
2026-04-09 18:38:30 +02:00
parent 408b262f11
commit 46db568c38
4 changed files with 11 additions and 20 deletions

View File

@@ -83,11 +83,9 @@ class UserServiceTest {
@Test
void createUser_validInput_returnsUser() {
var dto = new CreateUserDto("Alice", "alice@example.com");
var expected = new User();
expected.id = 1L;
expected.name = dto.name();
when(userRepository.persist(any(User.class))).thenReturn(expected);
// Panache persist() void döndürür — doNothing + verify kullanın
doNothing().when(userRepository).persist(any(User.class));
User result = userService.create(dto);