Переглянути джерело

Fix formatting of some files (#10972)

tags/8.5.0.alpha2
Ilia Motornyi 6 роки тому
джерело
коміт
16335d3aba

+ 1
- 1
server/src/main/java/com/vaadin/ui/AbstractDateField.java Переглянути файл

@@ -117,7 +117,7 @@ public abstract class AbstractDateField<T extends Temporal & TemporalAdjuster &
currentParseErrorMessage = null;
if (newDateString == null || newDateString.isEmpty()) {
boolean valueChanged = setValue(newDate, true);
if(!valueChanged && parseErrorWasSet) {
if (!valueChanged && parseErrorWasSet) {
doSetValue(newDate);
}
} else {

+ 18
- 11
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldErrorMessageTest.java Переглянути файл

@@ -39,11 +39,14 @@ public class DateFieldErrorMessageTest
public void testErrorMessageRemoved() throws Exception {
InlineDateField field = new InlineDateField("Day is",
LocalDate.of(2003, 2, 27));
checkValueAndComponentError(field, "2003-02-27", LocalDate.of(2003, 2, 27), false);
checkValueAndComponentError(field, "2003-02-27",
LocalDate.of(2003, 2, 27), false);
checkValueAndComponentError(field, "", null, false);
checkValueAndComponentError(field, "2003-04-27", LocalDate.of(2003, 4, 27), false);
checkValueAndComponentError(field, "2003-04-27",
LocalDate.of(2003, 4, 27), false);
checkValueAndComponentError(field, "foo", null, true);
checkValueAndComponentError(field, "2013-07-03", LocalDate.of(2013, 7, 3), false);
checkValueAndComponentError(field, "2013-07-03",
LocalDate.of(2013, 7, 3), false);
checkValueAndComponentError(field, "foo", null, true);
checkValueAndComponentError(field, "", null, false);
}
@@ -58,25 +61,29 @@ public class DateFieldErrorMessageTest
return InlineDateField.class;
}

private void checkValueAndComponentError(InlineDateField field, String newInput, LocalDate expectedFieldValue, boolean componentErrorExpected) throws Exception {
private void checkValueAndComponentError(InlineDateField field,
String newInput, LocalDate expectedFieldValue,
boolean componentErrorExpected) throws Exception {
setDateByText(field, newInput);
assertEquals(expectedFieldValue, field.getValue());
assertEquals(componentErrorExpected, field.getComponentError()!=null);
assertEquals(componentErrorExpected, field.getComponentError() != null);
}

private void setDateByText(InlineDateField field, String dateText) throws Exception {
private void setDateByText(InlineDateField field, String dateText)
throws Exception {
Field rcpField = AbstractDateField.class.getDeclaredField("rpc");
rcpField.setAccessible(true);
AbstractDateFieldServerRpc rcp = (AbstractDateFieldServerRpc)rcpField.get(field);
Map<String, Integer> resolutions=new HashMap<String, Integer>();
AbstractDateFieldServerRpc rcp = (AbstractDateFieldServerRpc) rcpField
.get(field);
Map<String, Integer> resolutions = new HashMap<String, Integer>();
try {
LocalDate date = LocalDate.parse(dateText);
resolutions.put(DateResolution.YEAR.name(), date.getYear());
resolutions.put(DateResolution.MONTH.name(), date.getMonthValue());
resolutions.put(DateResolution.DAY.name(), date.getDayOfMonth());
}catch (Exception e) {
//ignore
} catch (Exception e) {
// ignore
}
rcp.update(dateText, resolutions);
}
}
}

Завантаження…
Відмінити
Зберегти