### Question:
AccountService { public Account updateAccount(Long id, Account account) { Account accountToBeUpdated = getAccountById(id); accountToBeUpdated.setName(account.getName()); return repository.save(accountToBeUpdated); }  boolean isAccountPresent(Long id); Account getAccountById(Long id); List<Account> getAccounts(); Account addAccount(Account account); Account updateAccount(Long id, Account account); void deleteAccount(Long id);  }### Answer:
@Test public void whenUpdatingAccountThenUpdatedAccountShouldReturn() { Account mockAccount = mock(Account.class); Long id = new Long(1); when(mockAccount.getId()).thenReturn(id); when(mockAccount.getName()).thenReturn("Sagar Jadhav"); when(repository.findById(id)).thenReturn(Optional.of(mockAccount)); when(repository.save(mockAccount)).thenReturn(mockAccount); assertEquals(mockAccount, service.updateAccount(id, mockAccount)); }