ScesimModelDescriptor { public void moveFactMapping(int oldIndex, int newIndex) { if (oldIndex < 0 || oldIndex >= factMappings.size()) { throw new IndexOutOfBoundsException(new StringBuilder().append("Index ").append(oldIndex) .append(" not found in the list").toString()); } if (newIndex < 0 || newIndex >= factMappings.size()) { throw new IndexOutOfBoundsException(new StringBuilder().append("Index ").append(newIndex) .append(" out of range").toString()); } FactMapping factMapping = factMappings.get(oldIndex); factMappings.remove(oldIndex); factMappings.add(newIndex, factMapping); }  List<FactMapping> getUnmodifiableFactMappings(); Set<FactIdentifier> getFactIdentifiers(); List<FactMapping> getFactMappings(); void moveFactMapping(int oldIndex, int newIndex); FactMapping getFactMappingByIndex(int index); int getIndexByIdentifier(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier); List<FactMapping> getFactMappingsByFactName(String factName); Optional<FactMapping> getFactMapping(FactIdentifier factIdentifier, ExpressionIdentifier ei); FactMapping addFactMapping(int index, FactMapping toClone); FactMapping addFactMapping(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier); FactMapping addFactMapping(String factAlias, FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier); FactMapping addFactMapping(int index, FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier); FactMapping addFactMapping(int index, String factAlias, FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier); void clear();  }
@Test public void moveFactMappingTest() { ExpressionIdentifier expressionIdentifier2 = ExpressionIdentifier.create("Test expression 2", FactMappingType.GIVEN); ExpressionIdentifier expressionIdentifier3 = ExpressionIdentifier.create("Test expression 3", FactMappingType.GIVEN); FactMapping factMapping1 = scesimModelDescriptor.addFactMapping(factIdentifier, expressionIdentifier); FactMapping factMapping2 = scesimModelDescriptor.addFactMapping(factIdentifier, expressionIdentifier2); FactMapping factMapping3 = scesimModelDescriptor.addFactMapping(factIdentifier, expressionIdentifier3); List<FactMapping> factMappings = scesimModelDescriptor.getUnmodifiableFactMappings(); assertEquals(factMappings.get(0), factMapping1); assertEquals(factMappings.get(1), factMapping2); assertEquals(factMappings.get(2), factMapping3); scesimModelDescriptor.moveFactMapping(0, 1); factMappings = scesimModelDescriptor.getUnmodifiableFactMappings(); assertEquals(factMappings.get(0), factMapping2); assertEquals(factMappings.get(1), factMapping1); assertEquals(factMappings.get(2), factMapping3); scesimModelDescriptor.moveFactMapping(2, 1); factMappings = scesimModelDescriptor.getUnmodifiableFactMappings(); assertEquals(factMappings.get(0), factMapping2); assertEquals(factMappings.get(1), factMapping3); assertEquals(factMappings.get(2), factMapping1); scesimModelDescriptor.moveFactMapping(2, 2); factMappings = scesimModelDescriptor.getUnmodifiableFactMappings(); assertEquals(factMappings.get(0), factMapping2); assertEquals(factMappings.get(1), factMapping3); assertEquals(factMappings.get(2), factMapping1); }