public void testSubsequentPooledLoOptimizerUsage() {
// test the pooled optimizer in situation where the sequence is already beyond its initial value on init.
// cheat by telling the sequence to start with 1000
final SourceMock sequence = new SourceMock( 1001, 3, 5 );
// but tell the optimizer the start-with is 1
final Optimizer optimizer = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL, Long.class, 3, 1 );
assertEquals( 5, sequence.getTimesCalled() );
assertEquals( 1001, sequence.getCurrentValue() );
Long next = ( Long ) optimizer.generate( sequence );
assertEquals( (1001), next.intValue() );
assertEquals( (5+1), sequence.getTimesCalled() );
assertEquals( (1001+3), sequence.getCurrentValue() );
next = ( Long ) optimizer.generate( sequence );
assertEquals( (1001+1), next.intValue() );
assertEquals( (5+1), sequence.getTimesCalled() );
assertEquals( (1001+3), sequence.getCurrentValue() );
next = ( Long ) optimizer.generate( sequence );
assertEquals( (1001+2), next.intValue() );
assertEquals( (5+1), sequence.getTimesCalled() );
assertEquals( (1001+3), sequence.getCurrentValue() );
// // force a "clock over"
next = ( Long ) optimizer.generate( sequence );
assertEquals( (1001+3), next.intValue() );
assertEquals( (5+2), sequence.getTimesCalled() );
assertEquals( (1001+6), sequence.getCurrentValue() );
}