use of org.neo4j.cluster.protocol.election.IntegerElectionCredentials in project neo4j by neo4j.
the class DefaultWinnerStrategyTest method theWinnerShouldHaveTheBestVoteCredentials.
@Test
public void theWinnerShouldHaveTheBestVoteCredentials() throws Exception {
// given
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));
// when
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);
// then
assertEquals(instanceTwo, winner);
}
Aggregations