### Question:
UpstreamStrategyAddressSupplier implements ThrowingSupplier<AdvertisedSocketAddress,CatchupAddressResolutionException> { @Override public AdvertisedSocketAddress get() throws CatchupAddressResolutionException { try { MemberId upstreamMember = strategySelector.bestUpstreamDatabase(); return topologyService.findCatchupAddress( upstreamMember ).orElseThrow( () -> new CatchupAddressResolutionException( upstreamMember ) ); } catch ( UpstreamDatabaseSelectionException e ) { throw new CatchupAddressResolutionException( e ); } } UpstreamStrategyAddressSupplier( UpstreamDatabaseStrategySelector strategySelector, TopologyService topologyService ); @Override AdvertisedSocketAddress get();  }### Answer:
@Test public void selectionPrioritiesAreKept() throws CatchupAddressResolutionException { UpstreamDatabaseStrategySelector upstreamDatabaseStrategySelector = new UpstreamDatabaseStrategySelector( new CountedSelectionStrategy( defaultMember, 5 ), Arrays.asList( new CountedSelectionStrategy( firstMember, 1 ), new CountedSelectionStrategy( secondMember, 1 ) ), NullLogProvider.getInstance() ); UpstreamStrategyAddressSupplier upstreamStrategyAddressSupplier = new UpstreamStrategyAddressSupplier( upstreamDatabaseStrategySelector, topologyService ); AdvertisedSocketAddress firstResult = upstreamStrategyAddressSupplier.get(); AdvertisedSocketAddress secondResult = upstreamStrategyAddressSupplier.get(); AdvertisedSocketAddress thirdResult = upstreamStrategyAddressSupplier.get(); assertEquals( firstAddress, firstResult ); assertEquals( secondAddress, secondResult ); assertEquals( defaultAddress, thirdResult ); }
@Test public void exceptionWhenStrategiesFail() throws CatchupAddressResolutionException { UpstreamDatabaseStrategySelector upstreamDatabaseStrategySelector = new UpstreamDatabaseStrategySelector( new CountedSelectionStrategy( defaultMember, 0 ) ); UpstreamStrategyAddressSupplier upstreamStrategyAddressSupplier = new UpstreamStrategyAddressSupplier( upstreamDatabaseStrategySelector, topologyService ); expectedException.expect( CatchupAddressResolutionException.class ); upstreamStrategyAddressSupplier.get(); }