### Question:
AbstractListBoxFieldRenderer extends SelectorFieldRenderer<FIELD, OPTION, TYPE> implements RequiresValueConverter { @Override protected void refreshInput(Map<TYPE, String> optionsValues, TYPE selectedValue) { List<TYPE> values = optionsValues.keySet().stream().collect(Collectors.toList()); if (field.getAddEmptyOption()) { if (!values.contains(null)) { values.add(0, null); optionsValues.put(null, translationService.getTranslation(FormRenderingConstants.ListBoxFieldRendererEmptyOptionText)); } else { Collections.swap(values, values.indexOf(null), 0); } } if (widgetList.getValue() == null && optionsValues.containsKey(selectedValue)) { widgetList.setValue(selectedValue); } optionsRenderer.setValues(optionsValues); widgetList.setAcceptableValues(values); } AbstractListBoxFieldRenderer(TranslationService translationService); @Override String getName(); abstract TYPE getEmptyValue(); @Override Converter getConverter();  }### Answer:
@Test public void testRefreshInputDontAddNullOption() { when(field.getAddEmptyOption()).thenReturn(false); renderer.refreshInput(options, null); verify(field).getAddEmptyOption(); verify(translationService, never()).getTranslation(FormRenderingConstants.ListBoxFieldRendererEmptyOptionText); assertFalse(options.containsValue(null)); verify(optionsRenderer).setValues(options); verify(valueListBox).setAcceptableValues(any()); }
@Test public void testRefreshInputAddNullOption() { when(field.getAddEmptyOption()).thenReturn(true); renderer.refreshInput(options, null); verify(field).getAddEmptyOption(); verify(translationService).getTranslation(FormRenderingConstants.ListBoxFieldRendererEmptyOptionText); assertTrue(options.containsValue(null)); verify(optionsRenderer).setValues(options); verify(valueListBox).setAcceptableValues(any()); }
@Test public void testRefreshInputAddExistingNullOption() { when(field.getAddEmptyOption()).thenReturn(true); options.put(null, "null"); renderer.refreshInput(options, null); verify(field).getAddEmptyOption(); verify(translationService, never()).getTranslation(FormRenderingConstants.ListBoxFieldRendererEmptyOptionText); verify(optionsRenderer).setValues(options); verify(valueListBox).setAcceptableValues(any()); }