### Question:
ListBoxValues { public List<String> update(final String currentValue) { String currentEditValuePrompt = getEditValuePrompt(editPrefix); String newEditValuePrompt = editPrefix + currentValue + EDIT_SUFFIX; if (isCustomValue(currentValue)) { if (newEditValuePrompt.equals(currentEditValuePrompt)) { return acceptableValuesWithCustomValues; } if (currentEditValuePrompt != null) { acceptableValuesWithCustomValues.remove(currentEditValuePrompt); } int editPromptIndex = acceptableValuesWithCustomValues.indexOf(currentValue); if (editPromptIndex > -1) { editPromptIndex++; } else if (acceptableValuesWithCustomValues.size() > 1) { editPromptIndex = 2; } else { editPromptIndex = acceptableValuesWithCustomValues.size(); } acceptableValuesWithCustomValues.add(editPromptIndex, newEditValuePrompt); } else if (currentEditValuePrompt != null) { acceptableValuesWithCustomValues.remove(currentEditValuePrompt); } return acceptableValuesWithCustomValues; } ListBoxValues(final String customPrompt,
                         final String editPrefix,
                         final ValueTester valueTester,
                         final int maxDisplayLength,
                         final boolean allowEmpty);  ListBoxValues(final String customPrompt,
                         final String editPrefix,
                         final ValueTester valueTester,
                         final int maxDisplayLength);  ListBoxValues(final String customPrompt,
                         final String editPrefix,
                         final ValueTester valueTester,
                         final boolean allowEmpty);  ListBoxValues(final String customPrompt,
                         final String editPrefix,
                         final ValueTester valueTester);  ListBoxValues(final ListBoxValues copy,
                         final boolean copyCustomValues); String getEditPrefix(); void addValues(final List<String> acceptableValues); void addValues(final Map<String, String> acceptableValues); String addCustomValue(final String newValue,
                                 final String oldValue); List<String> update(final String currentValue); List<String> getAcceptableValuesWithCustomValues(); List<String> getAcceptableValuesWithoutCustomValues(); boolean isCustomValue(final String value); String getValueForDisplayValue(final String key); String getDisplayNameForValue(final String value); String getNonCustomValueForUserString(final String userValue); String toString(); static final String EDIT_SUFFIX; }### Answer:
@Test public void testUpdate() { final String first = "1st"; final String second = "2nd"; ListBoxValues test1 = new ListBoxValues("Constant ...", "Edit ", null); test1.customValues.add(CUSTOM_VALUE); List<String> result1 = test1.update(CUSTOM_VALUE); assertEquals(1, result1.size()); assertEquals(EDIT_CUSTOM_VALUE, result1.get(0)); ListBoxValues test2 = new ListBoxValues("Constant ...", "Edit ", null); test2.customValues.add(CUSTOM_VALUE); test2.customValues.add(CUSTOM_VALUE); test2.acceptableValuesWithCustomValues.add(first); test2.acceptableValuesWithCustomValues.add(second); List<String> result2 = test2.update(CUSTOM_VALUE); assertEquals(3, result2.size()); assertEquals(first, result2.get(0)); assertEquals(second, result2.get(1)); assertEquals(EDIT_CUSTOM_VALUE, result2.get(2)); }