Search in sources :

Example 31 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 testSetSelectedEditingPattern.

@Test
public void testSetSelectedEditingPattern() throws Exception {
    final PatternWrapper patternWrapper = mock(PatternWrapper.class);
    final String key = "factType boundName false";
    when(page.findPatternWrapperByKey(key)).thenReturn(patternWrapper);
    when(view.getSelectedValue()).thenReturn(key);
    page.setSelectedEditingPattern();
    verify(page).setEditingPattern(patternWrapper);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Example 32 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 testAddPatternWhenPatternIsValid.

@Test
public void testAddPatternWhenPatternIsValid() throws Exception {
    final PatternWrapper pattern52 = mock(PatternWrapper.class);
    doReturn("Applicant").when(view).getSelectedFactType();
    doReturn("app").when(view).getBindingText();
    doReturn(false).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 33 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 testPattern52.

@Test
public void testPattern52() throws Exception {
    when(view.getSelectedFactType()).thenReturn("Applicant");
    when(view.getBindingText()).thenReturn("app");
    when(view.isNegatePatternMatch()).thenReturn(false);
    final PatternWrapper pattern52 = presenter.pattern52();
    assertEquals("Applicant", pattern52.getFactType());
    assertEquals("app", pattern52.getBoundName());
    assertEquals(false, pattern52.isNegated());
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Example 34 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 testSetFactFieldWhenFactPatternIsNotNew.

@Test
public void testSetFactFieldWhenFactPatternIsNotNew() {
    final ActionSetFactWrapper actionWrapper = spy(new ActionSetFactWrapper(plugin));
    final Pattern52 patternMock = patternMock("factType");
    final PatternWrapper patternWrapperMock = patternWrapperMock("factType", "boundName");
    doReturn(false).when(plugin).isNewFactPattern();
    doReturn(actionWrapper).when(plugin).newActionSetFactWrapper();
    doReturn(patternWrapperMock).when(plugin).patternWrapper();
    doReturn(patternMock).when(model).getConditionPattern(eq("boundName"));
    doReturn("type").when(oracle).getFieldType(eq("factType"), eq("selectedValue"));
    plugin.setFactField("selectedValue");
    verify(actionWrapper).setFactField(eq("selectedValue"));
    verify(actionWrapper).setFactType(eq("factType"));
    verify(actionWrapper).setBoundName(eq("boundName"));
    verify(actionWrapper).setType(eq("type"));
    verify(plugin).fireChangeEvent(fieldPage);
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionSetFactWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionSetFactWrapper) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Example 35 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 mockPatternWrapper.

private PatternWrapper mockPatternWrapper(final String boundName) {
    final PatternWrapper wrapper = mock(PatternWrapper.class);
    when(wrapper.getBoundName()).thenReturn(boundName);
    return wrapper;
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)

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