@Test public void createSimulation() throws Exception { FactModelTuple factModelTuple = getFactModelTuple(); final Path pathMock = mock(Path.class); final String dmnFilePath = "test"; doReturn(factModelTuple).when(dmnSimulationCreationStrategy).getFactModelTuple(any(), any()); final Simulation retrieved = dmnSimulationCreationStrategy.createSimulation(pathMock, dmnFilePath); assertNotNull(retrieved); verify(dmnTypeServiceMock, never()).initializeNameAndNamespace( any(Settings.class), eq(pathMock), eq(dmnFilePath)); }
@Override public Simulation createSimulation(Path context, String dmnFilePath) { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor(); simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); int inputFirstOrder = Type.INPUT.equals(aType) ? -1 : 1; return aType.equals(bType) ? 0 : inputFirstOrder; }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { @Override public Simulation createSimulation(Path context, String dmnFilePath) { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor(); simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); int inputFirstOrder = Type.INPUT.equals(aType) ? -1 : 1; return aType.equals(bType) ? 0 : inputFirstOrder; }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; } }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { @Override public Simulation createSimulation(Path context, String dmnFilePath) { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor(); simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); int inputFirstOrder = Type.INPUT.equals(aType) ? -1 : 1; return aType.equals(bType) ? 0 : inputFirstOrder; }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; }  }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { @Override public Simulation createSimulation(Path context, String dmnFilePath) { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor(); simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); int inputFirstOrder = Type.INPUT.equals(aType) ? -1 : 1; return aType.equals(bType) ? 0 : inputFirstOrder; }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; }  @Override Simulation createSimulation(Path context, String dmnFilePath); @Override Settings createSettings(Path context, String dmnFilePath); }
DMNSimulationSettingsCreationStrategy implements SimulationSettingsCreationStrategy { @Override public Simulation createSimulation(Path context, String dmnFilePath) { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor(); simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new); AtomicInteger id = new AtomicInteger(1); final Collection<FactModelTree> visibleFactTrees = factModelTuple.getVisibleFacts().values(); final Map<String, FactModelTree> hiddenValues = factModelTuple.getHiddenFacts(); visibleFactTrees.stream().sorted((a, b) -> { Type aType = a.getType(); Type bType = b.getType(); int inputFirstOrder = Type.INPUT.equals(aType) ? -1 : 1; return aType.equals(bType) ? 0 : inputFirstOrder; }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, scenarioWithIndex.getIndex(), id, convert(factModelTree.getType()), simulationDescriptor, scenarioWithIndex.getScesimData()); addFactMapping(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); addEmptyColumnsIfNeeded(toReturn, scenarioWithIndex); return toReturn; }  @Override Simulation createSimulation(Path context, String dmnFilePath); @Override Settings createSettings(Path context, String dmnFilePath);  }