@Test
  public void testUpdateAccountsException() throws Exception {
    Account updatedTestAccount = new AccountBuilder(testAccount).status(Account.AccountStatus.INACTIVE).build();
    Collection<Account> accountsToUpdate = Collections.singletonList(updatedTestAccount);
    // exception in primary should be thrown
    doThrow(new AccountServiceException("", AccountServiceErrorCode.InternalError)).when(primaryAccountService)
        .updateAccounts(any());
    TestUtils.assertException(AccountServiceException.class,
        () -> compositeAccountService.updateAccounts(accountsToUpdate), null);
    verify(primaryAccountService).updateAccounts(accountsToUpdate);
    verify(secondaryAccountService, never()).updateAccounts(any());

    // exception in secondary should be swallowed
    reset(primaryAccountService, secondaryAccountService);
    doThrow(new AccountServiceException("", AccountServiceErrorCode.InternalError)).when(secondaryAccountService)
        .updateAccounts(any());
    TestUtils.assertException(AccountServiceException.class,
        () -> compositeAccountService.updateAccounts(accountsToUpdate), null);
    verify(primaryAccountService).updateAccounts(accountsToUpdate);
    verify(secondaryAccountService).updateAccounts(accountsToUpdate);
  }
Test composite updateAccounts() with either of the sources throwing exception.
ambry-account/src/test/java/com/github/ambry/account/CompositeAccountServiceTest.java