Search in sources :

Example 11 with DropDownData

use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.

the class ConstraintValueEditorHelperTest method testSimplePattern.

@Test
public void testSimplePattern() throws Exception {
    AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    FactPattern pattern = new FactPattern();
    pattern.setBoundName("pp");
    pattern.setFactType("House");
    model.addLhsItem(pattern);
    FactPattern pattern2 = new FactPattern();
    SingleFieldConstraint constraint = new SingleFieldConstraint();
    constraint.setFactType("House");
    constraint.setFieldName("this");
    constraint.setFieldName("org.mortgages.House");
    pattern2.addConstraint(constraint);
    model.addLhsItem(pattern);
    when(oracle.getFieldClassName("House", "this")).thenReturn("org.mortgages.House");
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "House", "this", constraint, "House", new DropDownData());
    helper.isApplicableBindingsInScope("pp", new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            assertTrue(result);
        }
    });
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) 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) Test(org.junit.Test)

Example 12 with DropDownData

use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.

the class ConstraintValueEditorHelperTest method isEnumEquivalentSecondNull.

@Test
public void isEnumEquivalentSecondNull() throws Exception {
    final DropDownData dropDownData = mock(DropDownData.class);
    doReturn(null).when(dropDownData).getFixedList();
    Assertions.assertThat(ConstraintValueEditorHelper.isEnumEquivalent(new String[0], dropDownData)).isFalse();
}
Also used : DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Test(org.junit.Test)

Example 13 with DropDownData

use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.

the class ConstraintValueEditorHelperTest method testEvents_BoundTypeIsNotEvent.

@Test
public void testEvents_BoundTypeIsNotEvent() 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", false);
            put("org.test.Event2", true);
        }
    });
    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 14 with DropDownData

use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.

the class DTCellValueWidgetFactory method makeHasEnumsListBox.

private ListBox makeHasEnumsListBox(Pattern52 pattern, BaseColumn column, DTCellValue52 value, boolean isMultipleSelect, String factField, String factType) {
    final LimitedEntryDropDownManager.Context context = new LimitedEntryDropDownManager.Context(pattern, column);
    final Map<String, String> currentValueMap = dropDownManager.getCurrentValueMap(context);
    final DropDownData dd = oracle.getEnums(factType, factField, currentValueMap);
    // No drop-down data defined
    if (dd == null) {
        return makeListBoxForColumn(DropDownData.create(new String[0]), pattern, column, value, isMultipleSelect);
    }
    return makeListBoxForColumn(dd, pattern, column, value, isMultipleSelect);
}
Also used : DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) LimitedEntryDropDownManager(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.LimitedEntryDropDownManager)

Example 15 with DropDownData

use of org.kie.soup.project.datamodel.oracle.DropDownData in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenterTest method getEnumLookupsWithFixedListDefinition.

@Test
@SuppressWarnings("unchecked")
public void getEnumLookupsWithFixedListDefinition() {
    final DependentEnumsUtilities.Context context = mock(DependentEnumsUtilities.Context.class);
    final Callback<Map<String, String>> callback = mock(Callback.class);
    final DropDownData dd = DropDownData.create(new String[] { "one", "two" });
    when(oracle.getEnums(eq("FactType"), eq("field"), any(Map.class))).thenReturn(dd);
    dtPresenter.getEnumLookups("FactType", "field", context, callback);
    verify(callback, times(1)).callback(callbackValueCaptor.capture());
    final Map<String, String> callbackValue = callbackValueCaptor.getValue();
    assertNotNull(callbackValue);
    assertFalse(callbackValue.isEmpty());
    assertTrue(callbackValue.containsKey("one"));
    assertTrue(callbackValue.containsKey("two"));
}
Also used : DependentEnumsUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.DependentEnumsUtilities) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Map(java.util.Map) Test(org.junit.Test)

Aggregations

DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)23 Test (org.junit.Test)18 Map (java.util.Map)7 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)5 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)5 ConstraintValueEditorHelper (org.drools.workbench.screens.guided.rule.client.editor.util.ConstraintValueEditorHelper)5 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)5 Path (org.uberfire.backend.vfs.Path)5 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 DependentEnumsUtilities (org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.DependentEnumsUtilities)3 Caller (org.jboss.errai.common.client.api.Caller)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Before (org.junit.Before)3 RunWith (org.junit.runner.RunWith)3 EnumDropdownService (org.kie.workbench.common.services.shared.enums.EnumDropdownService)3 Mock (org.mockito.Mock)3 Mockito.any (org.mockito.Mockito.any)3