@Test
  public void testUpdateContainersException() throws Exception {
    Collection<Container> updatedContainers = Collections.singletonList(
        new ContainerBuilder(testContainer).setStatus(Container.ContainerStatus.INACTIVE).build());

    // exception in primary should be thrown
    when(primaryAccountService.updateContainers(any(), any())).thenThrow(
        new AccountServiceException("", AccountServiceErrorCode.InternalError));
    when(secondaryAccountService.updateContainers(any(), any())).thenReturn(updatedContainers);
    TestUtils.assertException(AccountServiceException.class,
        () -> compositeAccountService.updateContainers(testAccount.getName(), updatedContainers), null);
    verify(primaryAccountService).updateContainers(testAccount.getName(), updatedContainers);
    verify(secondaryAccountService, never()).updateContainers(any(), any());

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