use of org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor in project drools-wb by kiegroup.
the class RefreshUtilTest method testConstraintValueEditorRefreshMultipleEditors.
@Test
public void testConstraintValueEditorRefreshMultipleEditors() throws Exception {
final SingleFieldConstraint constraintOne = mock(SingleFieldConstraint.class);
final SingleFieldConstraint constraintTwo = mock(SingleFieldConstraint.class);
final ConstraintValueEditor editorOne = mock(ConstraintValueEditor.class);
final ConstraintValueEditor editorTwo = mock(ConstraintValueEditor.class);
final Map<SingleFieldConstraint, ConstraintValueEditor> editors = new HashMap<>();
editors.put(constraintOne, editorOne);
editors.put(constraintTwo, editorTwo);
doReturn(BaseSingleFieldConstraint.TYPE_LITERAL).when(constraintOne).getConstraintValueType();
doReturn(BaseSingleFieldConstraint.TYPE_LITERAL).when(constraintTwo).getConstraintValueType();
RefreshUtil.refreshConstraintValueEditorsDropDownData(editors, mock(SingleFieldConstraint.class));
verify(editorOne).refresh();
verify(editorTwo).refresh();
}
use of org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor in project drools-wb by kiegroup.
the class ConnectivesTest method testConstraintValueEditorInitialization.
@Test
public void testConstraintValueEditorInitialization() {
final ConstraintValueEditor editor = mock(ConstraintValueEditor.class);
doReturn(editor).when(connectives).connectiveValueEditor(connectiveConstraint);
connectives.connectives(singleFieldConstraint);
verify(connectives).connectiveOperatorDropDown(eq(connectiveConstraint), isA(Callback.class));
verify(editor).init();
}
use of org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor in project drools-wb by kiegroup.
the class Connectives method connectives.
public Widget connectives(final SingleFieldConstraint c) {
final HorizontalPanel hp = new HorizontalPanel();
if (c.getConnectives() != null && c.getConnectives().length > 0) {
hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
for (int i = 0; i < c.getConnectives().length; i++) {
final int index = i;
final ConnectiveConstraint con = c.getConnectives()[i];
connectiveOperatorDropDown(con, new Callback<Widget>() {
@Override
public void callback(final Widget w) {
hp.add(w);
final ConstraintValueEditor editor = connectiveValueEditor(con);
editor.init();
hp.add(editor);
if (!isReadOnly) {
Image clear = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
clear.setAltText(GuidedRuleEditorResources.CONSTANTS.RemoveThisRestriction());
clear.setTitle(GuidedRuleEditorResources.CONSTANTS.RemoveThisRestriction());
clear.addClickHandler(createClickHandlerForClearImageButton(c, index));
hp.add(clear);
}
}
});
}
}
return hp;
}
use of org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor in project drools-wb by kiegroup.
the class RefreshUtilTest method testConstraintValueEditorRefreshPredicateNotRefreshed.
@Test
public void testConstraintValueEditorRefreshPredicateNotRefreshed() throws Exception {
final SingleFieldConstraint constraintOne = mock(SingleFieldConstraint.class);
final SingleFieldConstraint constraintTwo = mock(SingleFieldConstraint.class);
final ConstraintValueEditor editorOne = mock(ConstraintValueEditor.class);
final ConstraintValueEditor editorTwo = mock(ConstraintValueEditor.class);
final Map<SingleFieldConstraint, ConstraintValueEditor> editors = new HashMap<>();
editors.put(constraintOne, editorOne);
editors.put(constraintTwo, editorTwo);
doReturn(BaseSingleFieldConstraint.TYPE_LITERAL).when(constraintOne).getConstraintValueType();
doReturn(BaseSingleFieldConstraint.TYPE_PREDICATE).when(constraintTwo).getConstraintValueType();
RefreshUtil.refreshConstraintValueEditorsDropDownData(editors, mock(SingleFieldConstraint.class));
verify(editorOne).refresh();
verify(editorTwo, never()).refresh();
}
use of org.drools.workbench.screens.guided.rule.client.editor.ConstraintValueEditor in project drools-wb by kiegroup.
the class FactPatternWidgetTest method testOnChangeCallbackRegisteredForConstraintValueEditor.
@Test
public void testOnChangeCallbackRegisteredForConstraintValueEditor() throws Exception {
final SingleFieldConstraint constraint = new SingleFieldConstraint();
constraint.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
constraint.setFieldName("a");
final ConstraintValueEditor editor = mock(ConstraintValueEditor.class);
doReturn(editor).when(factPatternWidget).constraintValueEditor(constraint);
final SingleFieldConstraint constraintTwo = new SingleFieldConstraint();
constraintTwo.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
constraintTwo.setFieldName("b");
final ConstraintValueEditor editorTwo = mock(ConstraintValueEditor.class);
doReturn(editorTwo).when(factPatternWidget).constraintValueEditor(constraintTwo);
factPatternWidget.createValueEditor(constraint);
factPatternWidget.createValueEditor(constraintTwo);
verify(editor).init();
verify(editorTwo).init();
verify(editor).setOnValueChangeCommand(commandCaptor.capture());
commandCaptor.getValue().execute();
verify(editorTwo).hideError();
verify(factPatternWidget).setModified(true);
verify(editorTwo).refresh();
}
Aggregations