Search in sources :

Example 51 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 testMakeBRLRuleModel.

@Test
public void testMakeBRLRuleModel() {
    final String factType = "FactType";
    final String boundName1 = "$fact1";
    final String boundName2 = "$fact2";
    final Pattern52 pattern = new Pattern52() {

        {
            setFactType(factType);
            setBoundName(boundName1);
        }
    };
    final FactPattern factPattern = new FactPattern() {

        {
            setFactType(factType);
            setBoundName(boundName2);
        }
    };
    final PatternWrapper patternWrapper = mock(PatternWrapper.class);
    doReturn(factPattern).when(patternWrapper).makeFactPattern();
    doReturn(patternWrapper).when(plugin).patternWrapper();
    doReturn(Collections.singletonList(pattern)).when(model).getConditions();
    doReturn(pattern).when(model).getConditionPattern(boundName1);
    final BRLRuleModel brlRuleModel = plugin.makeBRLRuleModel();
    final List<String> expectedVariables = Arrays.asList(boundName1, boundName2);
    final List<String> actualVariables = brlRuleModel.getAllVariables();
    assertEquals(expectedVariables, actualVariables);
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Mockito.anyString(org.mockito.Mockito.anyString) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) Test(org.junit.Test)

Example 52 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 testGetEntryPointNameWhenEditingPatternIsNotNull.

@Test
public void testGetEntryPointNameWhenEditingPatternIsNotNull() throws Exception {
    final PatternWrapper pattern = mock(PatternWrapper.class);
    doReturn("EntryPointName").when(pattern).getEntryPointName();
    doReturn(pattern).when(plugin).patternWrapper();
    final String entryPointName = plugin.getEntryPointName();
    assertEquals("EntryPointName", entryPointName);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Mockito.anyString(org.mockito.Mockito.anyString) 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