+ public void testPersistWhenReplicatedLogSizeExceedsSnapshotBatchCount() {
+ doReturn(10L).when(mockReplicatedLog).size(); // matches snapshotBatchCount
+ doReturn(100).when(mockReplicatedLog).dataSize();
+
+ doReturn(5L).when(mockReplicatedLog).getSnapshotIndex();
+ doReturn(5L).when(mockReplicatedLog).getSnapshotTerm();
+
+ long replicatedToAllIndex = 1;
+ ReplicatedLogEntry replicatedLogEntry = mock(ReplicatedLogEntry.class);
+ doReturn(replicatedLogEntry).when(mockReplicatedLog).get(replicatedToAllIndex);
+ doReturn(6L).when(replicatedLogEntry).getTerm();
+ doReturn(replicatedToAllIndex).when(replicatedLogEntry).getIndex();
+
+ snapshotManager.capture(new SimpleReplicatedLogEntry(9, 6,
+ new MockRaftActorContext.MockPayload()), replicatedToAllIndex);
+
+ snapshotManager.persist(ByteState.empty(), Optional.empty(), 2000000L);
+
+ verify(mockDataPersistenceProvider).saveSnapshot(any(Snapshot.class));
+
+ verify(mockReplicatedLog).snapshotPreCommit(9L, 6L);
+
+ verify(mockRaftActorBehavior).setReplicatedToAllIndex(replicatedToAllIndex);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testPersistSendInstallSnapshot() throws Exception {