ConsumerFactory { public static <T, W extends TextBox, E extends SingleValueDOMElement<T, W>, F extends SingleValueSingletonDOMElementFactory<T, W, E>> Consumer<E> makeOnCreationCallback(final F factory, final GridCell<T> cell) { return (e) -> { if (hasValue(cell)) { e.getWidget().setValue(factory.convert(cell.getValue().getValue())); } else { e.getWidget().setValue(""); } }; }  static Consumer<E> makeOnCreationCallback(final F factory,
                                                                                                                                                                             final GridCell<T> cell); static Consumer<E> makeOnDisplayTextBoxCallback(); static Consumer<E> makeOnCreationCallback(final F factory,
                                                                                                                                                                           final GridCell<T> cell,
                                                                                                                                                                           final Map<String, String> enumLookups); static Consumer<E> makeOnDisplayListBoxCallback(); static Consumer<E> makeOnCreationCallback(final GridCell<Date> cell); static Consumer<E> makeOnDisplayDatePickerCallback();  }
@Test @SuppressWarnings("unchecked") public void makeOnCreationCallbackListBoxSingleSelect() { setupMultipleSelectTest(ConsumerFactory.MAX_VISIBLE_ROWS, false); final Consumer callback = ConsumerFactory.makeOnCreationCallback(factory, cell, enumLookups); callback.accept(multiValueDOMElement); verifyMultipleSelectTest(ConsumerFactory.MAX_VISIBLE_ROWS); verify(multiValueWidget, never()).setVisibleItemCount(anyInt()); }
@Test @SuppressWarnings("unchecked") public void makeOnCreationCallbackListBoxMultipleSelect() { setupMultipleSelectTest(ConsumerFactory.MAX_VISIBLE_ROWS, true); final Consumer callback = ConsumerFactory.makeOnCreationCallback(factory, cell, enumLookups); callback.accept(multiValueDOMElement); verifyMultipleSelectTest(ConsumerFactory.MAX_VISIBLE_ROWS); verify(multiValueWidget).setVisibleItemCount(eq(ConsumerFactory.MAX_VISIBLE_ROWS)); }
@Test @SuppressWarnings("unchecked") public void makeOnCreationCallbackListBoxMultipleSelectMoreThanMaximum() { setupMultipleSelectTest(ConsumerFactory.MAX_VISIBLE_ROWS + 1, true); final Consumer callback = ConsumerFactory.makeOnCreationCallback(factory, cell, enumLookups); callback.accept(multiValueDOMElement); verify(multiValueWidget).setVisibleItemCount(eq(ConsumerFactory.MAX_VISIBLE_ROWS)); verifyMultipleSelectTest(ConsumerFactory.MAX_VISIBLE_ROWS + 1); }
@Test public void testMakeOnCreationCallback() { final DatePickerDOMElement datePickerDomElement = mock(DatePickerDOMElement.class); final DatePicker datePickerWidget = mock(DatePicker.class); final String serverDate = "05-01-2018 06:00:00 +0300"; final String dateConvertedFromServerTimezone = "05-01-2018 00:00:00 -0300"; final Consumer<SingleValueDOMElement<Date, DatePicker>> callback = ConsumerFactory.makeOnCreationCallback(makeGridCell(asDate(serverDate))); when(datePickerDomElement.getWidget()).thenReturn(datePickerWidget); callback.accept(datePickerDomElement); verify(datePickerWidget).setValue(asDate(dateConvertedFromServerTimezone)); }