RaftActor extends AbstractUntypedPersistentActor { @Override protected void handleRecover(final Object message) { if (raftRecovery == null) { raftRecovery = newRaftActorRecoverySupport(); } boolean recoveryComplete = raftRecovery.handleRecoveryMessage(message, persistentProvider); if (recoveryComplete) { onRecoveryComplete(); initializeBehavior(); raftRecovery = null; } } protected  RaftActor(final String id, final Map<String, String> peerAddresses,
         final Optional<ConfigParams> configParams, final short payloadVersion); @Override void preStart(); @Override void postStop(); @Override long snapshotSequenceNr(); ActorSelection getLeader(); final DataPersistenceProvider persistence(); void setPersistence(final DataPersistenceProvider provider);  }
@Test public void testRaftActorForwardsToRaftActorRecoverySupport() { String persistenceId = factory.generateActorId("leader-"); DefaultConfigParamsImpl config = new DefaultConfigParamsImpl(); config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS)); TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.props(persistenceId, Collections.<String, String>emptyMap(), config), persistenceId); MockRaftActor mockRaftActor = mockActorRef.underlyingActor(); mockRaftActor.waitForRecoveryComplete(); RaftActorRecoverySupport mockSupport = mock(RaftActorRecoverySupport.class); mockRaftActor.setRaftActorRecoverySupport(mockSupport); Snapshot snapshot = Snapshot.create(ByteState.of(new byte[]{1}), Collections.<ReplicatedLogEntry>emptyList(), 3, 1, 3, 1, -1, null, null); SnapshotOffer snapshotOffer = new SnapshotOffer(new SnapshotMetadata("test", 6, 12345), snapshot); mockRaftActor.handleRecover(snapshotOffer); ReplicatedLogEntry logEntry = new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1", 5)); mockRaftActor.handleRecover(logEntry); ApplyJournalEntries applyJournalEntries = new ApplyJournalEntries(2); mockRaftActor.handleRecover(applyJournalEntries); DeleteEntries deleteEntries = new DeleteEntries(1); mockRaftActor.handleRecover(deleteEntries); UpdateElectionTerm updateElectionTerm = new UpdateElectionTerm(5, "member2"); mockRaftActor.handleRecover(updateElectionTerm); verify(mockSupport).handleRecoveryMessage(same(snapshotOffer), any(PersistentDataProvider.class)); verify(mockSupport).handleRecoveryMessage(same(logEntry), any(PersistentDataProvider.class)); verify(mockSupport).handleRecoveryMessage(same(applyJournalEntries), any(PersistentDataProvider.class)); verify(mockSupport).handleRecoveryMessage(same(deleteEntries), any(PersistentDataProvider.class)); verify(mockSupport).handleRecoveryMessage(same(updateElectionTerm), any(PersistentDataProvider.class)); }