public Simulation cloneSimulation() { Simulation toReturn = new Simulation(); toReturn.getSimulationDescriptor().setType(simulationDescriptor.getType()); toReturn.getSimulationDescriptor().setDmnFilePath(simulationDescriptor.getDmnFilePath()); toReturn.getSimulationDescriptor().setDmoSession(simulationDescriptor.getDmoSession()); final List<FactMapping> originalFactMappings = this.simulationDescriptor.getUnmodifiableFactMappings(); for (int i = 0; i < originalFactMappings.size(); i++) { final FactMapping originalFactMapping = originalFactMappings.get(i); toReturn.simulationDescriptor.addFactMapping(i, originalFactMapping); } this.scenarios.forEach(scenario -> toReturn.scenarios.add(scenario.cloneScenario())); return toReturn; }
public Simulation cloneSimulation() { Simulation toReturn = new Simulation(); toReturn.getSimulationDescriptor().setType(simulationDescriptor.getType()); toReturn.getSimulationDescriptor().setDmnFilePath(simulationDescriptor.getDmnFilePath()); toReturn.getSimulationDescriptor().setDmoSession(simulationDescriptor.getDmoSession()); final List<FactMapping> originalFactMappings = this.simulationDescriptor.getUnmodifiableFactMappings(); for (int i = 0; i < originalFactMappings.size(); i++) { final FactMapping originalFactMapping = originalFactMappings.get(i); toReturn.simulationDescriptor.addFactMapping(i, originalFactMapping); } this.scenarios.forEach(scenario -> toReturn.scenarios.add(scenario.cloneScenario())); return toReturn; }
@Before public void setup() throws Exception { Set<Package> packages = new HashSet<>(); packages.add(new Package(path, path, path, path, path, "Test", "", "")); when(kieModuleService.resolveModule(any())).thenReturn(module); when(kieModuleService.resolvePackages(any(KieModule.class))).thenReturn(packages); when(ioService.exists(activatorPath)).thenReturn(false); when(kieModuleService.resolveModule(any())).thenReturn(module); when(module.getPom()).thenReturn(projectPom); when(projectPom.getGav()).thenReturn(gav); when(gav.getGroupId()).thenReturn("Test"); when(projectPom.getDependencies()).thenReturn(dependencies); when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false); when(mockedPackage.getPackageTestSrcPath()).thenReturn(path); when(scenarioSimulationBuilderMock.createSimulation(any(), any(), any())).thenReturn(new Simulation()); service.scenarioSimulationBuilder = scenarioSimulationBuilderMock; }
@Override public Simulation createSimulation(Path context, String dmnFilePath) throws Exception { final FactModelTuple factModelTuple = getFactModelTuple(context, dmnFilePath); Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); simulationDescriptor.setType(ScenarioSimulationModel.Type.DMN); simulationDescriptor.setDmnFilePath(dmnFilePath); Scenario scenario = createScenario(toReturn, simulationDescriptor); int row = toReturn.getUnmodifiableScenarios().indexOf(scenario); 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(); return aType.equals(bType) ? 0 : (Type.INPUT.equals(aType) ? -1 : 1); }).forEach(factModelTree -> { FactIdentifier factIdentifier = new FactIdentifier(factModelTree.getFactName(), factModelTree.getFactName()); FactMappingExtractor factMappingExtractor = new FactMappingExtractor(factIdentifier, row, id, convert(factModelTree.getType()), simulationDescriptor, scenario); addToScenario(factMappingExtractor, factModelTree, new ArrayList<>(), hiddenValues); }); return toReturn; }
@Before public void init() { simulation = new Simulation(); simulationDescriptor = simulation.getSimulationDescriptor(); scenario = simulation.addScenario(); factIdentifier = FactIdentifier.create("test fact", String.class.getCanonicalName()); expressionIdentifier = ExpressionIdentifier.create("test expression", FactMappingType.EXPECT); }
@Before public void init() { simulation = new Simulation(); simulationDescriptor = simulation.getSimulationDescriptor(); scenario = simulation.addScenario(); factIdentifier = FactIdentifier.create("test fact", String.class.getCanonicalName()); expressionIdentifier = ExpressionIdentifier.create("test expression", FactMappingType.EXPECT); }
@Test public void getSpecificRunnerProvider() { Simulation simulation = new Simulation(); // all existing types should have a dedicated runner for (ScenarioSimulationModel.Type value : ScenarioSimulationModel.Type.values()) { simulation.getSimulationDescriptor().setType(value); AbstractScenarioRunner.getSpecificRunnerProvider(simulation); } } }
public static Simulation getSimulation(int numberOfColumns, int numberOfRows) { Simulation simulation = new Simulation(); SimulationDescriptor simulationDescriptor = simulation.getSimulationDescriptor(); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); // generate simulationDescriptor IntStream.range(0, numberOfColumns).forEach(columnIndex -> { simulationDescriptor.addFactMapping(FactIdentifier.create(getFactName(columnIndex), String.class.getCanonicalName()), ExpressionIdentifier.create(getColName(columnIndex), FactMappingType.EXPECT) ); }); // generate scenarios IntStream.range(0, numberOfRows).forEach(rowIndex -> { final Scenario scenario = simulation.addScenario(); scenario.setDescription(getRowName(rowIndex)); IntStream.range(0, numberOfColumns).forEach( columnIndex -> { scenario.addMappingValue(FactIdentifier.create(getFactName(columnIndex), String.class.getCanonicalName()), ExpressionIdentifier.create(getColName(columnIndex), FactMappingType.EXPECT), getCellValue(columnIndex, rowIndex)); }); }); return simulation; }
@Before public void setup() { simulation = new Simulation(); FactIdentifier factIdentifier = FactIdentifier.create("Test", String.class.getCanonicalName()); ExpressionIdentifier expressionIdentifier = ExpressionIdentifier.create("Test", FactMappingType.GIVEN); simulation.getSimulationDescriptor().addFactMapping(factIdentifier, expressionIdentifier); originalScenario = simulation.addScenario(); originalScenario.setDescription("Test Description"); originalScenario.addMappingValue(factIdentifier, expressionIdentifier, "TEST"); }
@Before public void setup() { simulation = new Simulation(); FactIdentifier factIdentifier = FactIdentifier.create("Test", String.class.getCanonicalName()); ExpressionIdentifier expressionIdentifier = ExpressionIdentifier.create("Test", FactMappingType.GIVEN); simulation.getSimulationDescriptor().addFactMapping(factIdentifier, expressionIdentifier); originalScenario = simulation.addScenario(); originalScenario.setDescription("Test Description"); originalScenario.addMappingValue(factIdentifier, expressionIdentifier, "TEST"); }
@Override public Simulation createSimulation(Path context, String value) throws Exception { Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); simulationDescriptor.setType(ScenarioSimulationModel.Type.RULE); simulationDescriptor.setDmoSession(value); Scenario scenario = createScenario(toReturn, simulationDescriptor); int row = toReturn.getUnmodifiableScenarios().indexOf(scenario); // Add GIVEN Fact int id = 1; ExpressionIdentifier givenExpression = ExpressionIdentifier.create(row + "|" + id, FactMappingType.GIVEN); final FactMapping givenFactMapping = simulationDescriptor.addFactMapping(FactMapping.getInstancePlaceHolder(id), FactIdentifier.EMPTY, givenExpression); givenFactMapping.setExpressionAlias(FactMapping.getPropertyPlaceHolder(id)); scenario.addMappingValue(FactIdentifier.EMPTY, givenExpression, null); // Add EXPECT Fact id = 2; ExpressionIdentifier expectedExpression = ExpressionIdentifier.create(row + "|" + id, FactMappingType.EXPECT); final FactMapping expectedFactMapping = simulationDescriptor.addFactMapping(FactMapping.getInstancePlaceHolder(id), FactIdentifier.EMPTY, expectedExpression); expectedFactMapping.setExpressionAlias(FactMapping.getPropertyPlaceHolder(id)); scenario.addMappingValue(FactIdentifier.EMPTY, expectedExpression, null); return toReturn; } }
private Simulation getSimulation() { Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); simulationDescriptor.setType(ScenarioSimulationModel.Type.RULE); simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); Scenario scenario = toReturn.addScenario(); int row = toReturn.getUnmodifiableScenarios().indexOf(scenario); scenario.setDescription(null); // Add GIVEN Facts IntStream.range(2, 4).forEach(id -> { ExpressionIdentifier givenExpression = ExpressionIdentifier.create(row + "|" + id, FactMappingType.GIVEN); simulationDescriptor.addFactMapping(FactMapping.getInstancePlaceHolder(id), FactIdentifier.EMPTY, givenExpression); scenario.addMappingValue(FactIdentifier.EMPTY, givenExpression, null); }); // Add EXPECT Facts IntStream.range(2, 4).forEach(id -> { id += 2; // This is to have consistent labels/names even when adding columns at runtime ExpressionIdentifier expectedExpression = ExpressionIdentifier.create(row + "|" + id, FactMappingType.EXPECT); simulationDescriptor.addFactMapping(FactMapping.getInstancePlaceHolder(id), FactIdentifier.EMPTY, expectedExpression); scenario.addMappingValue(FactIdentifier.EMPTY, expectedExpression, null); }); return toReturn; } }
@Before public void setup() { simulation = new Simulation(); personFactIdentifier = FactIdentifier.create("Fact 1", Person.class.getCanonicalName()); firstNameGivenExpressionIdentifier = ExpressionIdentifier.create("First Name Given", FactMappingType.GIVEN);
@Before public void init() { simulation = new Simulation(); personFactIdentifier = FactIdentifier.create("Fact 1", Person.class.getCanonicalName()); firstNameGivenExpressionIdentifier = ExpressionIdentifier.create("First Name Given", FactMappingType.GIVEN);
protected Simulation getSimulation(ScenarioSimulationModel.Type selectedType, String value) { Simulation toReturn = new Simulation(); SimulationDescriptor simulationDescriptor = toReturn.getSimulationDescriptor(); simulationDescriptor.setType(selectedType);