### Question:
AbstractCheckPointThreshold implements CheckPointThreshold { @Override public final boolean isCheckPointingNeeded( long lastCommittedTransactionId, Consumer<String> consumer ) { if ( thresholdReached( lastCommittedTransactionId ) ) { consumer.accept( description ); return true; } return false; } AbstractCheckPointThreshold( String description ); @Override final boolean isCheckPointingNeeded( long lastCommittedTransactionId, Consumer<String> consumer );  }### Answer:
@Test public void shouldCallConsumerProvidingTheDescriptionWhenThresholdIsTrue() { String description = "description"; AbstractCheckPointThreshold threshold = new TheAbstractCheckPointThreshold( true, description ); final AtomicReference<String> calledWith = new AtomicReference<>(); threshold.isCheckPointingNeeded( 42, calledWith::set ); assertEquals( description, calledWith.get() ); }
@Test public void shouldNotCallConsumerProvidingTheDescriptionWhenThresholdIsFalse() { AbstractCheckPointThreshold threshold = new TheAbstractCheckPointThreshold( false, null ); threshold.isCheckPointingNeeded( 42, s -> { throw new IllegalStateException( "nooooooooo!" ); } ); }