Search in sources :

Example 16 with FieldData

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;
    }
}
Also used : CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData) FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) Field(org.drools.workbench.models.testscenarios.shared.Field) CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData)

Example 17 with FieldData

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();
    }
}
Also used : CollectionFieldData(org.drools.workbench.models.testscenarios.shared.CollectionFieldData) FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 18 with FieldData

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());
}
Also used : FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) FactData(org.drools.workbench.models.testscenarios.shared.FactData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 19 with FieldData

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());
}
Also used : FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) Field(org.drools.workbench.models.testscenarios.shared.Field) Import(org.kie.soup.project.datamodel.imports.Import) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) FactData(org.drools.workbench.models.testscenarios.shared.FactData) ExecutionTrace(org.drools.workbench.models.testscenarios.shared.ExecutionTrace) KieSession(org.kie.api.runtime.KieSession) VerifyFact(org.drools.workbench.models.testscenarios.shared.VerifyFact) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Example 20 with FieldData

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);
}
Also used : FieldData(org.drools.workbench.models.testscenarios.shared.FieldData) FactData(org.drools.workbench.models.testscenarios.shared.FactData) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test)

Aggregations

FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)37 FactData (org.drools.workbench.models.testscenarios.shared.FactData)29 Test (org.junit.Test)26 CollectionFieldData (org.drools.workbench.models.testscenarios.shared.CollectionFieldData)20 Field (org.drools.workbench.models.testscenarios.shared.Field)13 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)12 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)11 VerifyField (org.drools.workbench.models.testscenarios.shared.VerifyField)11 ArrayList (java.util.ArrayList)10 Import (org.kie.soup.project.datamodel.imports.Import)9 ExecutionTrace (org.drools.workbench.models.testscenarios.shared.ExecutionTrace)8 KieSession (org.kie.api.runtime.KieSession)8 ClassTypeResolver (org.kie.soup.project.datamodel.commons.types.ClassTypeResolver)8 TypeResolver (org.kie.soup.project.datamodel.commons.types.TypeResolver)8 Cheese (org.drools.workbench.models.testscenarios.backend.Cheese)7 Expectation (org.drools.workbench.models.testscenarios.shared.Expectation)5 VerifyRuleFired (org.drools.workbench.models.testscenarios.shared.VerifyRuleFired)5 HashMap (java.util.HashMap)4 UiHandler (com.google.gwt.uibinder.client.UiHandler)3 FactAssignmentField (org.drools.workbench.models.testscenarios.shared.FactAssignmentField)3