aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/grid/GridNullSafeNestedPropertyColumnTest.java
blob: 2ac67b7fc26c4c845b7935f79c06ea84fa77b80e (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
41
42
43
44
45
46
package com.vaadin.tests.components.grid;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.tb3.MultiBrowserTest;
import org.junit.Test;
import org.openqa.selenium.WebElement;

import java.util.List;

import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;

/**
 * Tests that using a nested property name with a null bean child property won't
 * cause an exception.
 */
@TestCategory("grid")
public class GridNullSafeNestedPropertyColumnTest extends MultiBrowserTest {

    @Test
    public void testNullNestedPropertyInSafeGridColumn() {
        openTestURL();
        waitForElementPresent(org.openqa.selenium.By.className("v-grid"));
        $(ButtonElement.class).id("safe").click();
        $(ButtonElement.class).id("add").click();
        List<WebElement> errorIndicator = findElements(
                By.className("v-errorindicator"));
        assertTrue(errorIndicator.isEmpty());
    }

    @Test
    public void testNullNestedPropertyInUnsafeGridColumn() {
        openTestURL();
        waitForElementPresent(org.openqa.selenium.By.className("v-grid"));
        $(ButtonElement.class).id("unsafe").click();
        $(ButtonElement.class).id("add").click();
        List<WebElement> errorIndicator = findElements(
                By.className("v-errorindicator"));
        assertFalse(
                "There should be an error indicator when adding nested null values to Grid",
                errorIndicator.isEmpty());
    }

}