Scenario extends Observable implements Runnable { public void setRepeat(boolean repeat) { this.repeat = repeat; }  @Override void run(); void appendRunnable(Consumer<ProductionSite> runnable); void addPause(int length); void startScenario(); void cancelScenario(); boolean isRunning(); void setProductionSite(ProductionSite productionSite); void setScenarioFinishedListener(Runnable listener); void setRepeat(boolean repeat);  }
@Test public void testSetRepeat() { AtomicInteger counter = new AtomicInteger(); scenario.appendRunnable(productionSite -> counter.incrementAndGet()); scenario.setProductionSite(fakeSite); scenario.setRepeat(true); scenario.startScenario(); try { sleep(1000); int state1 = counter.get(); sleep(1000); assertTrue(counter.get() > state1); } catch (InterruptedException ex) { fail("Thread.sleep failed: " + ex.getMessage()); } assertTrue(scenario.isRunning()); scenario.cancelScenario(); }