default Scenario createScenario(Simulation simulation, SimulationDescriptor simulationDescriptor) { simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX); simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION); Scenario toReturn = simulation.addScenario(); toReturn.setDescription(null); return toReturn; } }
scenarioSimulationModel.setSimulation(new RULESimulationCreationStrategy().createSimulation(this.path, "default")); Scenario scenario = scenarioSimulationModel.getSimulation().getScenarioByIndex(0); scenario.setDescription("Test Scenario"); String errorMessage = "Test Error";
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"); }
scenario1.setDescription(TEST_DESCRIPTION); scenario1.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, NAME); scenario1.addMappingValue(personFactIdentifier, firstNameExpectedExpressionIdentifier, NAME); scenario2.setDescription(TEST_DESCRIPTION); scenario2.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, NAME); scenario2.addMappingValue(personFactIdentifier, firstNameExpectedExpressionIdentifier, NAME);
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; } }
scenario1.setDescription(TEST_DESCRIPTION); scenario1.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, FEEL_EXPRESSION_NAME); firstNameExpectedValue = scenario1.addMappingValue(personFactIdentifier, firstNameExpectedExpressionIdentifier, FEEL_EXPRESSION_NAME); scenario2.setDescription(TEST_DESCRIPTION); scenario2.addMappingValue(personFactIdentifier, firstNameGivenExpressionIdentifier, FEEL_EXPRESSION_NAME); scenario2.addMappingValue(personFactIdentifier, firstNameExpectedExpressionIdentifier, FEEL_EXPRESSION_NAME);
@Test public void getDescriptionTest() { assertEquals("", scenario.getDescription()); String description = "Test Description"; scenario.addMappingValue(FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION, description); assertEquals(description, scenario.getDescription()); Scenario scenarioWithDescriptionNull = simulation.addScenario(); scenarioWithDescriptionNull.setDescription(null); assertEquals("", scenarioWithDescriptionNull.getDescription()); }
@Test public void getDescriptionTest() { assertEquals("", scenario.getDescription()); String description = "Test Description"; scenario.addMappingValue(FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION, description); assertEquals(description, scenario.getDescription()); Scenario scenarioWithDescriptionNull = simulation.addScenario(); scenarioWithDescriptionNull.setDescription(null); assertEquals("", scenarioWithDescriptionNull.getDescription()); }
scenario.setDescription(null);