use of org.drools.scenariosimulation.api.model.Scenario in project drools-wb by kiegroup.
the class ScenarioSimulationEditorPresenterTest method cleanReadOnlyColumn.
@Test
public void cleanReadOnlyColumn() {
Simulation simulation = new Simulation();
ScesimModelDescriptor simulationDescriptor = simulation.getScesimModelDescriptor();
FactMapping test1 = simulationDescriptor.addFactMapping(FactIdentifier.create("test1", String.class.getCanonicalName()), ExpressionIdentifier.create("", FactMappingType.GIVEN));
FactMapping test2 = simulationDescriptor.addFactMapping(FactIdentifier.create("test2", String.class.getCanonicalName()), ExpressionIdentifier.create("", FactMappingType.GIVEN));
test1.addExpressionElement("test", String.class.getCanonicalName());
Scenario scenario = simulation.addData();
scenario.addMappingValue(test1.getFactIdentifier(), test1.getExpressionIdentifier(), LOWER_CASE_VALUE);
scenario.addMappingValue(test2.getFactIdentifier(), test2.getExpressionIdentifier(), LOWER_CASE_VALUE);
presenterSpy.cleanReadOnlyColumn(simulation);
assertNotNull(scenario.getFactMappingValue(test1.getFactIdentifier(), test1.getExpressionIdentifier()).get().getRawValue());
assertNull(scenario.getFactMappingValue(test2.getFactIdentifier(), test2.getExpressionIdentifier()).get().getRawValue());
}
use of org.drools.scenariosimulation.api.model.Scenario in project drools-wb by kiegroup.
the class ScenarioCsvImportExportTest method createDummySimulation.
private Simulation createDummySimulation(int numberOfColumn, int numberOfRow) {
Simulation simulation = new Simulation();
ScesimModelDescriptor simulationDescriptor = simulation.getScesimModelDescriptor();
simulationDescriptor.addFactMapping(FactIdentifier.INDEX, ExpressionIdentifier.INDEX).setExpressionAlias("Index");
simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION).setExpressionAlias("Description");
for (int col = 0; col < numberOfColumn; col += 1) {
createFactMapping(simulationDescriptor, col);
}
for (int row = 0; row < numberOfRow; row += 1) {
Scenario scenario = simulation.addData();
scenario.addMappingValue(FactIdentifier.INDEX, ExpressionIdentifier.INDEX, row);
scenario.setDescription("My scenario " + row);
for (int col = 2; col < numberOfColumn + 2; col += 1) {
FactMapping factMappingByIndex = simulationDescriptor.getFactMappingByIndex(col);
scenario.addMappingValue(factMappingByIndex.getFactIdentifier(), factMappingByIndex.getExpressionIdentifier(), "value_" + row + "_" + (col - 2));
}
}
return simulation;
}
use of org.drools.scenariosimulation.api.model.Scenario in project drools-wb by kiegroup.
the class TestUtils method getSimulation.
public static Simulation getSimulation(int numberOfColumns, int numberOfRows) {
Simulation simulation = new Simulation();
ScesimModelDescriptor simulationDescriptor = simulation.getScesimModelDescriptor();
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.addData();
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;
}
use of org.drools.scenariosimulation.api.model.Scenario in project drools-wb by kiegroup.
the class CoverageScenarioListPresenterTest method commonAddScesimDataGroup.
private void commonAddScesimDataGroup(ScenarioSimulationModel.Type type, int scenarioIndex, String scenarioDescription, String expectedLabel) {
Scenario scenario = new Scenario();
scenario.setDescription(scenarioDescription);
ScenarioWithIndex scenarioWithIndex = new ScenarioWithIndex(scenarioIndex, scenario);
Map<String, Integer> resultCounter = new HashMap<>();
coverageScenarioListPresenterSpy.addScesimDataGroup(scenarioWithIndex, resultCounter, type);
verify(viewsProviderMock, times(1)).getCoverageScenarioListView();
verify(coverageScenarioListViewMock, times(1)).setPresenter(eq(coverageScenarioListPresenterSpy));
verify(coverageScenarioListViewMock, times(1)).setVisible(eq(false));
verify(coverageScenarioListViewMock, times(1)).getScenarioElement();
verify(coverageScenarioListViewMock, times(1)).setItemLabel(eq(expectedLabel));
verify(scenarioElementMock, times(1)).appendChild(isA(HTMLUListElement.class));
}
Aggregations