@Test public void testSetupDropdownItems() { final HTMLOptGroupElement groupElementCustom = mock(HTMLOptGroupElement.class); final HTMLOptGroupElement groupElementDefault = mock(HTMLOptGroupElement.class); final List<DataType> defaultDataTypes = new ArrayList<>(); final List<DataType> customDataTypes = new ArrayList<>(); final Element element = mock(Element.class); when(translationService.format(DataTypeSelectView_DefaultTitle)).thenReturn("Default"); when(translationService.format(DataTypeSelectView_CustomTitle)).thenReturn("Custom"); when(presenter.getDefaultDataTypes()).thenReturn(defaultDataTypes); when(presenter.getCustomDataTypes()).thenReturn(customDataTypes); doReturn(groupElementCustom).when(view).makeOptionGroup(eq("Default"), eq(defaultDataTypes), any()); doReturn(groupElementDefault).when(view).makeOptionGroup(eq("Custom"), eq(customDataTypes), any()); typeSelect.firstChild = element; when(typeSelect.removeChild(element)).then(a -> { typeSelect.firstChild = null; return element; }); view.setupDropdownItems(); verify(typeSelect).removeChild(element); verify(typeSelect).appendChild(groupElementCustom); verify(typeSelect).appendChild(groupElementDefault); }
void setupDropdownItems() { RemoveHelper.removeChildren(typeSelect); typeSelect.appendChild(makeOptionGroup(defaultTitle(), presenter.getDefaultDataTypes(), DataType::getType)); typeSelect.appendChild(makeOptionGroup(customTitle(), presenter.getCustomDataTypes(), DataType::getName)); typeSelect.appendChild(makeOptionStructureGroup()); }
DataTypeSelectView implements DataTypeSelect.View { void setupDropdownItems() { RemoveHelper.removeChildren(typeSelect); typeSelect.appendChild(makeOptionGroup(defaultTitle(), presenter.getDefaultDataTypes(), DataType::getType)); typeSelect.appendChild(makeOptionGroup(customTitle(), presenter.getCustomDataTypes(), DataType::getName)); typeSelect.appendChild(makeOptionStructureGroup()); } }
DataTypeSelectView implements DataTypeSelect.View { void setupDropdownItems() { RemoveHelper.removeChildren(typeSelect); typeSelect.appendChild(makeOptionGroup(defaultTitle(), presenter.getDefaultDataTypes(), DataType::getType)); typeSelect.appendChild(makeOptionGroup(customTitle(), presenter.getCustomDataTypes(), DataType::getName)); typeSelect.appendChild(makeOptionStructureGroup()); } @Inject  DataTypeSelectView(final HTMLDivElement typeText,
                              final HTMLSelectElement typeSelect,
                              final HTMLOptGroupElement typeSelectOptGroup,
                              final HTMLOptionElement typeSelectOption,
                              final HTMLOptGroupElement typeSelectStructureOptGroup,
                              final TranslationService translationService); }
DataTypeSelectView implements DataTypeSelect.View { void setupDropdownItems() { RemoveHelper.removeChildren(typeSelect); typeSelect.appendChild(makeOptionGroup(defaultTitle(), presenter.getDefaultDataTypes(), DataType::getType)); typeSelect.appendChild(makeOptionGroup(customTitle(), presenter.getCustomDataTypes(), DataType::getName)); typeSelect.appendChild(makeOptionStructureGroup()); } @Inject  DataTypeSelectView(final HTMLDivElement typeText,
                              final HTMLSelectElement typeSelect,
                              final HTMLOptGroupElement typeSelectOptGroup,
                              final HTMLOptionElement typeSelectOption,
                              final HTMLOptGroupElement typeSelectStructureOptGroup,
                              final TranslationService translationService); @Override void init(final DataTypeSelect presenter); @Override void setupDropdown(); @Override void enableEditMode(); @Override void disableEditMode(); @Override void setDataType(final DataType dataType); void onSelectChange(final JQuerySelectPickerEvent event); @Override String getValue(); }
DataTypeSelectView implements DataTypeSelect.View { void setupDropdownItems() { RemoveHelper.removeChildren(typeSelect); typeSelect.appendChild(makeOptionGroup(defaultTitle(), presenter.getDefaultDataTypes(), DataType::getType)); typeSelect.appendChild(makeOptionGroup(customTitle(), presenter.getCustomDataTypes(), DataType::getName)); typeSelect.appendChild(makeOptionStructureGroup()); } @Inject  DataTypeSelectView(final HTMLDivElement typeText,
                              final HTMLSelectElement typeSelect,
                              final HTMLOptGroupElement typeSelectOptGroup,
                              final HTMLOptionElement typeSelectOption,
                              final HTMLOptGroupElement typeSelectStructureOptGroup,
                              final TranslationService translationService); @Override void init(final DataTypeSelect presenter); @Override void setupDropdown(); @Override void enableEditMode(); @Override void disableEditMode(); @Override void setDataType(final DataType dataType); void onSelectChange(final JQuerySelectPickerEvent event); @Override String getValue();  }