@Test
  public void testSetException() throws Exception {
    // exception in primary should be thrown
    when(primarySource.set(any())).thenThrow(new RuntimeException());
    DataNodeConfig config = createConfig(1, 1);
    TestUtils.assertException(RuntimeException.class, () -> compositeSource.set(config), null);
    verify(primarySource).set(config);
    verify(secondarySource, never()).set(any());

    // exception in secondary should be swallowed
    reset(primarySource, secondarySource);
    when(primarySource.set(any())).thenReturn(true);
    when(secondarySource.set(any())).thenThrow(new RuntimeException());
    assertTrue("Expected response from primary", compositeSource.set(config));
    verify(primarySource).set(config);
    verify(secondarySource).set(config);
    assertEquals("Expected one inconsistency", 1, metrics.setSwallowedErrorCount.getCount());
  }
Test exceptions thrown in the composite set method.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/CompositeDataNodeConfigSourceTest.java