@Test public void findNewIndexOfGroup() { ScesimModelDescriptor simulationDescriptorGiven = new ScesimModelDescriptor(); ExpressionIdentifier givenExpressionIdentifier = ExpressionIdentifier.create("given1", GIVEN); simulationDescriptorGiven.addFactMapping(FactIdentifier.EMPTY, givenExpressionIdentifier); assertEquals(1, dmnSimulationCreationStrategy.findNewIndexOfGroup(simulationDescriptorGiven, GIVEN)); assertEquals(1, dmnSimulationCreationStrategy.findNewIndexOfGroup(simulationDescriptorGiven, EXPECT)); ScesimModelDescriptor simulationDescriptorExpect = new ScesimModelDescriptor(); ExpressionIdentifier expectExpressionIdentifier = ExpressionIdentifier.create("expect1", EXPECT); simulationDescriptorExpect.addFactMapping(FactIdentifier.EMPTY, expectExpressionIdentifier); assertEquals(0, dmnSimulationCreationStrategy.findNewIndexOfGroup(simulationDescriptorExpect, GIVEN)); assertEquals(1, dmnSimulationCreationStrategy.findNewIndexOfGroup(simulationDescriptorExpect, EXPECT)); assertThatThrownBy(() -> dmnSimulationCreationStrategy.findNewIndexOfGroup(new ScesimModelDescriptor(), OTHER)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("This method can be invoked only with GIVEN or EXPECT as FactMappingType"); }
protected int findNewIndexOfGroup(ScesimModelDescriptor simulationDescriptor, FactMappingType factMappingType) { List<FactMapping> factMappings = simulationDescriptor.getFactMappings(); if (GIVEN.equals(factMappingType)) { for (int i = 0; i < factMappings.size(); i += 1) { if (EXPECT.equals(factMappings.get(i).getExpressionIdentifier().getType())) { return i; } } return factMappings.size(); } else if (EXPECT.equals(factMappingType)) { return factMappings.size(); } else { throw new IllegalArgumentException("This method can be invoked only with GIVEN or EXPECT as FactMappingType"); } }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { protected int findNewIndexOfGroup(ScesimModelDescriptor simulationDescriptor, FactMappingType factMappingType) { List<FactMapping> factMappings = simulationDescriptor.getFactMappings(); if (GIVEN.equals(factMappingType)) { for (int i = 0; i < factMappings.size(); i += 1) { if (EXPECT.equals(factMappings.get(i).getExpressionIdentifier().getType())) { return i; } } return factMappings.size(); } else if (EXPECT.equals(factMappingType)) { return factMappings.size(); } else { throw new IllegalArgumentException("This method can be invoked only with GIVEN or EXPECT as FactMappingType"); } } }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { protected int findNewIndexOfGroup(ScesimModelDescriptor simulationDescriptor, FactMappingType factMappingType) { List<FactMapping> factMappings = simulationDescriptor.getFactMappings(); if (GIVEN.equals(factMappingType)) { for (int i = 0; i < factMappings.size(); i += 1) { if (EXPECT.equals(factMappings.get(i).getExpressionIdentifier().getType())) { return i; } } return factMappings.size(); } else if (EXPECT.equals(factMappingType)) { return factMappings.size(); } else { throw new IllegalArgumentException("This method can be invoked only with GIVEN or EXPECT as FactMappingType"); } }  }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { protected int findNewIndexOfGroup(ScesimModelDescriptor simulationDescriptor, FactMappingType factMappingType) { List<FactMapping> factMappings = simulationDescriptor.getFactMappings(); if (GIVEN.equals(factMappingType)) { for (int i = 0; i < factMappings.size(); i += 1) { if (EXPECT.equals(factMappings.get(i).getExpressionIdentifier().getType())) { return i; } } return factMappings.size(); } else if (EXPECT.equals(factMappingType)) { return factMappings.size(); } else { throw new IllegalArgumentException("This method can be invoked only with GIVEN or EXPECT as FactMappingType"); } }  @Override Simulation createSimulation(Path context, String dmnFilePath); @Override Settings createSettings(Path context, String dmnFilePath); }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { protected int findNewIndexOfGroup(ScesimModelDescriptor simulationDescriptor, FactMappingType factMappingType) { List<FactMapping> factMappings = simulationDescriptor.getFactMappings(); if (GIVEN.equals(factMappingType)) { for (int i = 0; i < factMappings.size(); i += 1) { if (EXPECT.equals(factMappings.get(i).getExpressionIdentifier().getType())) { return i; } } return factMappings.size(); } else if (EXPECT.equals(factMappingType)) { return factMappings.size(); } else { throw new IllegalArgumentException("This method can be invoked only with GIVEN or EXPECT as FactMappingType"); } }  @Override Simulation createSimulation(Path context, String dmnFilePath); @Override Settings createSettings(Path context, String dmnFilePath);  }