### Question:
ComponentFactory { public static DateField newDateField() { MultiformatDateField field = new MultiformatDateField(); field.setRangeStart(LocalDate.ofYearDay(1, 1)); field.setRangeEnd(LocalDate.ofYearDay(9999, 365)); return field; } private  ComponentFactory(); @Deprecated static Label addHorizontalSpacer(AbstractLayout layout); @Deprecated static Label addHorizontalFixedSizeSpacer(AbstractOrderedLayout layout, int px); @Deprecated static final Label newLabelWidth100(AbstractOrderedLayout parent, String caption); @Deprecated static final Label sizedLabel(Layout parent, String caption, ContentMode mode); @Deprecated static final Label sizedLabel(AbstractOrderedLayout parent, String caption); @Deprecated static final Label newLabelWidthUndefined(AbstractOrderedLayout parent, String caption); @Deprecated static Label labelIcon(AbstractOrderedLayout parent, FontIcon icon); @Deprecated static final Label newEmptyLabel(AbstractOrderedLayout layout); static Label newHorizontalLine(); static Label newLabelIcon(FontIcon icon); static Label newLabelFullWidth(String caption, ContentMode contentMode); static Label newLabelFullWidth(String caption); static Label newLabelUndefinedWidth(String caption, ContentMode contentMode); static Label newLabelUndefinedWidth(String caption); static Link newLinkFullWidth(String caption); @Deprecated static TextField newTextfield(); static TextField newTextField(); static TextField newTextField(int maxLength, String width); static TextArea newTextArea(); static TextArea newTextArea(int maxLength, String width, int rows); @Deprecated static TextField newReadOnlyTextFieldFixedWidth(String value); @Deprecated static TextField newReadOnlyTextField(String value, int columns); @Deprecated static TextField newReadOnlyTextField100PctWidth(String value); @Deprecated static TextField newReadOnlyTextField(String value); static ComboBox<T> newComboBox(); static CheckBox newCheckBox(); static Button newButton(); static DateField newDateField(); @Deprecated static TextField newIntegerField(@SuppressWarnings("unused") Locale locale); @Deprecated static TextField newDoubleField(@SuppressWarnings("unused") Locale locale); @Deprecated static Button newButton(ButtonPmo buttonPmo); static Button newButton(Resource icon, Collection<String> styleNames); static TwinColSelect<T> newTwinColSelect(); static VerticalLayout newPlainVerticalLayout(); static final String NO_BREAK_SPACE; }### Answer:
@Test public void testNewDateField_BelowRange() { DateField dateField = ComponentFactory.newDateField(); dateField.setDateOutOfRangeMessage(MESSAGE); assertThrows(IllegalArgumentException.class, () -> dateField.setValue(LocalDate.of(-1, 1, 1))); }
@Test public void testNewDateField_InRangeLowerBound() { DateField dateField = ComponentFactory.newDateField(); dateField.setDateOutOfRangeMessage(MESSAGE); dateField.setValue(LocalDate.of(1, 1, 1)); assertThat(dateField.getErrorMessage(), is(nullValue())); }
@Test public void testNewDateField_InRangeUpperBound() { DateField dateField = ComponentFactory.newDateField(); dateField.setDateOutOfRangeMessage(MESSAGE); dateField.setValue(LocalDate.of(9999, 12, 31)); assertThat(dateField.getErrorMessage(), is(nullValue())); }
@Test public void testNewDateField_AboveRange() { DateField dateField = ComponentFactory.newDateField(); dateField.setDateOutOfRangeMessage(MESSAGE); assertThrows(IllegalArgumentException.class, () -> dateField.setValue(LocalDate.of(10000, 1, 1))); }