@Test
public void shouldOpenAccount() {

  when(accountRepository.save(any(Account.class))).then(invocation -> {
    ((Account) invocation.getArguments()[0]).setId(accountId);
    return null;
  });
  AccountInfo accountInfo = new AccountInfo(customerId, "Checking", initialBalance);
  Account account = accountService.openAccount(accountInfo);
  verify(accountRepository).save(account);
  verify(domainEventPublisher).publish(Account.class, accountId, Collections.singletonList(new AccountOpenedEvent(accountInfo)));
}