From 73d5b205e82a41c247d4fbc5ac4cef855d992b4c Mon Sep 17 00:00:00 2001 From: Sona Markosyan Date: Fri, 11 Feb 2022 00:56:39 +0100 Subject: [PATCH] account should be valid for valid credentials --- .../de/ci/exam/project/AccountServiceTest.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java index f5ab438..1e5d96b 100644 --- a/src/test/java/hs/fulda/de/ci/exam/project/AccountServiceTest.java +++ b/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);