@Test @SuppressWarnings("unchecked") public void testMakeOptionGroup() { final String dataTypeName = "name"; final String groupTitle = "Title"; final DataType dataType = makeDataType(dataTypeName); final List<DataType> dataTypes = Collections.singletonList(dataType); final HTMLOptGroupElement expectedGroupElement = mock(HTMLOptGroupElement.class); final HTMLOptionElement optionElement = mock(HTMLOptionElement.class); doReturn(expectedGroupElement).when(view).makeHTMLOptGroupElement(); doReturn(optionElement).when(view).makeOption(eq(dataType), any(Function.class)); final HTMLOptGroupElement actualGroupElement = view.makeOptionGroup(groupTitle, dataTypes, DataType::getName); verify(expectedGroupElement).appendChild(optionElement); assertEquals(expectedGroupElement, actualGroupElement); assertEquals(groupTitle, actualGroupElement.label); }
HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; }
DataTypeSelectView implements DataTypeSelect.View { HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; } }
DataTypeSelectView implements DataTypeSelect.View { HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; } @Inject  DataTypeSelectView(final HTMLDivElement typeText,
                              final HTMLSelectElement typeSelect,
                              final HTMLOptGroupElement typeSelectOptGroup,
                              final HTMLOptionElement typeSelectOption,
                              final HTMLOptGroupElement typeSelectStructureOptGroup,
                              final TranslationService translationService); }
DataTypeSelectView implements DataTypeSelect.View { HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; } @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 { HTMLOptGroupElement makeOptionGroup(final String groupTitle, final List<DataType> dataTypes, final Function<DataType, String> dataTypeConsumer) { final HTMLOptGroupElement optionGroup = makeHTMLOptGroupElement(); optionGroup.label = groupTitle; dataTypes.stream() .forEach(dataType -> { final HTMLOptionElement option = makeOption(dataType, dataTypeConsumer); optionGroup.appendChild(option); }); return optionGroup; } @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();  }