Browse Source

create Account Repository for AccountServiceTest mocked

feature-pr-AccountService
Sona Markosyan 3 years ago
parent
commit
2d27fc1d5e
  1. 8
      src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java

8
src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java

@ -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");

Loading…
Cancel
Save