RefreshUtil { public static void refreshActionValueEditorsDropDownData(final Map<ActionFieldValue, ActionValueEditor> actionValueEditors, final ActionFieldValue modifiedField) { for (Map.Entry<ActionFieldValue, ActionValueEditor> e : actionValueEditors.entrySet()) { final ActionFieldValue afv = e.getKey(); if (afv.getNature() == FieldNatureType.TYPE_LITERAL || afv.getNature() == FieldNatureType.TYPE_ENUM) { if (!afv.equals(modifiedField)) { e.getValue().refresh(); } } } }  static void refreshActionValueEditorsDropDownData(final Map<ActionFieldValue, ActionValueEditor> actionValueEditors, final ActionFieldValue modifiedField); static void refreshConstraintValueEditorsDropDownData(final Map<SingleFieldConstraint, ConstraintValueEditor> constraintValueEditors, final SingleFieldConstraint modifiedConstraint);  }
@Test public void testActionValueEditorRefreshPredicateNotRefreshed() throws Exception { final ActionFieldValue valueOne = mock(ActionFieldValue.class); final ActionFieldValue valueTwo = mock(ActionFieldValue.class); final ActionValueEditor editorOne = mock(ActionValueEditor.class); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); final Map<ActionFieldValue, ActionValueEditor> editors = new HashMap<>(); editors.put(valueOne, editorOne); editors.put(valueTwo, editorTwo); doReturn(FieldNatureType.TYPE_LITERAL).when(valueOne).getNature(); doReturn(FieldNatureType.TYPE_PREDICATE).when(valueTwo).getNature(); RefreshUtil.refreshActionValueEditorsDropDownData(editors, mock(ActionFieldValue.class)); verify(editorOne).refresh(); verify(editorTwo, never()).refresh(); }
@Test public void testActionValueEditorRefreshMultipleEditors() throws Exception { final ActionFieldValue valueOne = mock(ActionFieldValue.class); final ActionFieldValue valueTwo = mock(ActionFieldValue.class); final ActionValueEditor editorOne = mock(ActionValueEditor.class); final ActionValueEditor editorTwo = mock(ActionValueEditor.class); final Map<ActionFieldValue, ActionValueEditor> editors = new HashMap<>(); editors.put(valueOne, editorOne); editors.put(valueTwo, editorTwo); doReturn(FieldNatureType.TYPE_LITERAL).when(valueOne).getNature(); doReturn(FieldNatureType.TYPE_LITERAL).when(valueTwo).getNature(); RefreshUtil.refreshActionValueEditorsDropDownData(editors, mock(ActionFieldValue.class)); verify(editorOne).refresh(); verify(editorTwo).refresh(); }