use of org.drools.workbench.models.testscenarios.shared.Fixture in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method runScenarioWithDependentImports.
@Test
public void runScenarioWithDependentImports() throws Exception {
final ArrayList<Fixture> fixtures = new ArrayList<Fixture>() {
{
add(factData("java.sql.ClientInfoStatus"));
}
};
final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {
{
put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
}
};
when(scenario.getFixtures()).thenReturn(fixtures);
when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
when(scenario.getImports()).thenReturn(new Imports());
testEditorService.addDependentImportsToScenario(scenario, path);
assertEquals(2, scenario.getImports().getImports().size());
}
use of org.drools.workbench.models.testscenarios.shared.Fixture in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method checkDependentImportsWithPrimitiveTypes.
@Test
public void checkDependentImportsWithPrimitiveTypes() throws Exception {
final ArrayList<Fixture> fixtures = new ArrayList<>();
final Imports imports = new Imports() {
{
addImport(new Import("int"));
}
};
final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {
{
put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
}
};
when(scenario.getFixtures()).thenReturn(fixtures);
when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
when(scenario.getImports()).thenCallRealMethod();
doCallRealMethod().when(scenario).setImports(any(Imports.class));
scenario.setImports(imports);
testEditorService.addDependentImportsToScenario(scenario, path);
assertEquals(1, scenario.getImports().getImports().size());
}
use of org.drools.workbench.models.testscenarios.shared.Fixture in project drools by kiegroup.
the class ScenarioRunner method applyFixtures.
private void applyFixtures(final List<Fixture> fixtures, final ScenarioSettings scenarioSettings) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InvalidClockTypeException {
for (Iterator<Fixture> iterator = fixtures.iterator(); iterator.hasNext(); ) {
Fixture fixture = iterator.next();
if (fixture instanceof FactData) {
factPopulator.add(factPopulatorFactory.createFactPopulator((FactData) fixture));
} else if (fixture instanceof RetractFact) {
factPopulator.retractFact(((RetractFact) fixture).getName());
} else if (fixture instanceof CallMethod) {
workingMemoryWrapper.executeMethod((CallMethod) fixture);
} else if (fixture instanceof ActivateRuleFlowGroup) {
workingMemoryWrapper.activateRuleFlowGroup(((ActivateRuleFlowGroup) fixture).getName());
} else if (fixture instanceof ExecutionTrace) {
factPopulator.populate();
workingMemoryWrapper.executeSubScenario((ExecutionTrace) fixture, scenarioSettings);
} else if (fixture instanceof Expectation) {
factPopulator.populate();
workingMemoryWrapper.verifyExpectation((Expectation) fixture);
} else {
throw new IllegalArgumentException("Not sure what to do with " + fixture);
}
}
factPopulator.populate();
}
use of org.drools.workbench.models.testscenarios.shared.Fixture in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method runScenarioWithDependentImportsAndWithoutFactData.
@Test
public void runScenarioWithDependentImportsAndWithoutFactData() throws Exception {
final ArrayList<Fixture> fixtures = new ArrayList<Fixture>();
final Imports imports = new Imports() {
{
addImport(new Import("java.sql.ClientInfoStatus"));
}
};
final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {
{
put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
}
};
when(scenario.getFixtures()).thenReturn(fixtures);
when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
when(scenario.getImports()).thenReturn(imports);
testEditorService.addDependentImportsToScenario(scenario, path);
assertEquals(2, scenario.getImports().getImports().size());
}
use of org.drools.workbench.models.testscenarios.shared.Fixture in project drools-wb by kiegroup.
the class DataInputWidget method renderEditor.
public void renderEditor() {
clear();
if (definitionList.size() == 0) {
parent.renderEditor();
}
// This will work out what row is for what field, adding labels and remove icons
FactDataWidgetFactory factDataWidgetFactory = new FactDataWidgetFactory(scenario, oracle, definitionList, executionTrace, this, this);
for (Fixture fixture : definitionList) {
if (fixture instanceof FactData) {
factDataWidgetFactory.build(headerText, (FactData) fixture);
}
}
getFlexCellFormatter().setHorizontalAlignment(factDataWidgetFactory.amountOrRows() + 1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
if (factDataWidgetFactory.amountOrRows() == 0) {
setWidget(1, 1, new ClickableLabel(TestScenarioConstants.INSTANCE.AddAField(), new AddFieldToFactDataClickHandler(definitionList, oracle, parent)));
}
ScenarioUtils.addBottomAndRightPaddingToTableCells(this);
}
Aggregations