Search in sources :

Example 1 with RuleSelector

use of org.kie.workbench.common.widgets.client.ruleselector.RuleSelector in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testRuleSelectorWidgetWitNoActiveDecisionTable.

@Test
public void testRuleSelectorWidgetWitNoActiveDecisionTable() {
    final RuleSelector ruleSelector = mock(RuleSelector.class);
    when(modeller.getActiveDecisionTable()).thenReturn(Optional.empty());
    doReturn(ruleSelector).when(presenter).makeRuleSelector();
    presenter.ruleSelector();
    verify(presenter, never()).setupRuleSelector(any(GuidedDecisionTableView.Presenter.class));
}
Also used : RuleSelector(org.kie.workbench.common.widgets.client.ruleselector.RuleSelector) Test(org.junit.Test)

Example 2 with RuleSelector

use of org.kie.workbench.common.widgets.client.ruleselector.RuleSelector in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testRuleSelectorWidget.

@Test
@SuppressWarnings("unchecked")
public void testRuleSelectorWidget() {
    final RuleSelector ruleSelector = mock(RuleSelector.class);
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    final Collection<String> ruleNames = Collections.singletonList("rule");
    model.setParentName("parent");
    doReturn(ruleSelector).when(presenter).makeRuleSelector();
    when(modeller.getActiveDecisionTable()).thenReturn(Optional.of(dtPresenter));
    when(dtPresenter.getModel()).thenReturn(model);
    final ArgumentCaptor<ValueChangeHandler> valueChangeHandlerCaptor = ArgumentCaptor.forClass(ValueChangeHandler.class);
    final ArgumentCaptor<ParameterizedCommand> commandCaptor = ArgumentCaptor.forClass(ParameterizedCommand.class);
    presenter.ruleSelector();
    verify(ruleSelector).addValueChangeHandler(valueChangeHandlerCaptor.capture());
    valueChangeHandlerCaptor.getValue().onValueChange(mock(ValueChangeEvent.class));
    verify(dtPresenter).setParentRuleName(anyString());
    verify(presenter).setupRuleSelector(eq(dtPresenter));
    verify(dtPresenter).getPackageParentRuleNames(commandCaptor.capture());
    commandCaptor.getValue().execute(ruleNames);
    verify(ruleSelector).setRuleName(eq("parent"));
    verify(ruleSelector).setRuleNames(eq(ruleNames));
}
Also used : ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) RuleSelector(org.kie.workbench.common.widgets.client.ruleselector.RuleSelector) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) Matchers.anyString(org.mockito.Matchers.anyString) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RuleSelector (org.kie.workbench.common.widgets.client.ruleselector.RuleSelector)2 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)1 Matchers.anyString (org.mockito.Matchers.anyString)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1