|
|
@ -21,10 +21,18 @@ public class AccountServiceTest { |
|
|
|
|
|
|
|
@Before |
|
|
|
public void setup() { |
|
|
|
accountRepository = createAccountRepository(); |
|
|
|
passwordEncoder = createPasswordEncoder(); |
|
|
|
accountService = new AccountService(accountRepository, passwordEncoder); |
|
|
|
} |
|
|
|
|
|
|
|
private AccountRepository createAccountRepository() { |
|
|
|
AccountRepository mock = mock(AccountRepository.class); |
|
|
|
when(mock.findById(ENABLED_USER.getId())).thenReturn(ENABLED_USER); |
|
|
|
when(mock.findById(DISABLED_USER.getId())).thenReturn(DISABLED_USER); |
|
|
|
return mock; |
|
|
|
} |
|
|
|
|
|
|
|
private PasswordEncoder createPasswordEncoder() { |
|
|
|
PasswordEncoder mock = mock(PasswordEncoder.class); |
|
|
|
when(mock.encode(anyString())).thenReturn("any password hash"); |
|
|
|