AtomicInput implements Input, ActivityDefObserver, ProgressCapable { @Override public CycleSegment getInputSegment(int stride) { while (true) { long current = this.cycleValue.get(); long next = current + stride; if (next > max.get()) { if (recycleValue.get()>=recycleMax.get()) { logger.debug("Exhausted input for " + activityDef.getAlias() + " at " + current + ", recycle count " + recycleValue.get()); return null; } else { if (cycleValue.compareAndSet(current,min.get()+stride)) { recycleValue.getAndIncrement(); logger.trace("recycling input for " + activityDef.getAlias() + " recycle:" + recycleValue.get()); return new InputInterval.Segment(min.get(), min.get()+stride); } } } if (cycleValue.compareAndSet(current, next)) { return new InputInterval.Segment(current, next); } } } AtomicInput(ActivityDef activityDef); @Override CycleSegment getInputSegment(int stride); @Override double getProgress(); @Override double getTotal(); @Override String getProgressDetails(); @Override String toString(); @Override void onActivityDefUpdate(ActivityDef activityDef); @Override boolean isContiguous();  }
@Test public void testEmptyIntervalShouldNotProvideValues() { AtomicInput i = new AtomicInput(ActivityDef.parseActivityDef("alias=foo,cycles=23..23")); CycleSegment inputSegment = i.getInputSegment(1); assertThat(inputSegment).isNull(); }