RefreshUtil { public static void refreshConstraintValueEditorsDropDownData(final Map<SingleFieldConstraint, ConstraintValueEditor> constraintValueEditors, final SingleFieldConstraint modifiedConstraint) { for (Map.Entry<SingleFieldConstraint, ConstraintValueEditor> e : constraintValueEditors.entrySet()) { final SingleFieldConstraint sfc = e.getKey(); if (sfc.getConstraintValueType() == SingleFieldConstraint.TYPE_LITERAL || sfc.getConstraintValueType() == SingleFieldConstraint.TYPE_ENUM) { if (!sfc.equals(modifiedConstraint)) { 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 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(); }
@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(); }