ActionInsertFactWidget extends RuleModellerWidget { ActionValueEditor valueEditor(final ActionFieldValue actionFieldValue) { final ActionValueEditor actionValueEditor = actionValueEditor(factType, actionFieldValue, model.getFieldValues(), readOnly); actionValueEditor.setOnChangeCommand(new Command() { public void execute() { RefreshUtil.refreshActionValueEditorsDropDownData(actionValueEditors, actionFieldValue); setModified(true); } }); actionValueEditors.put(actionFieldValue, actionValueEditor); return actionValueEditor; } ActionInsertFactWidget(final RuleModeller mod,
                                  final EventBus eventBus,
                                  final ActionInsertFact set,
                                  final Boolean readOnly); @Override boolean isReadOnly(); @Override boolean isFactTypeKnown();  }
@Test public void testOnChangeCallbackRegisteredForActionValueEditor() throws Exception { final ActionFieldValue value = new ActionFieldValue(); value.setNature(FieldNatureType.TYPE_LITERAL); value.setField("a"); final ActionValueEditor editor = mock(ActionValueEditor.class); doReturn(editor).when(testedWidget).actionValueEditor(anyString(), eq(value), any(), eq(readOnly)); final ActionFieldValue valueTwo = new ActionFieldValue(); valueTwo.setNature(FieldNatureType.TYPE_LITERAL); valueTwo.setField("b"); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); doReturn(editorTwo).when(testedWidget).actionValueEditor(anyString(), eq(valueTwo), any(), eq(readOnly)); testedWidget.valueEditor(value); testedWidget.valueEditor(valueTwo); verify(editor).setOnChangeCommand(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(testedWidget).setModified(true); verify(editorTwo).refresh(); }