@Test
void shouldThrowModifiedErrorWhenRefreshRoutingTableFails() throws Throwable
{

    ConnectionPool connectionPool = newConnectionPoolMock();
    Rediscovery rediscovery = mock( Rediscovery.class );
    when( rediscovery.resolve() ).thenReturn( Arrays.asList( A, B ) );
    RoutingTableRegistry routingTables = mock( RoutingTableRegistry.class );
    when( routingTables.ensureRoutingTable( any( ConnectionContext.class ) ) ).thenThrow( new ServiceUnavailableException( "boooo" ) );
    LoadBalancer loadBalancer = newLoadBalancer( connectionPool, routingTables, rediscovery );
    ServiceUnavailableException exception = assertThrows( ServiceUnavailableException.class, () -> await( loadBalancer.verifyConnectivity() ) );
    assertThat( exception.getMessage(), startsWith( "Unable to connect to database management service," ) );
    verify( routingTables ).ensureRoutingTable( any( ConnectionContext.class ) );
}