You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LocalDateRenderersTest.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertEquals;
  3. import java.time.LocalDate;
  4. import java.time.format.DateTimeFormatter;
  5. import java.time.format.FormatStyle;
  6. import java.util.Locale;
  7. import org.junit.Test;
  8. import com.vaadin.testbench.elements.GridElement;
  9. import com.vaadin.tests.tb3.SingleBrowserTest;
  10. public class LocalDateRenderersTest extends SingleBrowserTest {
  11. @Test
  12. public void localDate_and_LocalDateTime_rendered_correctly() {
  13. openTestURL();
  14. GridElement grid = $(GridElement.class).first();
  15. LocalDate epochDate = LocalDate.ofEpochDay(0);
  16. assertEquals(
  17. epochDate.format(
  18. DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG)
  19. .withLocale(new Locale("en"))),
  20. grid.getCell(0, 0).getText());
  21. assertEquals("1. tammikuuta 1970", grid.getCell(0, 1).getText());
  22. assertEquals(
  23. epochDate.atTime(0, 0)
  24. .format(DateTimeFormatter
  25. .ofLocalizedDateTime(FormatStyle.LONG,
  26. FormatStyle.SHORT)
  27. .withLocale(new Locale("en"))),
  28. grid.getCell(0, 2).getText());
  29. assertEquals("1. tammikuuta 1970 klo 0.00.00",
  30. grid.getCell(0, 3).getText());
  31. }
  32. }