### Question:
DefaultWinnerStrategy implements WinnerStrategy { @Override public org.neo4j.cluster.InstanceId pickWinner( Collection<Vote> votes ) { List<Vote> eligibleVotes = ElectionContextImpl.removeBlankVotes( votes ); moveMostSuitableCandidatesToTop( eligibleVotes ); logElectionOutcome( votes, eligibleVotes ); for ( Vote vote : eligibleVotes ) { return vote.getSuggestedNode(); } return null; } DefaultWinnerStrategy( ClusterContext electionContext ); @Override org.neo4j.cluster.InstanceId pickWinner( Collection<Vote> votes );  }### Answer:
@Test public void shouldLogElectionProcess() { ClusterContext clusterContext = mock( ClusterContext.class ); final Log log = mock( Log.class ); LogProvider logProvider = new LogProvider() { @Override public Log getLog( Class loggingClass ) { return log; } @Override public Log getLog( String name ) { return log; } }; when( clusterContext.getLog( DefaultWinnerStrategy.class ) ).thenReturn( logProvider.getLog( DefaultWinnerStrategy.class ) ); Collection<Vote> votes = Collections.emptyList(); DefaultWinnerStrategy strategy = new DefaultWinnerStrategy( clusterContext ); strategy.pickWinner( votes ); verify( log ).debug( "Election: received votes [], eligible votes []" ); }
@Test public void shouldNotPickAWinnerIfAllVotesAreForIneligibleCandidates() { InstanceId instanceOne = new InstanceId( 1 ); InstanceId instanceTwo = new InstanceId( 2 ); ClusterContext clusterContext = mock( ClusterContext.class ); final Log log = mock( Log.class ); LogProvider logProvider = new LogProvider() { @Override public Log getLog( Class loggingClass ) { return log; } @Override public Log getLog( String name ) { return log; } }; when( clusterContext.getLog( DefaultWinnerStrategy.class ) ).thenReturn( logProvider.getLog( DefaultWinnerStrategy.class ) ); Collection<Vote> votes = Arrays.asList( new Vote( instanceOne, new NotElectableElectionCredentials() ), new Vote( instanceTwo, new NotElectableElectionCredentials() ) ); DefaultWinnerStrategy strategy = new DefaultWinnerStrategy( clusterContext ); org.neo4j.cluster.InstanceId winner = strategy.pickWinner( votes ); assertNull( winner ); }
@Test public void theWinnerShouldHaveTheBestVoteCredentials() { InstanceId instanceOne = new InstanceId( 1 ); InstanceId instanceTwo = new InstanceId( 2 ); ClusterContext clusterContext = mock( ClusterContext.class ); final Log log = mock( Log.class ); LogProvider logProvider = new LogProvider() { @Override public Log getLog( Class loggingClass ) { return log; } @Override public Log getLog( String name ) { return log; } }; when( clusterContext.getLog( DefaultWinnerStrategy.class ) ).thenReturn( logProvider.getLog( DefaultWinnerStrategy.class ) ); Collection<Vote> votes = Arrays.asList( new Vote( instanceOne, new IntegerElectionCredentials( 1 ) ), new Vote( instanceTwo, new IntegerElectionCredentials( 2 ) ) ); DefaultWinnerStrategy strategy = new DefaultWinnerStrategy( clusterContext ); org.neo4j.cluster.InstanceId winner = strategy.pickWinner( votes ); assertEquals( instanceTwo, winner ); }