PopupCreator { ClickHandler onExpressionEditorButtonClick(final HasConstraints hasConstraints, final FormStylePopup popup) { return event -> { final String factType = getPattern().getFactType(); final SingleFieldConstraintEBLeftSide constraint = makeSingleFieldConstraintEBLeftSide(factType); hasConstraints.addConstraint(constraint); getModeller().refreshWidget(); popup.hide(); }; }  FactPattern getPattern(); void setPattern(FactPattern pattern); AsyncPackageDataModelOracle getDataModelOracle(); void setDataModelOracle(AsyncPackageDataModelOracle oracle); RuleModeller getModeller(); void setModeller(RuleModeller modeller); boolean isBindable(); void setBindable(boolean bindable); void showBindFieldPopup(final FactPattern fp,
                                   final SingleFieldConstraint con,
                                   final ModelField[] fields,
                                   final PopupCreator popupCreator); void showPatternPopupForComposite(final HasConstraints hasConstraints); void showPatternPopup(final FactPattern fp,
                                 final SingleFieldConstraint con,
                                 final boolean isNested);  }
@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(); }