RaftActorDelegatingPersistentDataProvider extends DelegatingPersistentDataProvider { @Override public <T> void persist(final T entry, final Procedure<T> procedure) { doPersist(entry, procedure, false); } RaftActorDelegatingPersistentDataProvider(final DataPersistenceProvider delegate,
            final PersistentDataProvider persistentProvider); @Override void persist(final T entry, final Procedure<T> procedure); @Override void persistAsync(final T entry, final Procedure<T> procedure);  }
@SuppressWarnings("unchecked") @Test public void testPersistWithPersistenceEnabled() { doReturn(true).when(mockDelegateProvider).isRecoveryApplicable(); provider.persist(mockPersistentLogEntry, mockProcedure); verify(mockDelegateProvider).persist(mockPersistentLogEntry, mockProcedure); provider.persist(mockNonPersistentLogEntry, mockProcedure); verify(mockDelegateProvider).persist(mockNonPersistentLogEntry, mockProcedure); provider.persist(OTHER_DATA_OBJECT, mockProcedure); verify(mockDelegateProvider).persist(OTHER_DATA_OBJECT, mockProcedure); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testPersistWithPersistenceDisabled() throws Exception { doReturn(false).when(mockDelegateProvider).isRecoveryApplicable(); provider.persist(mockPersistentLogEntry, mockProcedure); ArgumentCaptor<Procedure> procedureCaptor = ArgumentCaptor.forClass(Procedure.class); verify(mockPersistentProvider).persist(eq(PERSISTENT_PAYLOAD), procedureCaptor.capture()); verify(mockDelegateProvider, never()).persist(mockNonPersistentLogEntry, mockProcedure); procedureCaptor.getValue().apply(PERSISTENT_PAYLOAD); verify(mockProcedure).apply(mockPersistentLogEntry); provider.persist(mockNonPersistentLogEntry, mockProcedure); verify(mockDelegateProvider).persist(mockNonPersistentLogEntry, mockProcedure); provider.persist(OTHER_DATA_OBJECT, mockProcedure); verify(mockDelegateProvider).persist(OTHER_DATA_OBJECT, mockProcedure); }