Simulation extends AbstractScesimModel<Scenario> { @Override public Scenario addData(int index) { if (index < 0 || index > scesimData.size()) { throw new IndexOutOfBoundsException(new StringBuilder().append("Index out of range ").append(index).toString()); } Scenario scenario = new Scenario(); scesimData.add(index, scenario); return scenario; }  List<ScenarioWithIndex> getScenarioWithIndex(); @Override Scenario addData(int index); @Override Simulation cloneModel();  }
@Test public void addData() { simulation.addData(1); assertThatThrownBy(() -> simulation.addData(-1)) .isInstanceOf(IndexOutOfBoundsException.class); assertThatThrownBy(() -> simulation.addData(3)) .isInstanceOf(IndexOutOfBoundsException.class); }