use of org.drools.workbench.models.testscenarios.shared.FieldData in project drools-wb by kiegroup.
the class FieldConstraintHelper method replaceFieldWith.
public void replaceFieldWith(final Field newField) {
for (Field factsField : fact.getFieldData()) {
if (factsField instanceof CollectionFieldData) {
CollectionFieldData fData = (CollectionFieldData) factsField;
List<FieldData> list = fData.getCollectionFieldList();
boolean aNewItem = true;
for (FieldData aField : list) {
if (aField.getNature() == 0) {
aNewItem = false;
aField.setNature(((FieldData) newField).getNature());
}
}
if (aNewItem && list.contains(field)) {
list.set(list.indexOf(field), (FieldData) newField);
}
}
}
if (fact.getFieldData().contains(field)) {
fact.getFieldData().set(fact.getFieldData().indexOf(field), newField);
field = newField;
}
}
use of org.drools.workbench.models.testscenarios.shared.FieldData in project drools-wb by kiegroup.
the class ListEditorRow method suffleDown.
@UiHandler("suffleDown")
public void suffleDown(final ClickEvent event) {
if (index < parentField.getCollectionFieldList().size() - 1) {
FieldData onMyLine = parentField.getCollectionFieldList().get(index);
FieldData onDown = parentField.getCollectionFieldList().get(index + 1);
parentField.getCollectionFieldList().set(index + 1, onMyLine);
parentField.getCollectionFieldList().set(index, onDown);
parent.renderEditor();
}
}
use of org.drools.workbench.models.testscenarios.shared.FieldData 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.FieldData 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());
}
use of org.drools.workbench.models.testscenarios.shared.FieldData in project drools by kiegroup.
the class ScenarioRunnerTest method testVerifyFactsWithEnumWildCardImport.
@Test
public void testVerifyFactsWithEnumWildCardImport() throws Exception {
FieldData cheeseType = new FieldData("cheeseType", "CheeseType.CHEDDAR");
cheeseType.setNature(FieldData.TYPE_ENUM);
FactData f1 = new FactData("Cheese", "f1", Arrays.<Field>asList(cheeseType), false);
Scenario scenario = new Scenario();
scenario.setPackageName("org.drools.workbench.models.testscenarios.backend");
scenario.getFixtures().add(f1);
ScenarioRunner runner = new ScenarioRunner(ksession);
runner.run(scenario);
}
Aggregations