|
|
@ -2,7 +2,9 @@ package hs.fulda.de.ci.exam.project; |
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.mockito.InOrder; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
|
import static org.mockito.ArgumentMatchers.anyString; |
|
|
|
import static org.mockito.Mockito.*; |
|
|
@ -37,6 +39,26 @@ public class AccountServiceTest { |
|
|
|
verify(passwordEncoder).encode(PASSWORD); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void shouldBEInvalidForInvalidId() { |
|
|
|
boolean accountIsValid = accountService.isValidAccount("invalid id", PASSWORD); |
|
|
|
assertFalse(accountIsValid); |
|
|
|
|
|
|
|
InOrder inOrder = inOrder(accountRepository, passwordEncoder); |
|
|
|
inOrder.verify(accountRepository).findById("invalid id"); |
|
|
|
inOrder.verify(passwordEncoder, never()).encode(anyString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void shouldBeInvalidForInvalid(){ |
|
|
|
boolean accountIsValid = accountService.isValidAccount("invalid id", PASSWORD); |
|
|
|
assertFalse(accountIsValid); |
|
|
|
|
|
|
|
InOrder inOrder = inOrder(accountRepository, passwordEncoder); |
|
|
|
inOrder.verify(accountRepository).findById("invalid id"); |
|
|
|
inOrder.verify(passwordEncoder, never()).encode(anyString()); |
|
|
|
} |
|
|
|
|
|
|
|
private AccountRepository createAccountRepository() { |
|
|
|
AccountRepository mock = mock(AccountRepository.class); |
|
|
|
when(mock.findById(ENABLED_USER.getId())).thenReturn(ENABLED_USER); |
|
|
|