Search in sources :

Example 41 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 patternWrapperMock.

private PatternWrapper patternWrapperMock(final String factType, final String boundName) {
    final PatternWrapper patternWrapper = mock(PatternWrapper.class);
    doReturn(factType).when(patternWrapper).getFactType();
    doReturn(boundName).when(patternWrapper).getBoundName();
    return patternWrapper;
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)

Example 42 with PatternWrapper

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

the class ActionWorkItemSetFieldPluginTest method testNewPatternWrapperWhenPatternIsNotFound.

@Test
public void testNewPatternWrapperWhenPatternIsNotFound() throws Exception {
    final Set<PatternWrapper> actionWrappers = new HashSet<>();
    final ActionWorkItemWrapper 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 : ActionWorkItemWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemWrapper) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 43 with PatternWrapper

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

the class ActionWorkItemSetFieldPluginTest method testSetFactFieldWhenFactPattern.

@Test
public void testSetFactFieldWhenFactPattern() throws Exception {
    final PatternWrapper patternWrapper = mock(PatternWrapper.class);
    final String factField = "factField";
    final String factType = "factType";
    final String boundName = "boundName";
    final String type = "type";
    doReturn(factType).when(patternWrapper).getFactType();
    doReturn(boundName).when(patternWrapper).getBoundName();
    doReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY).when(model).getTableFormat();
    doReturn(editingWrapper).when(plugin).editingWrapper();
    doReturn(patternWrapper).when(plugin).patternWrapper();
    doReturn(model).when(presenter).getModel();
    doReturn(oracle).when(presenter).getDataModelOracle();
    doReturn(true).when(plugin).isNewFactPattern();
    doReturn(type).when(oracle).getFieldType(any(), any());
    plugin.setFactField(factField);
    verify(editingWrapper).setFactField(factField);
    verify(editingWrapper).setFactType(factType);
    verify(editingWrapper).setBoundName(boundName);
    verify(editingWrapper).setType(type);
    verify(plugin).fireChangeEvent(fieldPage);
}
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)

Example 44 with PatternWrapper

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

the class ActionWorkItemSetFieldPluginTest method testNewPatternWrapperWhenPatternIsFound.

@Test
public void testNewPatternWrapperWhenPatternIsFound() throws Exception {
    final PatternWrapper expectedWrapper = mockPatternWrapper("BoundName");
    final Set<PatternWrapper> actionWrappers = new HashSet<PatternWrapper>() {

        {
            add(expectedWrapper);
        }
    };
    doReturn(actionWrappers).when(plugin).getPatterns();
    final PatternWrapper actualWrapper = plugin.newPatternWrapper(mockActionWrapper("BoundName", "factType"));
    assertSame(expectedWrapper, actualWrapper);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 45 with PatternWrapper

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

the class ActionWorkItemSetFieldPluginTest method testIsNewFactPatternWhenIsNew.

@Test
public void testIsNewFactPatternWhenIsNew() throws Exception {
    mockPatterns();
    plugin.setEditingPattern(new PatternWrapper("factType", "bananna"));
    assertTrue(plugin.isNewFactPattern());
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) 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