@Test
public void testLeaderTransitioning() {

    TEST_LOG.info("testLeaderTransitioning starting");
    ActorRef notifierActor = factory.createActor(MessageCollectorActor.props());
    DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
    config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
    String persistenceId = factory.generateActorId("test-actor-");
    TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
            .config(config).roleChangeNotifier(notifierActor).props()
            .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
    MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
    mockRaftActor.waitForInitializeBehaviorComplete();
    raftActorRef.tell(new AppendEntries(1L, "leader", 0L, 1L, Collections.<ReplicatedLogEntry>emptyList(),
            0L, -1L, (short)1), ActorRef.noSender());
    LeaderStateChanged leaderStateChange = MessageCollectorActor.expectFirstMatching(
            notifierActor, LeaderStateChanged.class);
    assertEquals("getLeaderId", "leader", leaderStateChange.getLeaderId());
    MessageCollectorActor.clearMessages(notifierActor);
    raftActorRef.tell(new LeaderTransitioning("leader"), ActorRef.noSender());
    leaderStateChange = MessageCollectorActor.expectFirstMatching(notifierActor, LeaderStateChanged.class);
    assertEquals("getMemberId", persistenceId, leaderStateChange.getMemberId());
    assertEquals("getLeaderId", null, leaderStateChange.getLeaderId());
    TEST_LOG.info("testLeaderTransitioning ending");
}