Search in sources :

Example 31 with DropDownData

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

the class CallMethodWidget method valueEditor.

private Widget valueEditor(final CallFieldValue val) {
    String type = "";
    if (oracle.isGlobalVariable(this.mCall.getVariable())) {
        type = oracle.getGlobalVariable(this.mCall.getVariable());
    } else {
        Map<String, String> mFactTypes = scenario.getVariableTypes();
        type = mFactTypes.get(this.mCall.getVariable());
    }
    DropDownData enums = oracle.getEnums(type, val.field, this.mCall.getCallFieldValuesMap());
    return new MethodParameterCallValueEditor(val, enums, executionTrace, scenario, val.type, oracle);
}
Also used : DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData)

Example 32 with DropDownData

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

the class EnumLoaderUtilitiesTest method checkEmptyDefinition.

@Test
public void checkEmptyDefinition() {
    final Callback<Map<String, String>> callback = (result) -> assertTrue(result.isEmpty());
    enumLoaderUtilities.getEnums(new DropDownData(), callback, presenter, onFetchCommand, onFetchCompleteCommand);
    assertNoInteractions();
}
Also used : GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) EnumDropdownService(org.kie.workbench.common.services.shared.enums.EnumDropdownService) CallerMock(org.uberfire.mocks.CallerMock) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.spy(org.mockito.Mockito.spy) Mockito.verify(org.mockito.Mockito.verify) Mockito.never(org.mockito.Mockito.never) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Callback(org.uberfire.client.callbacks.Callback) Assert.assertFalse(org.junit.Assert.assertFalse) Map(java.util.Map) Caller(org.jboss.errai.common.client.api.Caller) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Mockito.any(org.mockito.Mockito.any) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Path(org.uberfire.backend.vfs.Path) Command(org.uberfire.mvp.Command) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Map(java.util.Map) Test(org.junit.Test)

Example 33 with DropDownData

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

the class ConstraintValueEditorHelperTest method testSimpleField.

@Test
public void testSimpleField() throws Exception {
    AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    FactPattern pattern = new FactPattern();
    SingleFieldConstraint constraint = new SingleFieldConstraint();
    constraint.setFieldBinding("pp");
    constraint.setFactType("House");
    constraint.setFieldName("parent");
    constraint.setFieldType("org.mortgages.Parent");
    pattern.addConstraint(constraint);
    model.addLhsItem(pattern);
    when(oracle.getFieldClassName("House", "parent")).thenReturn("org.mortgages.Parent");
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "House", "parent", constraint, "Parent", 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 34 with DropDownData

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

the class ConstraintValueEditorHelperTest method testBoundFieldOfDifferentType.

@Test
public void testBoundFieldOfDifferentType() throws Exception {
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final FactPattern pattern = new FactPattern();
    final SingleFieldConstraint isFinished = new SingleFieldConstraint();
    isFinished.setFieldBinding("$finished");
    isFinished.setFactType("House");
    isFinished.setFieldName("finished");
    isFinished.setFieldType("java.time.LocalDate");
    isFinished.setOperator("!= null");
    pattern.addConstraint(isFinished);
    model.addLhsItem(pattern);
    final SingleFieldConstraint isFinishedAfter = new SingleFieldConstraint();
    isFinishedAfter.setFactType("House");
    isFinishedAfter.setFieldName("cost");
    isFinishedAfter.setFieldType("java.util.BigDecimal");
    isFinishedAfter.setOperator("==");
    pattern.addConstraint(isFinishedAfter);
    model.addLhsItem(pattern);
    when(oracle.getFieldClassName("House", "finished")).thenReturn("java.time.LocalDate");
    when(oracle.getFieldClassName("House", "cost")).thenReturn("java.util.BigDecimal");
    ConstraintValueEditorHelper helper = new ConstraintValueEditorHelper(model, oracle, "House", "cost", isFinished, "LocalDate", new DropDownData());
    helper.isApplicableBindingsInScope("$finished", result -> assertFalse(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 35 with DropDownData

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

the class ConstraintValueEditorHelperTest method isEnumEquivalentNullDropDownData.

@Test
public void isEnumEquivalentNullDropDownData() throws Exception {
    final DropDownData dropDownData = null;
    Assertions.assertThat(ConstraintValueEditorHelper.isEnumEquivalent(new String[] { "a", "b", "c" }, dropDownData)).isFalse();
}
Also used : DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) Test(org.junit.Test)

Aggregations

DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)40 Test (org.junit.Test)31 Path (org.uberfire.backend.vfs.Path)13 Map (java.util.Map)9 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 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)7 ListBox (org.gwtbootstrap3.client.ui.ListBox)6 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)4 HashMap (java.util.HashMap)3 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