Background extends AbstractScesimModel<BackgroundData> { @Override public Background cloneModel() { Background toReturn = new Background(); final List<FactMapping> originalFactMappings = this.scesimModelDescriptor.getUnmodifiableFactMappings(); for (int i = 0; i < originalFactMappings.size(); i++) { final FactMapping originalFactMapping = originalFactMappings.get(i); toReturn.scesimModelDescriptor.addFactMapping(i, originalFactMapping); } this.scesimData.forEach(scenario -> toReturn.scesimData.add(scenario.cloneInstance())); return toReturn; }  List<BackgroundDataWithIndex> getBackgroundDataWithIndex(); @Override BackgroundData addData(int index); @Override Background cloneModel();  }
@Test public void cloneModel() { final Background cloned = this.background.cloneModel(); assertNotNull(cloned); final ScesimModelDescriptor originalDescriptor = background.getScesimModelDescriptor(); final ScesimModelDescriptor clonedDescriptor = cloned.getScesimModelDescriptor(); assertEquals(originalDescriptor.getUnmodifiableFactMappings().size(), clonedDescriptor.getUnmodifiableFactMappings().size()); IntStream.range(0, originalDescriptor.getUnmodifiableFactMappings().size()).forEach(index -> { assertEquals(originalDescriptor.getUnmodifiableFactMappings().get(index), clonedDescriptor.getUnmodifiableFactMappings().get(index)); }); assertEquals(background.getUnmodifiableData().size(), cloned.getUnmodifiableData().size()); IntStream.range(0, background.getUnmodifiableData().size()).forEach(index -> { assertEquals(background.getUnmodifiableData().get(index).getDescription(), cloned.getUnmodifiableData().get(index).getDescription()); }); }