Ejemplo n.º 1
0
 @Test
 public void shouldCreateNonExistentAccount() throws DuplicateAccountException {
   when(accountRepository.save(testAccount)).thenReturn(testAccount);
   AccountService accountService = new AccountServiceImpl(accountRepository, passwordEncoder);
   accountService.create(testAccount);
   verify(accountRepository, times(1)).save(testAccount);
 }
Ejemplo n.º 2
0
 @Test(expected = DuplicateAccountException.class)
 public void shouldNotCreateDuplicateAccount() throws DuplicateAccountException {
   when(accountRepository.findByUsername(TEST_USERNAME)).thenReturn(testAccount);
   when(testAccount.getUsername()).thenReturn(TEST_USERNAME);
   AccountService accountService = new AccountServiceImpl(accountRepository, passwordEncoder);
   accountService.create(testAccount);
   verify(accountRepository, times(0)).save(testAccount);
 }