Search in sources :

Example 1 with LocalDateConverter

use of org.apache.wicket.util.convert.converter.LocalDateConverter in project wicket by apache.

the class DateTimeFieldTest method timeEmpty.

@Test
public void timeEmpty() {
    LocalDate date = LocalDate.of(2017, 02, 13);
    TestPage page = new TestPage(null);
    tester.startPage(page);
    FormTester formTester = tester.newFormTester("form", false);
    formTester.setValue("field:date", new LocalDateConverter().convertToString(date, Locale.forLanguageTag("en-US")));
    formTester.submit();
    tester.assertNoErrorMessage();
    assertEquals(LocalDateTime.of(date, LocalTime.of(12, 0)), page.field.getModelObject());
}
Also used : LocalDateConverter(org.apache.wicket.util.convert.converter.LocalDateConverter) FormTester(org.apache.wicket.util.tester.FormTester) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 2 with LocalDateConverter

use of org.apache.wicket.util.convert.converter.LocalDateConverter in project wicket by apache.

the class DateTimeFieldTest method dateTimeNotEmpty.

@Test
public void dateTimeNotEmpty() {
    LocalDate date = LocalDate.of(2017, 02, 13);
    TestPage page = new TestPage(null);
    tester.startPage(page);
    FormTester formTester = tester.newFormTester("form", false);
    formTester.setValue("field:date", new LocalDateConverter().convertToString(date, Locale.forLanguageTag("en-US")));
    formTester.setValue("field:time:hours", "6");
    formTester.setValue("field:time:minutes", "15");
    formTester.select("field:time:amOrPmChoice", 0);
    formTester.submit();
    tester.assertNoErrorMessage();
    assertEquals(LocalDateTime.of(date, LocalTime.of(6, 15)), page.field.getModelObject());
}
Also used : LocalDateConverter(org.apache.wicket.util.convert.converter.LocalDateConverter) FormTester(org.apache.wicket.util.tester.FormTester) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 3 with LocalDateConverter

use of org.apache.wicket.util.convert.converter.LocalDateConverter in project wicket by apache.

the class LocalDateTextFieldTest method dateNotNullTest.

@Test
public void dateNotNullTest() {
    LocalDate date = LocalDate.of(2017, 02, 13);
    TestPage page = new TestPage(null);
    tester.startPage(page);
    FormTester formTester = tester.newFormTester("form", false);
    formTester.setValue("field", new LocalDateConverter().convertToString(date, Locale.forLanguageTag("en-US")));
    formTester.submit();
    tester.assertNoErrorMessage();
    LocalDate d = page.field.getModelObject();
    assertEquals(date, d);
}
Also used : LocalDateConverter(org.apache.wicket.util.convert.converter.LocalDateConverter) FormTester(org.apache.wicket.util.tester.FormTester) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

LocalDate (java.time.LocalDate)3 LocalDateConverter (org.apache.wicket.util.convert.converter.LocalDateConverter)3 FormTester (org.apache.wicket.util.tester.FormTester)3 Test (org.junit.Test)3