use of org.drools.workbench.screens.guided.rule.client.editor.RuleModeller in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorViewImpl method setContent.
@Override
public void setContent(final TemplateModel model, final AsyncPackageDataModelOracle oracle, final Caller<RuleNamesService> ruleNamesService, final EventBus eventBus, final boolean isReadOnly) {
this.modeller = new RuleModeller(model, oracle, new TemplateModellerWidgetFactory(), eventBus, isReadOnly);
panel.setWidget(modeller);
ruleNamesService.call(new RemoteCallback<Collection<String>>() {
@Override
public void callback(Collection<String> ruleNames) {
modeller.setRuleNamesForPackage(ruleNames);
}
}).getRuleNames(oracle.getResourcePath(), model.getPackageName());
}
use of org.drools.workbench.screens.guided.rule.client.editor.RuleModeller in project drools-wb by kiegroup.
the class RuleModellerPage method newRuleModeller.
private RuleModeller newRuleModeller() {
final RuleModeller ruleModeller = new RuleModeller(ruleModel(), actionPlugins(), oracle(), widgetFactory(), configuration(), eventBus(), isReadOnly());
presenter.getPackageParentRuleNames(ruleModeller::setRuleNamesForPackage);
return ruleModeller;
}
use of org.drools.workbench.screens.guided.rule.client.editor.RuleModeller in project drools-wb by kiegroup.
the class PopupCreatorTest method testOnExpressionEditorButtonClick.
@Test
public void testOnExpressionEditorButtonClick() {
final String factType = "factType";
final FactPattern factPattern = mock(FactPattern.class);
final HasConstraints hasConstraints = mock(HasConstraints.class);
final FormStylePopup popup = mock(FormStylePopup.class);
final SingleFieldConstraintEBLeftSide constraint = mock(SingleFieldConstraintEBLeftSide.class);
final RuleModeller ruleModeller = mock(RuleModeller.class);
final ClickEvent clickEvent = mock(ClickEvent.class);
doReturn(factType).when(factPattern).getFactType();
doReturn(constraint).when(popupCreator).makeSingleFieldConstraintEBLeftSide(factType);
doReturn(ruleModeller).when(popupCreator).getModeller();
doReturn(factPattern).when(popupCreator).getPattern();
final ClickHandler clickHandler = popupCreator.onExpressionEditorButtonClick(hasConstraints, popup);
clickHandler.onClick(clickEvent);
verify(hasConstraints).addConstraint(constraint);
verify(ruleModeller).refreshWidget();
verify(popup).hide();
}
use of org.drools.workbench.screens.guided.rule.client.editor.RuleModeller in project drools-wb by kiegroup.
the class DSLDropDownTest method testGetDropDown.
@Test
public void testGetDropDown() throws Exception {
final String fact = "Fact";
final String field = "field";
final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
final RuleModeller ruleModeller = mock(RuleModeller.class);
doReturn(oracle).when(ruleModeller).getDataModelOracle();
final String variableDefinition = "varName:type:" + fact + "." + field;
final DSLSentence dslSentence = mock(DSLSentence.class);
final DSLVariableValue dslVariableValue = mock(DSLVariableValue.class);
final boolean isMultipleSelect = false;
final Callback<DSLDropDown> updateEnumsCallback = mock(Callback.class);
testedDropDown = new DSLDropDown(ruleModeller, variableDefinition, dslSentence, dslVariableValue, isMultipleSelect, updateEnumsCallback);
// reset oracle due to calls in DSLDropDown constructor
reset(oracle);
testedDropDown.getDropDownData();
verify(oracle).getEnums(eq(fact), eq(field), anyMap());
}
use of org.drools.workbench.screens.guided.rule.client.editor.RuleModeller in project drools-wb by kiegroup.
the class RuleModellerPageTest method testRuleModeller.
@Test
public void testRuleModeller() throws Exception {
when(brlActionPlugin.getRuleModel()).thenReturn(new RuleModel());
when(brlActionPlugin.tableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
when(brlActionPlugin.getRuleModellerActionPlugins()).thenReturn(Collections.singletonList(ruleModellerActionPlugin));
when(brlActionPlugin.getRuleModellerConfiguration()).thenReturn(mock(RuleModellerConfiguration.class));
when(presenter.getDataModelOracle()).thenReturn(mock(AsyncPackageDataModelOracle.class));
final RuleModeller ruleModeller = brlActionPage.ruleModeller();
assertNotNull(ruleModeller);
assertEquals(brlActionPlugin.getRuleModel(), ruleModeller.getModel());
assertEquals(Collections.singletonList(ruleModellerActionPlugin), ruleModeller.getActionPlugins());
assertEquals(presenter.getDataModelOracle(), ruleModeller.getDataModelOracle());
assertTrue(ruleModeller.getWidgetFactory() instanceof TemplateModellerWidgetFactory);
assertFalse(ruleModeller.isReadOnly());
}
Aggregations