### Question:
ServerShufflingProcessor implements LoadBalancingProcessor { @Override public Result run( Map<String,String> context ) throws ProcedureException { Result result = delegate.run( context ); Collections.shuffle( result.routeEndpoints() ); Collections.shuffle( result.writeEndpoints() ); Collections.shuffle( result.readEndpoints() ); return result; } ServerShufflingProcessor( LoadBalancingProcessor delegate ); @Override Result run( Map<String,String> context ); LoadBalancingProcessor delegate();  }### Answer:
@Test public void shouldShuffleServers() throws Exception { LoadBalancingProcessor delegate = mock( LoadBalancingPlugin.class ); List<Endpoint> routers = asList( Endpoint.route( new AdvertisedSocketAddress( "route", 1 ) ), Endpoint.route( new AdvertisedSocketAddress( "route", 2 ) ) ); List<Endpoint> writers = asList( Endpoint.write( new AdvertisedSocketAddress( "write", 3 ) ), Endpoint.write( new AdvertisedSocketAddress( "write", 4 ) ), Endpoint.write( new AdvertisedSocketAddress( "write", 5 ) ) ); List<Endpoint> readers = asList( Endpoint.read( new AdvertisedSocketAddress( "read", 6 ) ), Endpoint.read( new AdvertisedSocketAddress( "read", 7 ) ), Endpoint.read( new AdvertisedSocketAddress( "read", 8 ) ), Endpoint.read( new AdvertisedSocketAddress( "read", 9 ) ) ); long ttl = 1000; LoadBalancingProcessor.Result result = new LoadBalancingResult( new ArrayList<>( routers ), new ArrayList<>( writers ), new ArrayList<>( readers ), ttl ); when( delegate.run( any() ) ).thenReturn( result ); ServerShufflingProcessor plugin = new ServerShufflingProcessor( delegate ); boolean completeShuffle = false; for ( int i = 0; i < 1000; i++ ) { LoadBalancingProcessor.Result shuffledResult = plugin.run( Collections.emptyMap() ); assertThat( shuffledResult.routeEndpoints(), containsInAnyOrder( routers.toArray() ) ); assertThat( shuffledResult.writeEndpoints(), containsInAnyOrder( writers.toArray() ) ); assertThat( shuffledResult.readEndpoints(), containsInAnyOrder( readers.toArray() ) ); assertEquals( shuffledResult.ttlMillis(), ttl ); boolean readersEqual = shuffledResult.readEndpoints().equals( readers ); boolean writersEqual = shuffledResult.writeEndpoints().equals( writers ); boolean routersEqual = shuffledResult.routeEndpoints().equals( routers ); if ( !readersEqual && !writersEqual && !routersEqual ) { completeShuffle = true; break; } } assertTrue( completeShuffle ); }