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));
}
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));
}
Aggregations