### Question:
AccountService { public Account create(long userId, String description, boolean onBudget) { User user = userRepository.getOne(userId); Account account = new Account(description, onBudget, user); return accountRepository.saveAndFlush(account); } @Autowired  AccountService(AccountRepository accountRepository, UserRepository userRepository); List<Account> list(long userId); Account get(long id); Account create(long userId, String description, boolean onBudget);  }### Answer:
@Test public void shouldCreateAnAccount() { User bob = UserTestUtils.createBob(); when(userRepositoryMock.getOne(bob.getId())).thenReturn(bob); when(accountRepositoryMock.saveAndFlush(isA(Account.class))).thenAnswer(invocation -> invocation.getArgument(0)); Account account = testSubject.create(bob.getId(), "Cash", true); assertThat(account).isNotNull(); assertThat(account.getUser()).isNotNull(); assertThat(account.getUser().getId()).isEqualTo(bob.getId()); assertThat(account.getDescription()).isEqualTo("Cash"); assertThat(account.isOnBudget()).isTrue(); }