Browse Source

account should be valid for valid credentials

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

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

@ -1,10 +1,11 @@
package hs.fulda.de.ci.exam.project;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
public class AccountServiceTest {
private static final String PASSWORD = "password";
@ -26,6 +27,16 @@ public class AccountServiceTest {
accountService = new AccountService(accountRepository, passwordEncoder);
}
@Test
public void shouldBeValidForValidCredentials(){
boolean accountIsValid = accountService.isValidAccount(ENABLED_USER.getId(), PASSWORD);
assertTrue(accountIsValid);
verify(accountRepository).findById(ENABLED_USER.getId());
verify(passwordEncoder).encode(PASSWORD);
}
private AccountRepository createAccountRepository() {
AccountRepository mock = mock(AccountRepository.class);
when(mock.findById(ENABLED_USER.getId())).thenReturn(ENABLED_USER);

Loading…
Cancel
Save