diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-12 10:46:06 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-12 11:46:06 +0300 |
commit | c147b5d85bca3ddf30d9adbcd268066165889f37 (patch) | |
tree | 18d73bda278618004ec4a28ee62af7eb7edbeb98 /uitest | |
parent | 13d406a7086cc1546eac3fa86f6263bfb436de85 (diff) | |
download | vaadin-framework-c147b5d85bca3ddf30d9adbcd268066165889f37.tar.gz vaadin-framework-c147b5d85bca3ddf30d9adbcd268066165889f37.zip |
Use Collection.isEmpty() (#10172)
Diffstat (limited to 'uitest')
12 files changed, 25 insertions, 24 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java b/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java index 55e97c5a31..5f6c9d5cb5 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/KeyControl.java @@ -92,7 +92,7 @@ public class KeyControl extends TestBase { public void valueChange(ValueChangeEvent event) { @SuppressWarnings("unchecked") Set<String> value = (Set<String>) table3.getValue(); - selected3.setValue(value.size() == 0 ? "No selected items" + selected3.setValue(value.isEmpty() ? "No selected items" : value + ": Total " + value.size() + " items"); } }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java b/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java index a920be534f..fd39ec377b 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java @@ -109,7 +109,7 @@ public class LargeSelectionCausesNPE extends TestBase { // in multiselect mode, a Set of itemIds is returned, // in singleselect mode the itemId is returned directly Set<?> value = (Set<?>) event.getProperty().getValue(); - if (null == value || value.size() == 0) { + if (null == value || value.isEmpty()) { selected.setValue("No selection"); } else { selected.setValue("Selected: " + table.getValue()); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java index ca80a31e51..884f0a2d2b 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/CtrlShiftMultiselect.java @@ -36,7 +36,7 @@ public class CtrlShiftMultiselect extends TestBase { @SuppressWarnings("unchecked") // safe cast after instanceof check Set<Object> itemIds = (Set<Object>) tree.getValue(); - if (itemIds.size() == 0) { + if (itemIds.isEmpty()) { valueLbl.setValue("No selection"); } else { valueLbl.setValue(itemIds.toString()); diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java index 85765384c0..af88e41c1f 100644 --- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/ExpandCollapseTree.java @@ -36,7 +36,7 @@ public class ExpandCollapseTree extends TestBase { @SuppressWarnings("unchecked") // safe cast after instanceof check Set<Object> itemIds = (Set<Object>) tree.getValue(); - if (itemIds.size() == 0) { + if (itemIds.isEmpty()) { valueLbl.setValue("No selection"); } else { valueLbl.setValue(itemIds.toString()); diff --git a/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java index 689fe719e5..0db4875232 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java @@ -15,6 +15,7 @@ */ package com.vaadin.tests.components; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.List; @@ -36,7 +37,7 @@ public abstract class HasValueRequiredIndicatorTest extends MultiBrowserTest { public void requiredIndicatorVisible() { openTestURL(); List<WebElement> layouts = findElements(By.className("vaadin-layout")); - assertTrue(layouts.size() > 0); + assertFalse(layouts.isEmpty()); layouts.stream().forEach(this::checkRequiredIndicator); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java index 356f544f2d..36367e4b66 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -170,7 +169,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { assertItemSuffices(20); List<WebElement> icons = getSelect() .findElements(By.cssSelector(".v-select-optiongroup .v-icon")); - assertTrue(icons.size() > 0); + assertFalse(icons.isEmpty()); for (int i = 0; i < icons.size(); i++) { assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), icons.get(i).getText().charAt(0)); @@ -219,8 +218,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { } private void assertSelected(String... expectedSelection) { - assertEquals(Arrays.asList(expectedSelection), - getSelect().getValue()); + assertEquals(Arrays.asList(expectedSelection), getSelect().getValue()); } @Override @@ -276,7 +274,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { List<String> optionsIcons = new ArrayList<>(); for (WebElement option : getSelect().getOptionElements()) { List<WebElement> images = option.findElements(By.tagName("img")); - if (images.size() > 0) { + if (!images.isEmpty()) { optionsIcons.add(images.get(0).getAttribute("src")); } else { optionsIcons.add(null); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java index db0ad112a6..b156ee0f3e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFooterComponentsTest.java @@ -68,7 +68,7 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { int col) { GridCellElement cell = grid.getHeaderCell(row, col); List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); - if (all.size() == 0) { + if (all.isEmpty()) { return null; } else if (all.size() == 1) { return all.get(0); @@ -106,7 +106,7 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { int col) { GridCellElement cell = grid.getFooterCell(row, col); List<TextFieldElement> all = cell.$(TextFieldElement.class).all(); - if (all.size() == 0) { + if (all.isEmpty()) { return null; } else if (all.size() == 1) { return all.get(0); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java index 5febb3609b..b95cb5268d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableInIframeRowClickScrollJumpTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.components.table; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertFalse; import java.util.List; @@ -24,8 +25,8 @@ import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -96,7 +97,7 @@ public class TableInIframeRowClickScrollJumpTest extends MultiBrowserTest { public void switchIntoIframe() { List<WebElement> frames = driver.findElements(By.tagName("iframe")); - assertThat("No frames was found", frames.size() > 0); + assertFalse("No frames was found", frames.isEmpty()); driver.switchTo().frame(frames.get(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java index 48f8e782c6..adaf019719 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.components.table; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -70,12 +71,12 @@ public class TableToggleColumnVisibilityTest extends MultiBrowserTest { assertTrue("Column header text should be custom", headerCell.getText().equalsIgnoreCase("Hello World")); - assertTrue("Column should have an icon", - headerCell.findElements(By.className("v-icon")).size() > 0); + assertFalse("Column should have an icon", + headerCell.findElements(By.className("v-icon")).isEmpty()); - assertTrue("Column should have alignment to the right", headerCell + assertFalse("Column should have alignment to the right", headerCell .findElements( By.className("v-table-caption-container-align-right")) - .size() > 0); + .isEmpty()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java index fb97542862..4ad1a9aeb3 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/tabsheet/TabSheetElementTabWithoutCaptionTest.java @@ -104,7 +104,7 @@ public class TabSheetElementTabWithoutCaptionTest extends MultiBrowserTest { List<WebElement> openTabCaptionElements = tab .findElement(By.className("v-caption")) .findElements(By.className("v-captiontext")); - if (openTabCaptionElements.size() > 0) { + if (!openTabCaptionElements.isEmpty()) { String openTabCaption = openTabCaptionElements.get(0).getText(); assertEquals("Wrong tab is open.", caption, openTabCaption); } else { @@ -127,9 +127,9 @@ public class TabSheetElementTabWithoutCaptionTest extends MultiBrowserTest { boolean tabsOpen = false; for (int i = 0; i < tabs.size(); i++) { WebElement tab = tabs.get(i); - boolean isOpened = tab + boolean isOpened = !tab .findElements(By.className("v-tabsheet-tabitem-selected")) - .size() > 0; + .isEmpty(); if (isOpened) { tabsOpen = true; assertEquals("The wrong tab is open.", index, i); @@ -140,4 +140,4 @@ public class TabSheetElementTabWithoutCaptionTest extends MultiBrowserTest { + " should be open."); } } -}
\ No newline at end of file +} diff --git a/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java index 7865dd24ef..9f5330f538 100644 --- a/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java @@ -97,7 +97,7 @@ public class CalendarSmokeTest extends MultiBrowserTest { private WebElement getFirstDayWithEvents() { for (WebElement monthDay : getCalendar().getMonthDays()) { - if (getVisibleEvents(monthDay).size() > 0) { + if (!getVisibleEvents(monthDay).isEmpty()) { return monthDay; } } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java index c04104934b..3b3ab94e86 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -277,7 +277,7 @@ public abstract class AbstractTB3Test extends ParallelTest { parameters.add("restartApplication"); } - if (parameters.size() > 0) { + if (!parameters.isEmpty()) { url += "?" + StringUtils.join(parameters, "&"); } |