use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class TestScenarioFactory method makeTestScenarioWithoutVerifyFact.
public static Scenario makeTestScenarioWithoutVerifyFact(final String packageName, final Collection<Import> imports, final String name) {
final Scenario model = new Scenario();
model.getImports().getImports().addAll(imports);
model.setPackageName(packageName);
model.setName(name);
model.getFixtures().add(new FactData("Applicant", "$a", new ArrayList<Field>() {
{
add(new FieldData("age", "33"));
}
}, false));
return model;
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools-wb by kiegroup.
the class MethodParameterCallValueEditor method showTypeChoice.
protected void showTypeChoice(final Widget w) {
final FormStylePopup form = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.FieldValue());
Button lit = new Button(TestScenarioConstants.INSTANCE.LiteralValue());
lit.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.nature = FieldData.TYPE_LITERAL;
methodParameter.value = " ";
refresh();
form.hide();
}
});
form.addAttribute(TestScenarioConstants.INSTANCE.LiteralValue() + ":", widgets(lit, new InfoPopup(TestScenarioConstants.INSTANCE.Literal(), TestScenarioConstants.INSTANCE.LiteralValTip())));
form.addRow(new HTML("<hr/>"));
form.addRow(new SmallLabel(TestScenarioConstants.INSTANCE.AdvancedSection()));
/*
* If there is a bound variable that is the same type of the current
* variable type, then show a button
*/
List<String> vars = model.getFactNamesInScope(ex, true);
for (String v : vars) {
boolean createButton = false;
Button variable = new Button(TestScenarioConstants.INSTANCE.BoundVariable());
FactData factData = (FactData) model.getFactTypes().get(v);
if (factData.getType().equals(this.parameterType)) {
createButton = true;
}
if (createButton == true) {
form.addAttribute(TestScenarioConstants.INSTANCE.BoundVariable() + ":", variable);
variable.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
methodParameter.nature = FieldData.TYPE_VARIABLE;
methodParameter.value = "=";
refresh();
form.hide();
}
});
break;
}
}
form.show();
}
use of org.drools.workbench.models.testscenarios.shared.FactData 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.FactData in project drools by kiegroup.
the class FactDataTest method testAdd.
@Test
public void testAdd() {
FactData fd = new FactData("x", "y", new ArrayList(), false);
assertEquals(0, fd.getFieldData().size());
fd.getFieldData().add(new FieldData("x", "y"));
assertEquals(1, fd.getFieldData().size());
fd.getFieldData().add(new FieldData("q", "x"));
assertEquals(2, fd.getFieldData().size());
}
use of org.drools.workbench.models.testscenarios.shared.FactData in project drools by kiegroup.
the class ScenarioRunnerTest method testIntegrationWithModify.
@Test
public void testIntegrationWithModify() throws Exception {
Scenario sc = new Scenario();
sc.getImports().addImport(new Import("org.drools.workbench.models.testscenarios.backend.Cheese"));
sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "1")), false));
sc.getFixtures().add(new ExecutionTrace());
sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule1", "=="))));
sc.getFixtures().add(new FactData("Cheese", "c1", Arrays.<Field>asList(new FieldData("price", "42")), true));
sc.getFixtures().add(new ExecutionTrace());
sc.getFixtures().add(new VerifyFact("c1", ls(new VerifyField("type", "rule3", "=="))));
KieSession ksession = getKieSession("test_stateful.drl");
ScenarioRunner run = new ScenarioRunner(ksession);
run.run(sc);
assertTrue(sc.wasSuccessful());
}
Aggregations