Search in sources :

Example 16 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class ConditionColumnPluginTest method testIsFieldBindingValidWhenPluginBindingAndFactPatternBoundNameHaveTheSameValue.

@Test
public void testIsFieldBindingValidWhenPluginBindingAndFactPatternBoundNameHaveTheSameValue() {
    final PatternWrapper patternWrapper = mock(PatternWrapper.class);
    final FactPattern factPattern = new FactPattern() {

        {
            setBoundName("$fact");
        }
    };
    doReturn(BaseSingleFieldConstraint.TYPE_LITERAL).when(plugin).constraintValue();
    doReturn(factPattern).when(patternWrapper).makeFactPattern();
    doReturn(patternWrapper).when(plugin).patternWrapper();
    doReturn("$fact").when(plugin).getBinding();
    assertFalse(plugin.isFieldBindingValid());
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) Test(org.junit.Test)

Example 17 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class ConditionColumnPluginTest method testSetValueList.

@Test
public void testSetValueList() throws Exception {
    final String valueList = "valueList";
    final DTCellValue52 cellValue52 = mock(DTCellValue52.class);
    final PatternWrapper pattern = mock(PatternWrapper.class);
    final DataType.DataTypes dataTypes = DataType.DataTypes.STRING;
    plugin.setupDefaultValues();
    doReturn("FactType").when(pattern).getFactType();
    doReturn(dataTypes).when(cellValue52).getDataType();
    doReturn(cellValue52).when(editingCol).getDefaultValue();
    doReturn(editingCol).when(plugin).editingCol();
    doReturn(pattern).when(plugin).patternWrapper();
    doReturn(oracle).when(presenter).getDataModelOracle();
    plugin.setValueList(valueList);
    verify(editingCol).setValueList(valueList);
    verify(plugin).assertDefaultValue();
    verify(plugin).fireChangeEvent(valueOptionsPage);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) DataType(org.kie.soup.project.datamodel.oracle.DataType) Mockito.anyString(org.mockito.Mockito.anyString) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 18 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class PatternPageTest method testSetEditingPattern.

@Test
public void testSetEditingPattern() throws Exception {
    when(view.getEntryPointName()).thenReturn("entryPoint");
    final PatternWrapper pattern = spy(newPattern("factType1", "boundName1", false));
    page.setEditingPattern(pattern);
    verify(pattern).setEntryPointName("entryPoint");
    verify(plugin).setEditingPattern(pattern);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Example 19 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class NewPatternPresenterTest method testAddPatternWhenIsNegatePatternMatch.

@Test
public void testAddPatternWhenIsNegatePatternMatch() throws Exception {
    final PatternWrapper pattern52 = mock(PatternWrapper.class);
    doReturn("").when(view).getSelectedFactType();
    doReturn("").when(view).getBindingText();
    doReturn(true).when(view).isNegatePatternMatch();
    doReturn(pattern52).when(presenter).pattern52();
    presenter.addPattern();
    verify(patternPage).setEditingPattern(pattern52);
    verify(patternPage).prepareView();
    verify(view).hide();
    verify(view, never()).showError(any());
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Example 20 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class ActionSetFactPluginTest method testNewPatternWrapperWhenPatternIsNotFound.

@Test
public void testNewPatternWrapperWhenPatternIsNotFound() throws Exception {
    final Set<PatternWrapper> actionWrappers = new HashSet<>();
    final ActionWrapper actionWrapper = mockActionWrapper("boundName", "factType");
    doReturn(actionWrappers).when(plugin).getPatterns();
    final PatternWrapper patternWrapper = plugin.newPatternWrapper(actionWrapper);
    assertEquals(actionWrapper.getBoundName(), patternWrapper.getBoundName());
    assertEquals(actionWrapper.getFactType(), patternWrapper.getFactType());
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) ActionWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

PatternWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)52 Test (org.junit.Test)41 HashSet (java.util.HashSet)11 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)9 BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)6 Mockito.anyString (org.mockito.Mockito.anyString)6 DTColumnConfig52 (org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52)4 ActionWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWrapper)4 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)3 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)3 ActionWorkItemWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemWrapper)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Dependent (javax.enterprise.context.Dependent)2 Event (javax.enterprise.event.Event)2 Inject (javax.inject.Inject)2 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)2