### Question:
FreeIdFilteredIdGenerator extends IdGenerator.Delegate { @Override public void freeId( long id ) { if ( freeIdCondition.getAsBoolean() ) { super.freeId( id ); } } FreeIdFilteredIdGenerator( IdGenerator delegate, BooleanSupplier freeIdCondition ); @Override void freeId( long id );  }### Answer:
@Test public void freeIdIfConditionSatisfied() { FreeIdFilteredIdGenerator generator = createFilteredIdGenerator( idGenerator, () -> true ); generator.freeId( 1 ); verify( idGenerator ).freeId( 1 ); }
@Test public void skipFreeIdIfConditionIsNotSatisfied() { FreeIdFilteredIdGenerator generator = createFilteredIdGenerator( idGenerator, () -> false ); generator.freeId( 1 ); verifyZeroInteractions( idGenerator ); }
@Test public void freeIdOnlyWhenConditionSatisfied() { MutableBoolean condition = new MutableBoolean(); FreeIdFilteredIdGenerator generator = createFilteredIdGenerator( idGenerator, condition::booleanValue ); generator.freeId( 1 ); condition.setTrue(); generator.freeId( 2 ); verify( idGenerator ).freeId( 2 ); }