aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/grid/LocalDateRenderersTest.java
blob: 1bafdbaab2814a46207864330edbae47fcc51b9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.vaadin.tests.components.grid;

import static org.junit.Assert.assertEquals;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Locale;

import org.junit.Test;

import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class LocalDateRenderersTest extends SingleBrowserTest {

    @Test
    public void localDate_and_LocalDateTime_rendered_correctly() {
        openTestURL();

        GridElement grid = $(GridElement.class).first();

        LocalDate epochDate = LocalDate.ofEpochDay(0);
        assertEquals(
                epochDate.format(
                        DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG)
                                .withLocale(new Locale("en"))),
                grid.getCell(0, 0).getText());
        assertEquals("1. tammikuuta 1970", grid.getCell(0, 1).getText());
        assertEquals(
                epochDate.atTime(0, 0)
                        .format(DateTimeFormatter
                                .ofLocalizedDateTime(FormatStyle.LONG,
                                        FormatStyle.SHORT)
                                .withLocale(new Locale("en"))),
                grid.getCell(0, 2).getText());
        assertEquals("1. tammikuuta 1970 klo 0.00.00",
                grid.getCell(0, 3).getText());
    }
}