|
|
@ -2,10 +2,10 @@ package hs.fulda.de.ci.exam.project; |
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.mockito.ArgumentCaptor; |
|
|
|
import org.mockito.InOrder; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
import static org.mockito.ArgumentMatchers.anyString; |
|
|
|
import static org.mockito.Mockito.*; |
|
|
|
|
|
|
@ -68,6 +68,19 @@ public class AccountServiceTest { |
|
|
|
verify(accountRepository).findById(DISABLED_USER.getId()); |
|
|
|
verify(passwordEncoder, never()).encode(anyString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void shouldBeInvalidForInvalidPassword() { |
|
|
|
boolean accountIsValid = |
|
|
|
accountService.isValidAccount(ENABLED_USER.getId(), "invalid"); |
|
|
|
assertFalse(accountIsValid); |
|
|
|
|
|
|
|
ArgumentCaptor<String> passwordCaptor = ArgumentCaptor.forClass(String.class); |
|
|
|
|
|
|
|
verify(passwordEncoder).encode(passwordCaptor.capture()); |
|
|
|
assertEquals("invalid", passwordCaptor.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
private AccountRepository createAccountRepository() { |
|
|
|
AccountRepository mock = mock(AccountRepository.class); |
|
|
|
when(mock.findById(ENABLED_USER.getId())).thenReturn(ENABLED_USER); |
|
|
|