Search in sources :

Example 1 with NotElectableElectionCredentials

use of org.neo4j.cluster.protocol.election.NotElectableElectionCredentials in project neo4j by neo4j.

the class DefaultWinnerStrategyTest method shouldNotPickAWinnerIfAllVotesAreForIneligibleCandidates.

@Test
public void shouldNotPickAWinnerIfAllVotesAreForIneligibleCandidates() {
    // 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 NotElectableElectionCredentials()), new Vote(instanceTwo, new NotElectableElectionCredentials()));
    DefaultWinnerStrategy strategy = new DefaultWinnerStrategy(clusterContext);
    org.neo4j.cluster.InstanceId winner = strategy.pickWinner(votes);
    // then
    assertNull(winner);
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) InstanceId(org.neo4j.cluster.InstanceId) Log(org.neo4j.logging.Log) ClusterContext(org.neo4j.cluster.protocol.cluster.ClusterContext) LogProvider(org.neo4j.logging.LogProvider) NotElectableElectionCredentials(org.neo4j.cluster.protocol.election.NotElectableElectionCredentials) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 InstanceId (org.neo4j.cluster.InstanceId)1 ClusterContext (org.neo4j.cluster.protocol.cluster.ClusterContext)1 NotElectableElectionCredentials (org.neo4j.cluster.protocol.election.NotElectableElectionCredentials)1 Log (org.neo4j.logging.Log)1 LogProvider (org.neo4j.logging.LogProvider)1