ScesimModelDescriptor { public int getIndexByIdentifier(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier) { return IntStream.range(0, factMappings.size()).filter(index -> { FactMapping factMapping = factMappings.get(index); return Objects.equals(factMapping.getExpressionIdentifier(), expressionIdentifier) && Objects.equals(factMapping.getFactIdentifier(), factIdentifier); }).findFirst().orElseThrow(() -> new IllegalArgumentException( new StringBuilder().append("Impossible to find a FactMapping with factIdentifier '").append(factIdentifier.getName()) .append("' and expressionIdentifier '").append(expressionIdentifier.getName()).append("'").toString())); }  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 getIndexByIdentifierTest() { List<FactMapping> originalFactMappings = IntStream.range(0, 2).boxed() .map(i -> scesimModelDescriptor .addFactMapping(FactIdentifier.create("test " + i, String.class.getCanonicalName()), this.expressionIdentifier) ).collect(Collectors.toList()); int indexToCheck = 0; int indexRetrieved = scesimModelDescriptor.getIndexByIdentifier(originalFactMappings.get(indexToCheck).getFactIdentifier(), this.expressionIdentifier); assertEquals(indexToCheck, indexRetrieved); indexToCheck = 1; indexRetrieved = scesimModelDescriptor.getIndexByIdentifier(originalFactMappings.get(indexToCheck).getFactIdentifier(), this.expressionIdentifier); assertEquals(indexToCheck, indexRetrieved); }