@SuppressWarnings("unchecked")
@Test
public void testApplyJournalEntriesCallsDataPersistence() throws Exception {

    String persistenceId = factory.generateActorId("leader-");
    DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
    config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
    DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
    TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
            Collections.<String, String>emptyMap(), config, dataPersistenceProvider), persistenceId);
    MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
    mockRaftActor.waitForInitializeBehaviorComplete();
    mockRaftActor.waitUntilLeader();
    mockRaftActor.handleCommand(new ApplyJournalEntries(10));
    verify(dataPersistenceProvider).persistAsync(any(ApplyJournalEntries.class), any(Procedure.class));
}