Search in sources :

Example 6 with ConstraintValueEditorHelper

use of org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper in project drools-wb by kiegroup.

the class ConstraintValueEditorHelperTest method testEvents_BoundTypeIsEvent.

@Test
public void testEvents_BoundTypeIsEvent() throws Exception {
    AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, validatorInstance);
    oracle.setPackageName("org.test");
    oracle.addModelFields(new HashMap<String, ModelField[]>() {

        {
            put("org.test.Event1", new ModelField[] { modelField("this", "org.test.Event1") });
            put("org.test.Event2", new ModelField[] { modelField("this", "org.test.Event2") });
        }
    });
    oracle.addEventTypes(new HashMap<String, Boolean>() {

        {
            put("org.test.Event1", true);
            put("org.test.Event2", false);
        }
    });
    oracle.addSuperTypes(new HashMap<String, List<String>>() {

        {
            put("org.test.Event1", Collections.EMPTY_LIST);
            put("org.test.Event2", Collections.EMPTY_LIST);
        }
    });
    oracle.filter();
    FactPattern pattern1 = new FactPattern();
    pattern1.setFactType("Event1");
    pattern1.setBoundName("$e");
    SingleFieldConstraint constraint = new SingleFieldConstraint();
    constraint.setFactType("Event1");
    constraint.setFieldName("this");
    constraint.setFieldType("Event1");
    constraint.setOperator(OperatorsOracle.SIMPLE_CEP_OPERATORS[0]);
    pattern1.addConstraint(constraint);
    model.addLhsItem(pattern1);
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "Event2", "this", constraint, "Event2", new DropDownData());
    helper.isApplicableBindingsInScope("$e", new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            assertFalse(result);
        }
    });
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ConstraintValueEditorHelper(org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) List(java.util.List) Test(org.junit.Test)

Example 7 with ConstraintValueEditorHelper

use of org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper in project drools-wb by kiegroup.

the class ConstraintValueEditorHelperTest method testEvents_BothTypesAreEvents.

@Test
public void testEvents_BothTypesAreEvents() throws Exception {
    AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(serviceCaller, validatorInstance);
    oracle.setPackageName("org.test");
    oracle.addModelFields(new HashMap<String, ModelField[]>() {

        {
            put("org.test.Event1", new ModelField[] { modelField("this", "org.test.Event1") });
            put("org.test.Event2", new ModelField[] { modelField("this", "org.test.Event2") });
        }
    });
    oracle.addEventTypes(new HashMap<String, Boolean>() {

        {
            put("org.test.Event1", true);
            put("org.test.Event2", true);
        }
    });
    oracle.filter();
    FactPattern pattern1 = new FactPattern();
    pattern1.setFactType("Event1");
    pattern1.setBoundName("$e");
    SingleFieldConstraint constraint = new SingleFieldConstraint();
    constraint.setFactType("Event1");
    constraint.setFieldName("this");
    constraint.setFieldType("Event1");
    constraint.setOperator(OperatorsOracle.SIMPLE_CEP_OPERATORS[0]);
    pattern1.addConstraint(constraint);
    model.addLhsItem(pattern1);
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "Event2", "this", constraint, "Event2", new DropDownData());
    helper.isApplicableBindingsInScope("$e", new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            assertTrue(result);
        }
    });
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ConstraintValueEditorHelper(org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) AsyncPackageDataModelOracleImpl(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) Test(org.junit.Test)

Aggregations

FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)7 ConstraintValueEditorHelper (org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper)7 Test (org.junit.Test)7 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)7 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)7 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)3 AsyncPackageDataModelOracleImpl (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleImpl)3 List (java.util.List)2