diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-03 12:56:25 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-03 13:56:25 +0300 |
commit | ccad305464af83826de4a4bd25a383360fb356d0 (patch) | |
tree | d399448d2910c4cf373e64c690b053740dff43ba | |
parent | 28b52d687dade66154a4fcd545415bf0d01b0a53 (diff) | |
download | vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.tar.gz vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.zip |
Use static import of Assert in tests (#10126)
Also removes dependency on junit.framework.TestCase .
735 files changed, 7245 insertions, 6600 deletions
diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java index a1a4d835d1..919e5a5b0e 100644 --- a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java +++ b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java @@ -32,12 +32,15 @@ import static com.vaadin.tools.CvalCheckerTest.readSystemOut; import static com.vaadin.tools.CvalCheckerTest.saveCache; import static com.vaadin.tools.CvalCheckerTest.unreachableLicenseProvider; import static com.vaadin.tools.CvalCheckerTest.validLicenseProvider; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.net.URL; import java.net.URLClassLoader; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -81,10 +84,10 @@ public class CvalAddonsCheckerTest { addonChecker.setLicenseProvider(validLicenseProvider); try { addonChecker.run(); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // We have a license that has never been validated from the server and // we are offline @@ -94,8 +97,8 @@ public class CvalAddonsCheckerTest { addonChecker.setLicenseProvider(unreachableLicenseProvider); captureSystemOut(); addonChecker.run(); - Assert.assertTrue(readSystemOut().contains("has not been validated")); - Assert.assertFalse(cacheExists(productNameCval)); + assertTrue(readSystemOut().contains("has not been validated")); + assertFalse(cacheExists(productNameCval)); // Valid license has previously been validated from the server and we // are offline @@ -104,7 +107,7 @@ public class CvalAddonsCheckerTest { addonChecker.setLicenseProvider(validLicenseProvider); captureSystemOut(); addonChecker.run(); - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); addonChecker.setLicenseProvider(unreachableLicenseProvider); addonChecker.run(); @@ -124,7 +127,7 @@ public class CvalAddonsCheckerTest { "normal"); try { addonChecker.run(); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { } @@ -137,9 +140,9 @@ public class CvalAddonsCheckerTest { "evaluation"); try { addonChecker.run(); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { - Assert.assertTrue(expected.getMessage().contains("expired")); + assertTrue(expected.getMessage().contains("expired")); } // Valid evaluation license @@ -151,9 +154,9 @@ public class CvalAddonsCheckerTest { setCacheFileTs(System.currentTimeMillis() + GRACE_DAYS_MSECS, "evaluation"); List<CValUiInfo> uiInfo = addonChecker.run(); - Assert.assertEquals(1, uiInfo.size()); - Assert.assertEquals("Test " + productNameCval, uiInfo.get(0).product); - Assert.assertEquals("evaluation", uiInfo.get(0).type); + assertEquals(1, uiInfo.size()); + assertEquals("Test " + productNameCval, uiInfo.get(0).product); + assertEquals("evaluation", uiInfo.get(0).type); // Valid real license // -> Work as expected @@ -164,7 +167,7 @@ public class CvalAddonsCheckerTest { addonChecker.setLicenseProvider(validLicenseProvider); captureSystemOut(); addonChecker.run(); - Assert.assertTrue(readSystemOut().contains("valid")); + assertTrue(readSystemOut().contains("valid")); } @Test @@ -178,9 +181,9 @@ public class CvalAddonsCheckerTest { captureSystemOut(); addonChecker.run(); String out = readSystemOut(); - Assert.assertTrue(out.contains("valid")); - Assert.assertTrue(out.contains("AGPL")); - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(out.contains("valid")); + assertTrue(out.contains("AGPL")); + assertTrue(cacheExists(productNameCval)); } private void setCacheFileTs(long expireTs, String type) { diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java index 4d1696b62a..e3180c4743 100644 --- a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java +++ b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java @@ -34,11 +34,12 @@ import static com.vaadin.tools.CvalCheckerTest.saveCache; import static com.vaadin.tools.CvalCheckerTest.unreachableLicenseProvider; import static com.vaadin.tools.CvalCheckerTest.validEvaluationLicenseProvider; import static com.vaadin.tools.CvalCheckerTest.validLicenseProvider; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.net.URL; import java.net.URLClassLoader; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -220,7 +221,8 @@ public class CvalAddonstCheckerUseCasesTest { deleteCache(productNameCval); } else { String type = lic == License.EVAL || lic == License.EVAL_EXPIRED - ? "evaluation" : null; + ? "evaluation" + : null; Boolean expired = lic == License.EVAL_EXPIRED || lic == License.REAL_EXPIRED ? true : null; String key = val == Validated.OLD_KEY ? "oldkey" : null; @@ -247,26 +249,24 @@ public class CvalAddonstCheckerUseCasesTest { addonChecker.run(); message = readSystemOut(); if (res == Compile.NO) { - Assert.fail(testNumber + "Exception not thrown:" + message); + fail(testNumber + "Exception not thrown:" + message); } } catch (Exception e) { restoreSystemOut(); message = e.getMessage(); if (res == Compile.YES) { - Assert.fail( - testNumber + "Unexpected Exception: " + e.getMessage()); + fail(testNumber + "Unexpected Exception: " + e.getMessage()); } } // System.err.println("\n> " + testNumber + " " + lic + " " + ver + " " // + val + " " + net + " " + res + " " + cached + "\n" + message); - Assert.assertTrue(testNumber + "Fail:\n" + message + "\nDoes not match:" + assertTrue(testNumber + "Fail:\n" + message + "\nDoes not match:" + msg.msg, message.matches("(?s).*" + msg.msg + ".*")); String c = cachedPreferences(productNameCval); - Assert.assertTrue(testNumber + "Fail: cacheExists != " - + (cached == Cached.YES) + "\n " + c, - (c != null) == (cached == Cached.YES)); + assertTrue(testNumber + "Fail: cacheExists != " + (cached == Cached.YES) + + "\n " + c, (c != null) == (cached == Cached.YES)); } } diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java index 441a8aa626..3e71eef4ca 100644 --- a/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java +++ b/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java @@ -25,8 +25,10 @@ import static com.vaadin.tools.CvalChecker.cacheLicenseInfo; import static com.vaadin.tools.CvalChecker.deleteCache; import static com.vaadin.tools.CvalChecker.parseJson; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.File; @@ -43,7 +45,6 @@ import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.prefs.Preferences; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -162,58 +163,58 @@ public class CvalCheckerTest { try { licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { assertEquals(productNameCval, expected.name); } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // If the license key is empty, throw an exception System.setProperty(licenseName, ""); try { licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { assertEquals(productNameCval, expected.name); } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // If license key is invalid, throw an exception System.setProperty(licenseName, "invalid"); try { licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { assertEquals(productNameCval, expected.name); } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // Fail if version is bigger System.setProperty(licenseName, VALID_KEY); try { licenseChecker.validateProduct(productNameCval, "3.0", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { assertEquals(productNameCval, expected.name); assertTrue(expected.getMessage().contains("is not valid")); } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // Success if license key and version are valid System.setProperty(licenseName, VALID_KEY); licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); // Success if license and cache file are valid, although the license // server is offline licenseChecker.setLicenseProvider(unreachableLicenseProvider); licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); // Fail if license key changes although cache file were validated // previously and it is ok, we are offline @@ -221,13 +222,13 @@ public class CvalCheckerTest { System.setProperty(licenseName, INVALID_KEY); licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { - Assert.fail(); + fail(); } catch (UnreachableCvalServerException expected) { assertEquals(productNameCval, expected.name); } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // Fail with unreachable exception if license has never verified and // server is offline @@ -235,13 +236,13 @@ public class CvalCheckerTest { System.setProperty(licenseName, VALID_KEY); licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { - Assert.fail(); + fail(); } catch (UnreachableCvalServerException expected) { assertEquals(productNameCval, expected.name); } - Assert.assertFalse(cacheExists(productNameCval)); + assertFalse(cacheExists(productNameCval)); // Fail when expired flag comes in the server response, although the // expired is valid. @@ -250,20 +251,20 @@ public class CvalCheckerTest { try { licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { assertEquals(productNameCval, expected.name); // Check that we use server customized message if it comes - Assert.assertTrue(expected.getMessage().contains("Custom")); + assertTrue(expected.getMessage().contains("Custom")); } - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); // Check an unlimited license deleteCache(productNameCval); licenseChecker.setLicenseProvider(unlimitedLicenseProvider); licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); // Fail if expired flag does not come, but expired epoch is in the past System.setProperty(licenseName, VALID_KEY); @@ -272,17 +273,17 @@ public class CvalCheckerTest { try { licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.fail(); + fail(); } catch (InvalidCvalException expected) { assertEquals(productNameCval, expected.name); } - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); deleteCache(productNameCval); licenseChecker.setLicenseProvider(nullVersionLicenseProvider); licenseChecker.validateProduct(productNameCval, "2.1", productTitleCval); - Assert.assertTrue(cacheExists(productNameCval)); + assertTrue(cacheExists(productNameCval)); } /* diff --git a/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java b/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java index 1329b7fdc9..563f16c334 100755 --- a/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java +++ b/client/src/test/java/com/vaadin/client/DateTimeServiceTest.java @@ -1,11 +1,12 @@ package com.vaadin.client; +import static org.junit.Assert.assertEquals; + import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Test; public class DateTimeServiceTest { @@ -77,7 +78,7 @@ public class DateTimeServiceTest { Date d = new Date(start + i * MILLISECONDS_PER_DAY); int expected = getCalendarISOWeekNr(d); int calculated = DateTimeService.getISOWeekNumber(d); - Assert.assertEquals(d + " should be week " + expected, expected, + assertEquals(d + " should be week " + expected, expected, calculated); } @@ -94,11 +95,11 @@ public class DateTimeServiceTest { // System.out.println("Sample: " + d); int expected = isoWeekNumbers.get(d); int calculated = DateTimeService.getISOWeekNumber(d); - Assert.assertEquals( + assertEquals( d + " should be week " + expected + " (Java Calendar is wrong?)", expected, getCalendarISOWeekNr(d)); - Assert.assertEquals(d + " should be week " + expected, expected, + assertEquals(d + " should be week " + expected, expected, calculated); } diff --git a/client/src/test/java/com/vaadin/client/LocatorUtilTest.java b/client/src/test/java/com/vaadin/client/LocatorUtilTest.java index 1a771c5281..3f785d6115 100644 --- a/client/src/test/java/com/vaadin/client/LocatorUtilTest.java +++ b/client/src/test/java/com/vaadin/client/LocatorUtilTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.client; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.client.componentlocator.LocatorUtil; @@ -28,53 +29,53 @@ public class LocatorUtilTest { @Test public void testIsUI1() { boolean isUI = LocatorUtil.isUIElement("com.vaadin.ui.UI"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsUI2() { boolean isUI = LocatorUtil.isUIElement("/com.vaadin.ui.UI"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsUI3() { boolean isUI = LocatorUtil .isUIElement("//com.vaadin.ui.UI[RandomString"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsUI4() { boolean isUI = LocatorUtil.isUIElement("//com.vaadin.ui.UI[0]"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification1() { boolean isUI = LocatorUtil .isNotificationElement("com.vaadin.ui.VNotification"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification2() { boolean isUI = LocatorUtil .isNotificationElement("com.vaadin.ui.Notification"); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification3() { boolean isUI = LocatorUtil .isNotificationElement("/com.vaadin.ui.VNotification["); - Assert.assertTrue(isUI); + assertTrue(isUI); } @Test public void testIsNotification4() { boolean isUI = LocatorUtil .isNotificationElement("//com.vaadin.ui.VNotification[0]"); - Assert.assertTrue(isUI); + assertTrue(isUI); } } diff --git a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java index 2594b3d09d..79d278acd1 100644 --- a/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java +++ b/client/src/test/java/com/vaadin/client/VBrowserDetailsUserAgentParserTest.java @@ -441,10 +441,10 @@ public class VBrowserDetailsUserAgentParserTest { @Test public void checkFFsupportedVersions() { VBrowserDetails details = new VBrowserDetails(FIREFOX_40B11_WIN); - Assert.assertTrue(details.isTooOldToFunctionProperly()); + assertTrue(details.isTooOldToFunctionProperly()); details = new VBrowserDetails(FIREFOX_SUPPORTED); - Assert.assertFalse(details.isTooOldToFunctionProperly()); + assertFalse(details.isTooOldToFunctionProperly()); } /* @@ -634,7 +634,7 @@ public class VBrowserDetailsUserAgentParserTest { assertFalse(browserDetails.isIOS()); assertFalse(browserDetails.isAndroid()); assertFalse(browserDetails.isChromeOS()); - Assert.assertEquals(isWindowsPhone, browserDetails.isWindowsPhone()); + assertEquals(isWindowsPhone, browserDetails.isWindowsPhone()); } private void assertLinux(VBrowserDetails browserDetails) { diff --git a/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java b/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java index ee39492bbf..278bc67414 100644 --- a/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java +++ b/client/src/test/java/com/vaadin/client/communication/ServerMessageHandlerTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.client.communication; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import org.junit.Test; /** @@ -28,7 +30,7 @@ public class ServerMessageHandlerTest { @Test public void unwrapValidJson() { String payload = "{'foo': 'bar'}"; - Assert.assertEquals(payload, + assertEquals(payload, MessageHandler.stripJSONWrapping("for(;;);[" + payload + "]")); } @@ -36,19 +38,19 @@ public class ServerMessageHandlerTest { @Test public void unwrapUnwrappedJson() { String payload = "{'foo': 'bar'}"; - Assert.assertNull(MessageHandler.stripJSONWrapping(payload)); + assertNull(MessageHandler.stripJSONWrapping(payload)); } @Test public void unwrapNull() { - Assert.assertNull(MessageHandler.stripJSONWrapping(null)); + assertNull(MessageHandler.stripJSONWrapping(null)); } @Test public void unwrapEmpty() { - Assert.assertNull(MessageHandler.stripJSONWrapping("")); + assertNull(MessageHandler.stripJSONWrapping("")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java b/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java index 00022ba44c..cea9f7a135 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/ComponentDesignWriterUtility.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.lang.reflect.Modifier; import java.net.URISyntaxException; @@ -11,7 +13,6 @@ import java.util.stream.Collectors; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Test; import com.vaadin.navigator.Navigator; @@ -47,23 +48,23 @@ public class ComponentDesignWriterUtility { WHITE_LIST_FQNS.add(ColorPickerSelect.class.getName()); WHITE_LIST_FQNS.add(ColorPickerHistory.class.getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerGradient.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerGradient.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerPopup.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerPopup.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerPreview.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerPreview.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerGrid.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerGrid.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerSelect.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerSelect.class .getName()); - WHITE_LIST_FQNS - .add(com.vaadin.v7.ui.components.colorpicker.ColorPickerHistory.class + WHITE_LIST_FQNS.add( + com.vaadin.v7.ui.components.colorpicker.ColorPickerHistory.class .getName()); // ================================================================== @@ -113,7 +114,7 @@ public class ComponentDesignWriterUtility { @Test public void vaadin8ComponentsElementStartsWithVaadinPrefix() throws URISyntaxException { - Assert.assertTrue(getVaadin8Components().stream() + assertTrue(getVaadin8Components().stream() .map(ComponentDesignWriterUtility::getDeclarativeSyntax) .allMatch(element -> element.startsWith("<vaadin-"))); } @@ -121,7 +122,7 @@ public class ComponentDesignWriterUtility { @Test public void vaadin7ComponentsElementStartsWithVaadinPrefix() throws URISyntaxException { - Assert.assertTrue(getVaadin7Components().stream() + assertTrue(getVaadin7Components().stream() .map(ComponentDesignWriterUtility::getDeclarativeSyntax) .allMatch(element -> element.startsWith("<vaadin7-"))); } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java index f00592af6d..38380483a6 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/DeprecatedTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.server; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + import java.io.File; import java.net.URISyntaxException; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; import org.junit.Test; /** @@ -40,13 +42,11 @@ public class DeprecatedTest { && !testRoot.equals(new File(entry))) .forEach(cls -> { count.incrementAndGet(); - Assert.assertNotNull( - "Class " + cls - + " is in compatability package and it's not deprecated", + assertNotNull("Class " + cls + + " is in compatability package and it's not deprecated", cls.getAnnotation(Deprecated.class)); }); - Assert.assertNotEquals("Total number of checked classes", 0, - count.get()); + assertNotEquals("Total number of checked classes", 0, count.get()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index 7924b36f7e..0252da62ac 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -1,5 +1,8 @@ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; @@ -7,7 +10,6 @@ import java.util.HashSet; import java.util.Set; import org.easymock.EasyMock; -import org.junit.Assert; import com.vaadin.tests.VaadinClasses; import com.vaadin.ui.Component; @@ -54,13 +56,11 @@ public abstract class AbstractListenerMethodsTestBase { .getName() + ";"); System.out.println("import " + c.getName() + ";"); - System.out - .println( - "public class " + c.getSimpleName() - + "Listeners extends " - + AbstractListenerMethodsTestBase.class - .getSimpleName() - + " {"); + System.out.println("public class " + c.getSimpleName() + + "Listeners extends " + + AbstractListenerMethodsTestBase.class + .getSimpleName() + + " {"); } String listenerClassName = m.getParameterTypes()[0] @@ -174,11 +174,10 @@ public abstract class AbstractListenerMethodsTestBase { SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Collection<?> registeredListeners = getListeners(c, eventClass); - Assert.assertEquals("Number of listeners", expectedListeners.length, + assertEquals("Number of listeners", expectedListeners.length, registeredListeners.size()); - Assert.assertArrayEquals(expectedListeners, - registeredListeners.toArray()); + assertArrayEquals(expectedListeners, registeredListeners.toArray()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java index 1f7783dda5..a2d40836b6 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java @@ -3,8 +3,8 @@ package com.vaadin.tests.server.component.slider; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.fail; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Slider; @@ -61,7 +61,7 @@ public class SliderTest { try { s.setValue(20.0); - Assert.fail("Should throw out of bounds exception"); + fail("Should throw out of bounds exception"); } catch (Slider.ValueOutOfBoundsException e) { // TODO: handle exception } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java index fdb0ae2bf3..9e213fbb1d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/BeanFieldGroupTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.data.fieldgroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class BeanFieldGroupTest { @@ -63,8 +64,8 @@ public class BeanFieldGroupTest { public void propertyTypeWithoutItem() { BeanFieldGroup<Sub2> s = new BeanFieldGroup<BeanFieldGroupTest.Sub2>( Sub2.class); - Assert.assertEquals(boolean.class, s.getPropertyType("sub2field")); - Assert.assertEquals(Integer.class, s.getPropertyType("sub1Field")); - Assert.assertEquals(String.class, s.getPropertyType("mainField")); + assertEquals(boolean.class, s.getPropertyType("sub2field")); + assertEquals(Integer.class, s.getPropertyType("sub1Field")); + assertEquals(String.class, s.getPropertyType("mainField")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java index 38ac1a8f9c..e502da734c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactoryTest.java @@ -15,10 +15,13 @@ */ package com.vaadin.v7.data.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.util.Date; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -44,7 +47,7 @@ public class DefaultFieldGroupFieldFactoryTest { public void noPublicConstructor() { Class<DefaultFieldGroupFieldFactory> clazz = DefaultFieldGroupFieldFactory.class; Constructor<?>[] constructors = clazz.getConstructors(); - Assert.assertEquals( + assertEquals( "DefaultFieldGroupFieldFactory contains public constructors", 0, constructors.length); } @@ -55,40 +58,39 @@ public class DefaultFieldGroupFieldFactoryTest { .get(); DefaultFieldGroupFieldFactory factory2 = DefaultFieldGroupFieldFactory .get(); - Assert.assertTrue( + assertTrue( "DefaultFieldGroupFieldFactory.get() method returns different instances", factory1 == factory2); - Assert.assertNotNull( - "DefaultFieldGroupFieldFactory.get() method returns null", + assertNotNull("DefaultFieldGroupFieldFactory.get() method returns null", factory1); } @Test public void testDateGenerationForPopupDateField() { Field f = fieldFactory.createField(Date.class, DateField.class); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } @Test public void testDateGenerationForInlineDateField() { Field f = fieldFactory.createField(Date.class, InlineDateField.class); - Assert.assertNotNull(f); - Assert.assertEquals(InlineDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(InlineDateField.class, f.getClass()); } @Test public void testDateGenerationForTextField() { Field f = fieldFactory.createField(Date.class, TextField.class); - Assert.assertNotNull(f); - Assert.assertEquals(TextField.class, f.getClass()); + assertNotNull(f); + assertEquals(TextField.class, f.getClass()); } @Test public void testDateGenerationForField() { Field f = fieldFactory.createField(Date.class, Field.class); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } public enum SomeEnum { @@ -98,22 +100,22 @@ public class DefaultFieldGroupFieldFactoryTest { @Test public void testEnumComboBox() { Field f = fieldFactory.createField(SomeEnum.class, ComboBox.class); - Assert.assertNotNull(f); - Assert.assertEquals(ComboBox.class, f.getClass()); + assertNotNull(f); + assertEquals(ComboBox.class, f.getClass()); } @Test public void testEnumAnySelect() { Field f = fieldFactory.createField(SomeEnum.class, AbstractSelect.class); - Assert.assertNotNull(f); - Assert.assertEquals(ListSelect.class, f.getClass()); + assertNotNull(f); + assertEquals(ListSelect.class, f.getClass()); } @Test public void testEnumAnyField() { Field f = fieldFactory.createField(SomeEnum.class, Field.class); - Assert.assertNotNull(f); - Assert.assertEquals(ListSelect.class, f.getClass()); + assertNotNull(f); + assertEquals(ListSelect.class, f.getClass()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java index d354729bea..728860dcf3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupDateTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.v7.data.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.Date; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -67,15 +69,15 @@ public class FieldGroupDateTest { @Test public void testBuildAndBindDate() { Field f = fieldGroup.buildAndBind("javaDate"); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } @Test public void testBuildAndBindSqlDate() { Field f = fieldGroup.buildAndBind("sqlDate"); - Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + assertNotNull(f); + assertEquals(PopupDateField.class, f.getClass()); } @Test @@ -85,12 +87,12 @@ public class FieldGroupDateTest { fieldGroup.bind(sqlDate, "sqlDate"); fieldGroup.bind(javaDate, "javaDate"); - Assert.assertEquals(new Date(2010, 5, 7), javaDate.getValue()); - Assert.assertEquals(new Date(2011, 6, 8), sqlDate.getValue()); + assertEquals(new Date(2010, 5, 7), javaDate.getValue()); + assertEquals(new Date(2011, 6, 8), sqlDate.getValue()); fieldGroup.clear(); - Assert.assertEquals(null, javaDate.getValue()); - Assert.assertEquals(null, sqlDate.getValue()); + assertEquals(null, javaDate.getValue()); + assertEquals(null, sqlDate.getValue()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java index c8d98c14b5..219bd07815 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/fieldgroup/FieldGroupTest.java @@ -3,9 +3,9 @@ package com.vaadin.v7.data.fieldgroup; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -67,7 +67,7 @@ public class FieldGroupTest { group.bind(field, "name"); Property propertyDataSource = field.getPropertyDataSource(); - Assert.assertTrue( + assertTrue( "Custom implementation of transactional property " + "has not been used", propertyDataSource instanceof TransactionalPropertyImpl); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java index 7ff24f76ae..bfbf6d4eb2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/AbstractContainerTestBase.java @@ -42,7 +42,7 @@ public abstract class AbstractContainerTestBase { * Check that no one event has occurred since the previous assert call. */ public void assertNone() { - Assert.assertEquals(lastAssertedEventCount, eventCount); + assertEquals(lastAssertedEventCount, eventCount); } /** @@ -50,7 +50,7 @@ public abstract class AbstractContainerTestBase { * call. */ public void assertOnce() { - Assert.assertEquals(++lastAssertedEventCount, eventCount); + assertEquals(++lastAssertedEventCount, eventCount); } /** @@ -154,7 +154,7 @@ public abstract class AbstractContainerTestBase { } // getItemProperty - Assert.assertNull( + assertNull( container.getItem(itemIdInSet).getItemProperty("notinset")); } @@ -208,20 +208,20 @@ public abstract class AbstractContainerTestBase { container.removeAllItems(); Object id = container.addItem(); - Assert.assertTrue(container.containsId(id)); - Assert.assertNotNull(container.getItem(id)); + assertTrue(container.containsId(id)); + assertNotNull(container.getItem(id)); Item item = container.addItem("foo"); - Assert.assertNotNull(item); - Assert.assertTrue(container.containsId("foo")); - Assert.assertEquals(item, container.getItem("foo")); + assertNotNull(item); + assertTrue(container.containsId("foo")); + assertEquals(item, container.getItem("foo")); // Add again Item item2 = container.addItem("foo"); - Assert.assertNull(item2); + assertNull(item2); // Null is not a valid itemId - Assert.assertNull(container.addItem(null)); + assertNull(container.addItem(null)); } catch (UnsupportedOperationException e) { // Ignore contains which do not support addItem* } @@ -232,25 +232,25 @@ public abstract class AbstractContainerTestBase { container.removeAllItems(); Object id = container.addItemAt(0); - Assert.assertTrue(container.containsId(id)); - Assert.assertEquals(id, container.getIdByIndex(0)); - Assert.assertNotNull(container.getItem(id)); + assertTrue(container.containsId(id)); + assertEquals(id, container.getIdByIndex(0)); + assertNotNull(container.getItem(id)); Item item = container.addItemAt(0, "foo"); - Assert.assertNotNull(item); - Assert.assertTrue(container.containsId("foo")); - Assert.assertEquals(item, container.getItem("foo")); - Assert.assertEquals("foo", container.getIdByIndex(0)); + assertNotNull(item); + assertTrue(container.containsId("foo")); + assertEquals(item, container.getItem("foo")); + assertEquals("foo", container.getIdByIndex(0)); Item itemAtEnd = container.addItemAt(2, "atend"); - Assert.assertNotNull(itemAtEnd); - Assert.assertTrue(container.containsId("atend")); - Assert.assertEquals(itemAtEnd, container.getItem("atend")); - Assert.assertEquals("atend", container.getIdByIndex(2)); + assertNotNull(itemAtEnd); + assertTrue(container.containsId("atend")); + assertEquals(itemAtEnd, container.getItem("atend")); + assertEquals("atend", container.getIdByIndex(2)); // Add again Item item2 = container.addItemAt(0, "foo"); - Assert.assertNull(item2); + assertNull(item2); } catch (UnsupportedOperationException e) { // Ignore contains which do not support addItem* } @@ -265,28 +265,28 @@ public abstract class AbstractContainerTestBase { try { container.removeAllItems(); - Assert.assertNotNull(container.addItem(0)); + assertNotNull(container.addItem(0)); Item item = container.addItemAfter(null, "foo"); - Assert.assertNotNull(item); - Assert.assertTrue(container.containsId("foo")); - Assert.assertEquals(item, container.getItem("foo")); - Assert.assertEquals("foo", + assertNotNull(item); + assertTrue(container.containsId("foo")); + assertEquals(item, container.getItem("foo")); + assertEquals("foo", container.getItemIds().iterator().next()); Item itemAtEnd = container.addItemAfter(0, "atend"); - Assert.assertNotNull(itemAtEnd); - Assert.assertTrue(container.containsId("atend")); - Assert.assertEquals(itemAtEnd, container.getItem("atend")); + assertNotNull(itemAtEnd); + assertTrue(container.containsId("atend")); + assertEquals(itemAtEnd, container.getItem("atend")); Iterator<?> i = container.getItemIds().iterator(); i.next(); i.next(); - Assert.assertEquals("atend", i.next()); + assertEquals("atend", i.next()); // Add again - Assert.assertNull(container.addItemAfter(null, "foo")); - Assert.assertNull(container.addItemAfter("atend", "foo")); - Assert.assertNull(container.addItemAfter("nonexistant", "123123")); + assertNull(container.addItemAfter(null, "foo")); + assertNull(container.addItemAfter("atend", "foo")); + assertNull(container.addItemAfter("nonexistant", "123123")); } catch (UnsupportedOperationException e) { // Ignore contains which do not support addItem* } @@ -421,43 +421,43 @@ public abstract class AbstractContainerTestBase { initializeContainer(container); // indexOfId - Assert.assertEquals(itemPosition, container.indexOfId(itemId)); + assertEquals(itemPosition, container.indexOfId(itemId)); // getIdByIndex - Assert.assertEquals(itemId, container.getIdByIndex(itemPosition)); + assertEquals(itemId, container.getIdByIndex(itemPosition)); // addItemAt if (testAddEmptyItemAt) { Object addedId = container.addItemAt(itemPosition); - Assert.assertEquals(itemPosition, container.indexOfId(addedId)); - Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId)); - Assert.assertEquals(addedId, container.getIdByIndex(itemPosition)); - Assert.assertEquals(itemId, + assertEquals(itemPosition, container.indexOfId(addedId)); + assertEquals(itemPosition + 1, container.indexOfId(itemId)); + assertEquals(addedId, container.getIdByIndex(itemPosition)); + assertEquals(itemId, container.getIdByIndex(itemPosition + 1)); Object newFirstId = container.addItemAt(0); - Assert.assertEquals(0, container.indexOfId(newFirstId)); - Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId)); - Assert.assertEquals(newFirstId, container.firstItemId()); - Assert.assertEquals(newFirstId, container.getIdByIndex(0)); - Assert.assertEquals(itemId, + assertEquals(0, container.indexOfId(newFirstId)); + assertEquals(itemPosition + 2, container.indexOfId(itemId)); + assertEquals(newFirstId, container.firstItemId()); + assertEquals(newFirstId, container.getIdByIndex(0)); + assertEquals(itemId, container.getIdByIndex(itemPosition + 2)); Object newLastId = container.addItemAt(container.size()); - Assert.assertEquals(container.size() - 1, + assertEquals(container.size() - 1, container.indexOfId(newLastId)); - Assert.assertEquals(itemPosition + 2, container.indexOfId(itemId)); - Assert.assertEquals(newLastId, container.lastItemId()); - Assert.assertEquals(newLastId, + assertEquals(itemPosition + 2, container.indexOfId(itemId)); + assertEquals(newLastId, container.lastItemId()); + assertEquals(newLastId, container.getIdByIndex(container.size() - 1)); - Assert.assertEquals(itemId, + assertEquals(itemId, container.getIdByIndex(itemPosition + 2)); - Assert.assertTrue(container.removeItem(addedId)); - Assert.assertTrue(container.removeItem(newFirstId)); - Assert.assertTrue(container.removeItem(newLastId)); + assertTrue(container.removeItem(addedId)); + assertTrue(container.removeItem(newFirstId)); + assertTrue(container.removeItem(newLastId)); - Assert.assertFalse( + assertFalse( "Removing non-existing item should indicate failure", container.removeItem(addedId)); } @@ -465,35 +465,35 @@ public abstract class AbstractContainerTestBase { // addItemAt if (testAddItemAtWithId) { container.addItemAt(itemPosition, newItemId); - Assert.assertEquals(itemPosition, container.indexOfId(newItemId)); - Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId)); - Assert.assertEquals(newItemId, + assertEquals(itemPosition, container.indexOfId(newItemId)); + assertEquals(itemPosition + 1, container.indexOfId(itemId)); + assertEquals(newItemId, container.getIdByIndex(itemPosition)); - Assert.assertEquals(itemId, + assertEquals(itemId, container.getIdByIndex(itemPosition + 1)); - Assert.assertTrue(container.removeItem(newItemId)); - Assert.assertFalse(container.containsId(newItemId)); + assertTrue(container.removeItem(newItemId)); + assertFalse(container.containsId(newItemId)); container.addItemAt(0, newItemId); - Assert.assertEquals(0, container.indexOfId(newItemId)); - Assert.assertEquals(itemPosition + 1, container.indexOfId(itemId)); - Assert.assertEquals(newItemId, container.firstItemId()); - Assert.assertEquals(newItemId, container.getIdByIndex(0)); - Assert.assertEquals(itemId, + assertEquals(0, container.indexOfId(newItemId)); + assertEquals(itemPosition + 1, container.indexOfId(itemId)); + assertEquals(newItemId, container.firstItemId()); + assertEquals(newItemId, container.getIdByIndex(0)); + assertEquals(itemId, container.getIdByIndex(itemPosition + 1)); - Assert.assertTrue(container.removeItem(newItemId)); - Assert.assertFalse(container.containsId(newItemId)); + assertTrue(container.removeItem(newItemId)); + assertFalse(container.containsId(newItemId)); container.addItemAt(container.size(), newItemId); - Assert.assertEquals(container.size() - 1, + assertEquals(container.size() - 1, container.indexOfId(newItemId)); - Assert.assertEquals(itemPosition, container.indexOfId(itemId)); - Assert.assertEquals(newItemId, container.lastItemId()); - Assert.assertEquals(newItemId, + assertEquals(itemPosition, container.indexOfId(itemId)); + assertEquals(newItemId, container.lastItemId()); + assertEquals(newItemId, container.getIdByIndex(container.size() - 1)); - Assert.assertEquals(itemId, container.getIdByIndex(itemPosition)); - Assert.assertTrue(container.removeItem(newItemId)); - Assert.assertFalse(container.containsId(newItemId)); + assertEquals(itemId, container.getIdByIndex(itemPosition)); + assertTrue(container.removeItem(newItemId)); + assertFalse(container.containsId(newItemId)); } } @@ -597,7 +597,7 @@ public abstract class AbstractContainerTestBase { } protected void initializeContainer(Container container) { - Assert.assertTrue(container.removeAllItems()); + assertTrue(container.removeAllItems()); Object[] propertyIds = container.getContainerPropertyIds().toArray(); for (Object propertyId : propertyIds) { container.removeContainerProperty(propertyId); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java index f536fb489e..a7cf440279 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanContainerTest.java @@ -79,7 +79,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { @Test public void testGetType_existingProperty_typeReturned() { BeanContainer<String, ClassName> container = getContainer(); - Assert.assertEquals( + assertEquals( "Unexpected type is returned for property 'simpleName'", String.class, container.getType("simpleName")); } @@ -87,7 +87,7 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { @Test public void testGetType_notExistingProperty_nullReturned() { BeanContainer<String, ClassName> container = getContainer(); - Assert.assertNull("Not null type is returned for property ''", + assertNull("Not null type is returned for property ''", container.getType("")); } @@ -222,49 +222,49 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { try { container.addItem(); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItem(null); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAfter(null, null); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAfter(new Person("Jane")); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAt(0); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAt(0, new Person("Jane")); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addContainerProperty("lastName", String.class, ""); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } @@ -279,14 +279,14 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { container.setBeanIdResolver(new PersonNameResolver()); container.addBean(new Person("John")); - Assert.assertEquals("John", + assertEquals("John", container.getContainerProperty("John", "name").getValue()); - Assert.assertTrue(container.removeContainerProperty("name")); - Assert.assertNull(container.getContainerProperty("John", "name")); + assertTrue(container.removeContainerProperty("name")); + assertNull(container.getContainerProperty("John", "name")); - Assert.assertNotNull(container.getItem("John")); + assertNotNull(container.getItem("John")); // property removed also from item - Assert.assertNull(container.getItem("John").getItemProperty("name")); + assertNull(container.getItem("John").getItemProperty("name")); } @Test @@ -335,26 +335,26 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { try { container.addBean(new Person("John")); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } try { container.addBeanAfter(null, new Person("Jane")); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } try { container.addBeanAt(0, new Person("Jack")); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } try { container .addAll(Arrays.asList(new Person[] { new Person("Jack") })); - Assert.fail(); + fail(); } catch (IllegalStateException e) { // should get exception } @@ -404,19 +404,19 @@ public class BeanContainerTest extends AbstractBeanContainerTestBase { try { container.addBean(new Person("John")); - Assert.fail(); + fail(); } catch (IllegalArgumentException e) { // should get exception } try { container.addBeanAfter(null, new Person("Jane")); - Assert.fail(); + fail(); } catch (IllegalArgumentException e) { // should get exception } try { container.addBeanAt(0, new Person("Jack")); - Assert.fail(); + fail(); } catch (IllegalArgumentException e) { // should get exception } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java index 9ad0c65f1a..4c228c59f3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerSortTest.java @@ -1,5 +1,8 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -7,7 +10,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Assert; import org.junit.Test; public class BeanItemContainerSortTest { @@ -45,11 +47,10 @@ public class BeanItemContainerSortTest { } } - String[] names = { "Antti", "Ville", "Sirkka", "Jaakko", - "Pekka", "John" }; + String[] names = { "Antti", "Ville", "Sirkka", "Jaakko", "Pekka", "John" }; int[] ages = { 10, 20, 50, 12, 64, 67 }; - String[] sortedByAge = { names[0], names[3], names[1], - names[2], names[4], names[5] }; + String[] sortedByAge = { names[0], names[3], names[1], names[2], names[4], + names[5] }; public BeanItemContainer<Person> getContainer() { BeanItemContainer<Person> bc = new BeanItemContainer<Person>( @@ -94,8 +95,8 @@ public class BeanItemContainerSortTest { int i = 0; for (String string : asList) { Person idByIndex = container.getIdByIndex(i++); - Assert.assertTrue(container.containsId(idByIndex)); - Assert.assertEquals(string, idByIndex.getName()); + assertTrue(container.containsId(idByIndex)); + assertEquals(string, idByIndex.getName()); } } @@ -112,8 +113,8 @@ public class BeanItemContainerSortTest { int i = 0; for (String string : sortedByAge) { Person idByIndex = container.getIdByIndex(i++); - Assert.assertTrue(container.containsId(idByIndex)); - Assert.assertEquals(string, idByIndex.getName()); + assertTrue(container.containsId(idByIndex)); + assertEquals(string, idByIndex.getName()); } } @@ -134,8 +135,8 @@ public class BeanItemContainerSortTest { int i = container.size() - 1; for (String string : sortedByAge) { Person idByIndex = container.getIdByIndex(i--); - Assert.assertTrue(container.containsId(idByIndex)); - Assert.assertEquals(string, idByIndex.getName()); + assertTrue(container.containsId(idByIndex)); + assertEquals(string, idByIndex.getName()); } } @@ -145,22 +146,22 @@ public class BeanItemContainerSortTest { Collection<?> sortablePropertyIds = container .getSortableContainerPropertyIds(); - Assert.assertEquals(2, sortablePropertyIds.size()); - Assert.assertTrue(sortablePropertyIds.contains("name")); - Assert.assertTrue(sortablePropertyIds.contains("age")); + assertEquals(2, sortablePropertyIds.size()); + assertTrue(sortablePropertyIds.contains("name")); + assertTrue(sortablePropertyIds.contains("age")); } @Test public void testGetNonSortableProperties() { BeanItemContainer<Parent> container = getParentContainer(); - Assert.assertEquals(3, container.getContainerPropertyIds().size()); + assertEquals(3, container.getContainerPropertyIds().size()); Collection<?> sortablePropertyIds = container .getSortableContainerPropertyIds(); - Assert.assertEquals(2, sortablePropertyIds.size()); - Assert.assertTrue(sortablePropertyIds.contains("name")); - Assert.assertTrue(sortablePropertyIds.contains("age")); + assertEquals(2, sortablePropertyIds.size()); + assertTrue(sortablePropertyIds.contains("name")); + assertTrue(sortablePropertyIds.contains("age")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java index dee7c3fee3..c6ef1f4ab0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemContainerTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Arrays; @@ -15,7 +16,6 @@ import java.util.Map; import org.easymock.Capture; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -86,15 +86,14 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { @Test public void testGetType_existingProperty_typeReturned() { BeanItemContainer<ClassName> container = getContainer(); - Assert.assertEquals( - "Unexpected type is returned for property 'simpleName'", + assertEquals("Unexpected type is returned for property 'simpleName'", String.class, container.getType("simpleName")); } @Test public void testGetType_notExistingProperty_nullReturned() { BeanItemContainer<ClassName> container = getContainer(); - Assert.assertNull("Not null type is returned for property ''", + assertNull("Not null type is returned for property ''", container.getType("")); } @@ -213,18 +212,18 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { BeanItemContainer<ClassName> container = new BeanItemContainer<ClassName>( classNames); - Assert.assertEquals(3, container.size()); - Assert.assertEquals(classNames.get(0), container.firstItemId()); - Assert.assertEquals(classNames.get(1), container.getIdByIndex(1)); - Assert.assertEquals(classNames.get(2), container.lastItemId()); + assertEquals(3, container.size()); + assertEquals(classNames.get(0), container.firstItemId()); + assertEquals(classNames.get(1), container.getIdByIndex(1)); + assertEquals(classNames.get(2), container.lastItemId()); BeanItemContainer<ClassName> container2 = new BeanItemContainer<ClassName>( ClassName.class, classNames); - Assert.assertEquals(3, container2.size()); - Assert.assertEquals(classNames.get(0), container2.firstItemId()); - Assert.assertEquals(classNames.get(1), container2.getIdByIndex(1)); - Assert.assertEquals(classNames.get(2), container2.lastItemId()); + assertEquals(3, container2.size()); + assertEquals(classNames.get(0), container2.firstItemId()); + assertEquals(classNames.get(1), container2.getIdByIndex(1)); + assertEquals(classNames.get(2), container2.lastItemId()); } // this only applies to the collection constructor with no type parameter @@ -233,15 +232,13 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { public void testEmptyCollectionConstructor() { try { new BeanItemContainer<ClassName>((Collection<ClassName>) null); - Assert.fail( - "Initializing BeanItemContainer from a null collection should not work!"); + fail("Initializing BeanItemContainer from a null collection should not work!"); } catch (IllegalArgumentException e) { // success } try { new BeanItemContainer<ClassName>(new ArrayList<ClassName>()); - Assert.fail( - "Initializing BeanItemContainer from an empty collection should not work!"); + fail("Initializing BeanItemContainer from an empty collection should not work!"); } catch (IllegalArgumentException e) { // success } @@ -275,7 +272,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(null, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -283,7 +280,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.firstItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -291,7 +288,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.lastItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -299,7 +296,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(0, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -307,7 +304,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(1, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -315,7 +312,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(container.size(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -401,7 +398,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(null, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -409,7 +406,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.firstItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -417,7 +414,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAfter(container.lastItemId(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -425,7 +422,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(0, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.firstItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -433,7 +430,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(1, cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.getIdByIndex(1), FULLY_QUALIFIED_NAME).getValue()); @@ -441,7 +438,7 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { counter.reset(); container.addItemAt(container.size(), cn1); counter.assertOnce(); - Assert.assertEquals("com.example.Test", + assertEquals("com.example.Test", container.getContainerProperty(container.lastItemId(), FULLY_QUALIFIED_NAME).getValue()); @@ -655,28 +652,28 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { try { container.addItem(); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAfter(new Person("Jane")); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addItemAt(0); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } try { container.addContainerProperty("lastName", String.class, ""); - Assert.fail(); + fail(); } catch (UnsupportedOperationException e) { // should get exception } @@ -691,14 +688,14 @@ public class BeanItemContainerTest extends AbstractBeanContainerTestBase { Person john = new Person("John"); container.addBean(john); - Assert.assertEquals("John", + assertEquals("John", container.getContainerProperty(john, "name").getValue()); - Assert.assertTrue(container.removeContainerProperty("name")); - Assert.assertNull(container.getContainerProperty(john, "name")); + assertTrue(container.removeContainerProperty("name")); + assertNull(container.getContainerProperty(john, "name")); - Assert.assertNotNull(container.getItem(john)); + assertNotNull(container.getItem(john)); // property removed also from item - Assert.assertNull(container.getItem(john).getItemProperty("name")); + assertNull(container.getItem(john).getItemProperty("name")); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java index 8232f9d532..76d25d1db5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/BeanItemTest.java @@ -1,5 +1,9 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -9,7 +13,6 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property; @@ -166,10 +169,10 @@ public class BeanItemTest { new MySuperClass()); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(3, itemPropertyIds.size()); - Assert.assertTrue(itemPropertyIds.contains("superPrivate")); - Assert.assertTrue(itemPropertyIds.contains("superProtected")); - Assert.assertTrue(itemPropertyIds.contains("superPublic")); + assertEquals(3, itemPropertyIds.size()); + assertTrue(itemPropertyIds.contains("superPrivate")); + assertTrue(itemPropertyIds.contains("superProtected")); + assertTrue(itemPropertyIds.contains("superPublic")); } @Test @@ -177,13 +180,13 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); - Assert.assertTrue(itemPropertyIds.contains("superPrivate")); - Assert.assertTrue(itemPropertyIds.contains("superProtected")); - Assert.assertTrue(itemPropertyIds.contains("superPublic")); - Assert.assertTrue(itemPropertyIds.contains("name")); - Assert.assertTrue(itemPropertyIds.contains("noField")); - Assert.assertTrue(itemPropertyIds.contains("name2")); + assertEquals(6, itemPropertyIds.size()); + assertTrue(itemPropertyIds.contains("superPrivate")); + assertTrue(itemPropertyIds.contains("superProtected")); + assertTrue(itemPropertyIds.contains("superPublic")); + assertTrue(itemPropertyIds.contains("name")); + assertTrue(itemPropertyIds.contains("noField")); + assertTrue(itemPropertyIds.contains("name2")); } @Test @@ -191,12 +194,12 @@ public class BeanItemTest { BeanItem<MyClass2> item = new BeanItem<MyClass2>(new MyClass2("bean2")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); + assertEquals(6, itemPropertyIds.size()); - Assert.assertTrue(MyClass2.class.equals(item.getBean().getClass())); + assertTrue(MyClass2.class.equals(item.getBean().getClass())); // check that name2 accessed via MyClass2, not MyClass - Assert.assertFalse(item.getItemProperty("name2").isReadOnly()); + assertFalse(item.getItemProperty("name2").isReadOnly()); } @Test @@ -209,13 +212,13 @@ public class BeanItemTest { LinkedHashMap<String, VaadinPropertyDescriptor<Class>> propertyDescriptors = (LinkedHashMap<String, VaadinPropertyDescriptor<Class>>) method .invoke(null, MySuperInterface.class); - Assert.assertEquals(2, propertyDescriptors.size()); - Assert.assertTrue(propertyDescriptors.containsKey("super1")); - Assert.assertTrue(propertyDescriptors.containsKey("override")); + assertEquals(2, propertyDescriptors.size()); + assertTrue(propertyDescriptors.containsKey("super1")); + assertTrue(propertyDescriptors.containsKey("override")); MethodProperty<?> property = (MethodProperty<?>) propertyDescriptors .get("override").createProperty(getClass()); - Assert.assertTrue(property.isReadOnly()); + assertTrue(property.isReadOnly()); } @Test @@ -228,15 +231,15 @@ public class BeanItemTest { LinkedHashMap<String, VaadinPropertyDescriptor<Class>> propertyDescriptors = (LinkedHashMap<String, VaadinPropertyDescriptor<Class>>) method .invoke(null, MySubInterface.class); - Assert.assertEquals(4, propertyDescriptors.size()); - Assert.assertTrue(propertyDescriptors.containsKey("sub")); - Assert.assertTrue(propertyDescriptors.containsKey("super1")); - Assert.assertTrue(propertyDescriptors.containsKey("super2")); - Assert.assertTrue(propertyDescriptors.containsKey("override")); + assertEquals(4, propertyDescriptors.size()); + assertTrue(propertyDescriptors.containsKey("sub")); + assertTrue(propertyDescriptors.containsKey("super1")); + assertTrue(propertyDescriptors.containsKey("super2")); + assertTrue(propertyDescriptors.containsKey("override")); MethodProperty<?> property = (MethodProperty<?>) propertyDescriptors .get("override").createProperty(getClass()); - Assert.assertFalse(property.isReadOnly()); + assertFalse(property.isReadOnly()); } @Test @@ -251,11 +254,11 @@ public class BeanItemTest { ids); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals("name", it.next()); - Assert.assertEquals("superPublic", it.next()); - Assert.assertEquals("name2", it.next()); - Assert.assertEquals("noField", it.next()); - Assert.assertFalse(it.hasNext()); + assertEquals("name", it.next()); + assertEquals("superPublic", it.next()); + assertEquals("name2", it.next()); + assertEquals("noField", it.next()); + assertFalse(it.hasNext()); } @Test @@ -264,11 +267,11 @@ public class BeanItemTest { new String[] { "name", "superPublic", "name2", "noField" }); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals("name", it.next()); - Assert.assertEquals("superPublic", it.next()); - Assert.assertEquals("name2", it.next()); - Assert.assertEquals("noField", it.next()); - Assert.assertFalse(it.hasNext()); + assertEquals("name", it.next()); + assertEquals("superPublic", it.next()); + assertEquals("name2", it.next()); + assertEquals("noField", it.next()); + assertFalse(it.hasNext()); } @Test @@ -282,8 +285,8 @@ public class BeanItemTest { ids); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals("name", it.next()); - Assert.assertFalse(it.hasNext()); + assertEquals("name", it.next()); + assertFalse(it.hasNext()); } @Test @@ -291,11 +294,11 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); + assertEquals(6, itemPropertyIds.size()); item.removeItemProperty("name2"); - Assert.assertEquals(5, itemPropertyIds.size()); - Assert.assertFalse(itemPropertyIds.contains("name2")); + assertEquals(5, itemPropertyIds.size()); + assertFalse(itemPropertyIds.contains("name2")); } @Test @@ -303,33 +306,32 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); Collection<?> itemPropertyIds = item.getItemPropertyIds(); - Assert.assertEquals(6, itemPropertyIds.size()); + assertEquals(6, itemPropertyIds.size()); item.removeItemProperty("superPrivate"); - Assert.assertEquals(5, itemPropertyIds.size()); - Assert.assertFalse(itemPropertyIds.contains("superPrivate")); + assertEquals(5, itemPropertyIds.size()); + assertFalse(itemPropertyIds.contains("superPrivate")); } @Test public void testPropertyTypes() { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); - Assert.assertTrue(Integer.class + assertTrue(Integer.class .equals(item.getItemProperty("superPrivate").getType())); - Assert.assertTrue(Double.class + assertTrue(Double.class .equals(item.getItemProperty("superProtected").getType())); - Assert.assertTrue(Boolean.class + assertTrue(Boolean.class .equals(item.getItemProperty("superPublic").getType())); - Assert.assertTrue( - String.class.equals(item.getItemProperty("name").getType())); + assertTrue(String.class.equals(item.getItemProperty("name").getType())); } @Test public void testPropertyReadOnly() { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); - Assert.assertFalse(item.getItemProperty("name").isReadOnly()); - Assert.assertTrue(item.getItemProperty("name2").isReadOnly()); + assertFalse(item.getItemProperty("name").isReadOnly()); + assertTrue(item.getItemProperty("name2").isReadOnly()); } @Test @@ -348,8 +350,8 @@ public class BeanItemTest { BeanItem<MyClass> item = constructor.newInstance(instance, propertyDescriptors); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals("bean1", item.getItemProperty("myname").getValue()); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals("bean1", item.getItemProperty("myname").getValue()); } @Test @@ -361,15 +363,15 @@ public class BeanItemTest { BeanItem<MyClass> item = new BeanItem<MyClass>(new MyClass("bean1")); - Assert.assertEquals(6, item.getItemPropertyIds().size()); - Assert.assertEquals(null, item.getItemProperty("myname")); + assertEquals(6, item.getItemPropertyIds().size()); + assertEquals(null, item.getItemProperty("myname")); item.addItemProperty("myname", pd.createProperty(item.getBean())); - Assert.assertEquals(7, item.getItemPropertyIds().size()); - Assert.assertEquals("bean1", item.getItemProperty("myname").getValue()); + assertEquals(7, item.getItemPropertyIds().size()); + assertEquals("bean1", item.getItemProperty("myname").getValue()); item.removeItemProperty("myname"); - Assert.assertEquals(6, item.getItemPropertyIds().size()); - Assert.assertEquals(null, item.getItemProperty("myname")); + assertEquals(6, item.getItemPropertyIds().size()); + assertEquals(null, item.getItemProperty("myname")); } @Test @@ -377,11 +379,10 @@ public class BeanItemTest { BeanItem<SubClass> item = new BeanItem<SubClass>(new SubClass()); Property<?> property = item.getItemProperty("property"); - Assert.assertEquals("Unexpected class for property type", String.class, + assertEquals("Unexpected class for property type", String.class, property.getType()); - Assert.assertEquals("Unexpected property value", "", - property.getValue()); + assertEquals("Unexpected property value", "", property.getValue()); // Should not be exception property.setValue(null); @@ -392,7 +393,7 @@ public class BeanItemTest { BeanItem<MyClass> beanItem = new BeanItem<BeanItemTest.MyClass>( new MyClass("Foo")); beanItem.setBean(new MyClass("Bar")); - Assert.assertEquals("Bar", beanItem.getItemProperty("name").getValue()); + assertEquals("Bar", beanItem.getItemProperty("name").getValue()); } @Test @@ -400,7 +401,7 @@ public class BeanItemTest { BeanItem<MyClass> beanItem = new BeanItem<BeanItemTest.MyClass>( new MyClass("Foo")); beanItem.setBean(new MyClass("Bar")); - Assert.assertEquals("Bar", beanItem.getItemProperty("name").getValue()); + assertEquals("Bar", beanItem.getItemProperty("name").getValue()); } @Test(expected = IllegalArgumentException.class) diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java index c421750f87..f6444ce459 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/FileSystemContainerTest.java @@ -1,8 +1,9 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertTrue; + import java.io.File; -import org.junit.Assert; import org.junit.Test; public class FileSystemContainerTest { @@ -11,6 +12,6 @@ public class FileSystemContainerTest { public void nonExistingDirectory() { FilesystemContainer fsc = new FilesystemContainer( new File("/non/existing")); - Assert.assertTrue(fsc.getItemIds().isEmpty()); + assertTrue(fsc.getItemIds().isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java index fb7cb06727..dfa537a98a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/GeneratedPropertyContainerBasicTest.java @@ -532,7 +532,7 @@ public class GeneratedPropertyContainerBasicTest public void testGetItemIdsRangeIndexOutOfBoundsDueToSizeChange() { GeneratedPropertyContainer ic = createContainer(); ic.addItem(new Object()); - Assert.assertEquals( + assertEquals( "Container returned too many items when the range was >> container size", 1, ic.getItemIds(0, 10).size()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java index 712a9b7047..79adeb8218 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/IndexedContainerTest.java @@ -485,7 +485,7 @@ public class IndexedContainerTest extends AbstractInMemoryContainerTestBase { public void testGetItemIdsRangeIndexOutOfBoundsDueToSizeChange() { IndexedContainer ic = new IndexedContainer(); ic.addItem(new Object()); - Assert.assertEquals( + assertEquals( "Container returned too many items when the range was >> container size", 1, ic.getItemIds(0, 10).size()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java index 64a7c19b8f..d208dffa95 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyMemoryConsumptionTest.java @@ -15,6 +15,9 @@ */ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -23,7 +26,6 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Field; -import org.junit.Assert; import org.junit.Test; /** @@ -52,12 +54,12 @@ public class MethodPropertyMemoryConsumptionTest { .getDeclaredField("setArgs"); setArgsField.setAccessible(true); - Assert.assertSame( + assertSame( "setArguments method sets non-default instance" + " of empty Object array for getArgs", getArgsField.get(property), getArgs); - Assert.assertSame( + assertSame( "setArguments method sets non-default instance" + " of empty Object array for setArgs", setArgsField.get(property), setArgs); @@ -75,11 +77,11 @@ public class MethodPropertyMemoryConsumptionTest { TestBean otherBean = new TestBean(); TestMethodProperty<String> otherProperty = new TestMethodProperty<String>( otherBean, "name"); - Assert.assertSame( + assertSame( "setArguments method uses different instance" + " of empty Object array for getArgs", getArgs, otherProperty.getGetArgs()); - Assert.assertSame( + assertSame( "setArguments method uses different instance" + " of empty Object array for setArgs", setArgs, otherProperty.getSetArgs()); @@ -101,9 +103,9 @@ public class MethodPropertyMemoryConsumptionTest { Object red = inputStream.readObject(); TestMethodProperty<?> deserialized = (TestMethodProperty<?>) red; - Assert.assertNotNull("Deseriliation doesn't call setArguments method", + assertNotNull("Deseriliation doesn't call setArguments method", deserialized.getGetArgs()); - Assert.assertNotNull("Deseriliation doesn't call setArguments method", + assertNotNull("Deseriliation doesn't call setArguments method", deserialized.getSetArgs()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java index 61c66b9167..5ef3d03a2e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/MethodPropertyTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.data.util; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -34,7 +35,7 @@ public class MethodPropertyTest { public void getValue() { MethodProperty<String> mp = new MethodProperty<String>(testObject, "street"); - Assert.assertEquals("some street", mp.getValue()); + assertEquals("some street", mp.getValue()); } @Test @@ -42,7 +43,7 @@ public class MethodPropertyTest { MethodProperty<String> mp = new MethodProperty<String>(testObject, "street"); testObject.setStreet("Foo street"); - Assert.assertEquals("Foo street", mp.getValue()); + assertEquals("Foo street", mp.getValue()); } @Test @@ -50,7 +51,7 @@ public class MethodPropertyTest { MethodProperty<String> mp = new MethodProperty<String>(testObject, "street"); mp.setValue("Foo street"); - Assert.assertEquals("Foo street", testObject.getStreet()); + assertEquals("Foo street", testObject.getStreet()); } @Test @@ -59,8 +60,8 @@ public class MethodPropertyTest { "street"); Address newStreet = new Address("new street", 999); mp.setInstance(newStreet); - Assert.assertEquals("new street", mp.getValue()); - Assert.assertEquals("some street", testObject.getStreet()); + assertEquals("new street", mp.getValue()); + assertEquals("some street", testObject.getStreet()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java index 9a47e395e2..96065ae199 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/NestedMethodPropertyTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; @@ -10,7 +13,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -140,8 +142,8 @@ public class NestedMethodPropertyTest { NestedMethodProperty<String> nameProperty = new NestedMethodProperty<String>( vaadin, "name"); - Assert.assertEquals(String.class, nameProperty.getType()); - Assert.assertEquals("Vaadin", nameProperty.getValue()); + assertEquals(String.class, nameProperty.getType()); + assertEquals("Vaadin", nameProperty.getValue()); } @Test @@ -149,8 +151,8 @@ public class NestedMethodPropertyTest { NestedMethodProperty<Person> managerProperty = new NestedMethodProperty<Person>( vaadin, "manager"); - Assert.assertEquals(Person.class, managerProperty.getType()); - Assert.assertEquals(joonas, managerProperty.getValue()); + assertEquals(Person.class, managerProperty.getType()); + assertEquals(joonas, managerProperty.getValue()); } @Test @@ -168,26 +170,25 @@ public class NestedMethodPropertyTest { NestedMethodProperty<Boolean> booleanProperty = new NestedMethodProperty<Boolean>( vaadin, "manager.address.boolean"); - Assert.assertEquals(String.class, managerNameProperty.getType()); - Assert.assertEquals("Joonas", managerNameProperty.getValue()); + assertEquals(String.class, managerNameProperty.getType()); + assertEquals("Joonas", managerNameProperty.getValue()); - Assert.assertEquals(Address.class, addressProperty.getType()); - Assert.assertEquals(oldMill, addressProperty.getValue()); + assertEquals(Address.class, addressProperty.getType()); + assertEquals(oldMill, addressProperty.getValue()); - Assert.assertEquals(String.class, streetProperty.getType()); - Assert.assertEquals("Ruukinkatu 2-4", streetProperty.getValue()); + assertEquals(String.class, streetProperty.getType()); + assertEquals("Ruukinkatu 2-4", streetProperty.getValue()); - Assert.assertEquals(Integer.class, - postalCodePrimitiveProperty.getType()); - Assert.assertEquals(Integer.valueOf(20540), + assertEquals(Integer.class, postalCodePrimitiveProperty.getType()); + assertEquals(Integer.valueOf(20540), postalCodePrimitiveProperty.getValue()); - Assert.assertEquals(Integer.class, postalCodeObjectProperty.getType()); - Assert.assertEquals(Integer.valueOf(20540), + assertEquals(Integer.class, postalCodeObjectProperty.getType()); + assertEquals(Integer.valueOf(20540), postalCodeObjectProperty.getValue()); - Assert.assertEquals(Boolean.class, booleanProperty.getType()); - Assert.assertEquals(Boolean.TRUE, booleanProperty.getValue()); + assertEquals(Boolean.class, booleanProperty.getType()); + assertEquals(Boolean.TRUE, booleanProperty.getValue()); } @Test @@ -274,8 +275,8 @@ public class NestedMethodPropertyTest { assertNull(streetProperty.getValue()); vaadin.setManager(joonas); - Assert.assertEquals("Joonas", managerNameProperty.getValue()); - Assert.assertNull(streetProperty.getValue()); + assertEquals("Joonas", managerNameProperty.getValue()); + assertNull(streetProperty.getValue()); } @@ -293,20 +294,20 @@ public class NestedMethodPropertyTest { vaadin, "manager.address.postalCodeObject"); managerNameProperty.setValue("Joonas L"); - Assert.assertEquals("Joonas L", joonas.getName()); + assertEquals("Joonas L", joonas.getName()); streetProperty.setValue("Ruukinkatu"); - Assert.assertEquals("Ruukinkatu", oldMill.getStreet()); + assertEquals("Ruukinkatu", oldMill.getStreet()); postalCodePrimitiveProperty.setValue(0); postalCodeObjectProperty.setValue(1); - Assert.assertEquals(0, oldMill.getPostalCodePrimitive()); - Assert.assertEquals(Integer.valueOf(1), oldMill.getPostalCodeObject()); + assertEquals(0, oldMill.getPostalCodePrimitive()); + assertEquals(Integer.valueOf(1), oldMill.getPostalCodeObject()); postalCodeObjectProperty.setValue(null); - Assert.assertNull(oldMill.getPostalCodeObject()); + assertNull(oldMill.getPostalCodeObject()); Address address2 = new Address("Other street", 12345); addressProperty.setValue(address2); - Assert.assertEquals("Other street", streetProperty.getValue()); + assertEquals("Other street", streetProperty.getValue()); } @Test @@ -319,7 +320,7 @@ public class NestedMethodPropertyTest { NestedMethodProperty<String> property2 = (NestedMethodProperty<String>) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); - Assert.assertEquals("Ruukinkatu 2-4", property2.getValue()); + assertEquals("Ruukinkatu 2-4", property2.getValue()); } @Test @@ -334,7 +335,7 @@ public class NestedMethodPropertyTest { NestedMethodProperty<String> property2 = (NestedMethodProperty<String>) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); - Assert.assertNull(property2.getValue()); + assertNull(property2.getValue()); } @Test @@ -344,8 +345,8 @@ public class NestedMethodPropertyTest { NestedMethodProperty<Boolean> booleanProperty = new NestedMethodProperty<Boolean>( vaadin, "manager.address.boolean"); - Assert.assertFalse(streetProperty.isReadOnly()); - Assert.assertTrue(booleanProperty.isReadOnly()); + assertFalse(streetProperty.isReadOnly()); + assertTrue(booleanProperty.isReadOnly()); } @Test @@ -358,9 +359,9 @@ public class NestedMethodPropertyTest { Team someteam = new Team("The team", someone); streetProperty.setInstance(someteam); - Assert.assertEquals("The street", streetProperty.getValue()); - Assert.assertEquals("Ruukinkatu 2-4", vaadin.getManager().getAddress() - .getStreet()); + assertEquals("The street", streetProperty.getValue()); + assertEquals("Ruukinkatu 2-4", + vaadin.getManager().getAddress().getStreet()); } @Test(expected = IllegalArgumentException.class) diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java index 3e2cb5cc91..4484a2a584 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/ObjectPropertyTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.data.util; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class ObjectPropertyTest { @@ -35,68 +36,68 @@ public class ObjectPropertyTest { public void testSimple() { ObjectProperty<TestSuperClass> prop1 = new ObjectProperty<TestSuperClass>( super1, TestSuperClass.class); - Assert.assertEquals("super1", prop1.getValue().getName()); + assertEquals("super1", prop1.getValue().getName()); prop1 = new ObjectProperty<TestSuperClass>(super1); - Assert.assertEquals("super1", prop1.getValue().getName()); + assertEquals("super1", prop1.getValue().getName()); ObjectProperty<TestSubClass> prop2 = new ObjectProperty<TestSubClass>( sub1, TestSubClass.class); - Assert.assertEquals("Subclass: sub1", prop2.getValue().getName()); + assertEquals("Subclass: sub1", prop2.getValue().getName()); prop2 = new ObjectProperty<TestSubClass>(sub1); - Assert.assertEquals("Subclass: sub1", prop2.getValue().getName()); + assertEquals("Subclass: sub1", prop2.getValue().getName()); } @Test public void testSetValueObjectSuper() { ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>( super1, TestSuperClass.class); - Assert.assertEquals("super1", prop.getValue().getName()); + assertEquals("super1", prop.getValue().getName()); prop.setValue(new TestSuperClass("super2")); - Assert.assertEquals("super1", super1.getName()); - Assert.assertEquals("super2", prop.getValue().getName()); + assertEquals("super1", super1.getName()); + assertEquals("super2", prop.getValue().getName()); } @Test public void testSetValueObjectSub() { ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>( sub1, TestSubClass.class); - Assert.assertEquals("Subclass: sub1", prop.getValue().getName()); + assertEquals("Subclass: sub1", prop.getValue().getName()); prop.setValue(new TestSubClass("sub2")); - Assert.assertEquals("Subclass: sub1", sub1.getName()); - Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); + assertEquals("Subclass: sub1", sub1.getName()); + assertEquals("Subclass: sub2", prop.getValue().getName()); } @Test public void testSetValueStringSuper() { ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>( super1, TestSuperClass.class); - Assert.assertEquals("super1", prop.getValue().getName()); + assertEquals("super1", prop.getValue().getName()); prop.setValue(new TestSuperClass("super2")); - Assert.assertEquals("super1", super1.getName()); - Assert.assertEquals("super2", prop.getValue().getName()); + assertEquals("super1", super1.getName()); + assertEquals("super2", prop.getValue().getName()); } @Test public void testSetValueStringSub() { ObjectProperty<TestSubClass> prop = new ObjectProperty<TestSubClass>( sub1, TestSubClass.class); - Assert.assertEquals("Subclass: sub1", prop.getValue().getName()); + assertEquals("Subclass: sub1", prop.getValue().getName()); prop.setValue(new TestSubClass("sub2")); - Assert.assertEquals("Subclass: sub1", sub1.getName()); - Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); + assertEquals("Subclass: sub1", sub1.getName()); + assertEquals("Subclass: sub2", prop.getValue().getName()); } @Test public void testMixedGenerics() { ObjectProperty<TestSuperClass> prop = new ObjectProperty<TestSuperClass>( sub1); - Assert.assertEquals("Subclass: sub1", prop.getValue().getName()); - Assert.assertEquals(prop.getType(), TestSubClass.class); + assertEquals("Subclass: sub1", prop.getValue().getName()); + assertEquals(prop.getType(), TestSubClass.class); // create correct subclass based on the runtime type of the instance // given to ObjectProperty constructor, which is a subclass of the type // parameter prop.setValue(new TestSubClass("sub2")); - Assert.assertEquals("Subclass: sub2", prop.getValue().getName()); + assertEquals("Subclass: sub2", prop.getValue().getName()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java index 78ff4e9b9f..6491b9cc99 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java @@ -1,5 +1,7 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -7,7 +9,6 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; -import org.junit.Assert; import org.junit.Test; public class PerformanceTestIndexedContainerTest { @@ -109,8 +110,8 @@ public class PerformanceTestIndexedContainerTest { long median = median(times); System.out.println( methodName + " timings (ms) for " + items + " items: " + times); - Assert.assertTrue(methodName + " too slow, median time " + median - + "ms for " + items + " items", median <= threshold); + assertTrue(methodName + " too slow, median time " + median + "ms for " + + items + " items", median <= threshold); } private Long median(Collection<Long> times) { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java index 1dd603c328..19147fdef4 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertyDescriptorTest.java @@ -1,5 +1,8 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.ByteArrayInputStream; @@ -7,7 +10,6 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property; @@ -38,7 +40,7 @@ public class PropertyDescriptorTest { Property<?> property = descriptor2 .createProperty(new Person("John", null)); - Assert.assertEquals("John", property.getValue()); + assertEquals("John", property.getValue()); } @Test @@ -54,7 +56,7 @@ public class PropertyDescriptorTest { new ByteArrayInputStream(baos.toByteArray())).readObject(); Property<?> property = pd2.createProperty(new Person("John", null)); - Assert.assertEquals("John", property.getValue()); + assertEquals("John", property.getValue()); } @Test @@ -69,7 +71,7 @@ public class PropertyDescriptorTest { new ByteArrayInputStream(baos.toByteArray())).readObject(); Property<?> property = pd2.createProperty(new Person("John", null)); - Assert.assertNull(property.getValue()); + assertNull(property.getValue()); } @Test @@ -79,6 +81,6 @@ public class PropertyDescriptorTest { "age", int.class, Person.class.getMethod("getAge"), Person.class.getMethod("setAge", int.class)); - Assert.assertEquals(Integer.class, pd.getPropertyType()); + assertEquals(Integer.class, pd.getPropertyType()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java index 0516c8ae9f..8f9adb3e0d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PropertySetItemTest.java @@ -1,10 +1,15 @@ package com.vaadin.v7.data.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,20 +62,20 @@ public class PropertySetItemTest { @Test public void testEmptyItem() { PropertysetItem item = createPropertySetItem(); - Assert.assertNotNull(item.getItemPropertyIds()); - Assert.assertEquals(0, item.getItemPropertyIds().size()); + assertNotNull(item.getItemPropertyIds()); + assertEquals(0, item.getItemPropertyIds().size()); } @Test public void testGetProperty() { PropertysetItem item = createPropertySetItem(); - Assert.assertNull(item.getItemProperty(ID1)); + assertNull(item.getItemProperty(ID1)); item.addItemProperty(ID1, prop1); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); - Assert.assertNull(item.getItemProperty(ID2)); + assertEquals(prop1, item.getItemProperty(ID1)); + assertNull(item.getItemProperty(ID2)); } @Test @@ -78,10 +83,10 @@ public class PropertySetItemTest { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); - Assert.assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(1, item.getItemPropertyIds().size()); Object firstValue = item.getItemPropertyIds().iterator().next(); - Assert.assertEquals(ID1, firstValue); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(ID1, firstValue); + assertEquals(prop1, item.getItemProperty(ID1)); } @Test @@ -89,16 +94,16 @@ public class PropertySetItemTest { PropertysetItem item = createPropertySetItem(); item.addItemProperty(ID1, prop1); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); item.addItemProperty(ID2, prop2); - Assert.assertEquals(2, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); - Assert.assertEquals(prop2, item.getItemProperty(ID2)); + assertEquals(2, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(prop2, item.getItemProperty(ID2)); item.addItemProperty(ID3, prop3); - Assert.assertEquals(3, item.getItemPropertyIds().size()); + assertEquals(3, item.getItemPropertyIds().size()); } @Test @@ -109,32 +114,32 @@ public class PropertySetItemTest { item.addItemProperty(ID3, prop3); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals(ID1, it.next()); - Assert.assertEquals(ID2, it.next()); - Assert.assertEquals(ID3, it.next()); + assertEquals(ID1, it.next()); + assertEquals(ID2, it.next()); + assertEquals(ID3, it.next()); } @Test public void testAddPropertyTwice() { PropertysetItem item = createPropertySetItem(); - Assert.assertTrue(item.addItemProperty(ID1, prop1)); - Assert.assertFalse(item.addItemProperty(ID1, prop1)); + assertTrue(item.addItemProperty(ID1, prop1)); + assertFalse(item.addItemProperty(ID1, prop1)); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); } @Test public void testCannotChangeProperty() { PropertysetItem item = createPropertySetItem(); - Assert.assertTrue(item.addItemProperty(ID1, prop1)); + assertTrue(item.addItemProperty(ID1, prop1)); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(prop1, item.getItemProperty(ID1)); - Assert.assertFalse(item.addItemProperty(ID1, prop2)); + assertFalse(item.addItemProperty(ID1, prop2)); - Assert.assertEquals(1, item.getItemPropertyIds().size()); - Assert.assertEquals(prop1, item.getItemProperty(ID1)); + assertEquals(1, item.getItemPropertyIds().size()); + assertEquals(prop1, item.getItemProperty(ID1)); } @Test @@ -143,8 +148,8 @@ public class PropertySetItemTest { item.addItemProperty(ID1, prop1); item.removeItemProperty(ID1); - Assert.assertEquals(0, item.getItemPropertyIds().size()); - Assert.assertNull(item.getItemProperty(ID1)); + assertEquals(0, item.getItemPropertyIds().size()); + assertNull(item.getItemProperty(ID1)); } @Test @@ -157,8 +162,8 @@ public class PropertySetItemTest { item.removeItemProperty(ID2); Iterator<?> it = item.getItemPropertyIds().iterator(); - Assert.assertEquals(ID1, it.next()); - Assert.assertEquals(ID3, it.next()); + assertEquals(ID1, it.next()); + assertEquals(ID3, it.next()); } @Test @@ -232,7 +237,7 @@ public class PropertySetItemTest { public void testItemEqualsNull() { PropertysetItem item = createPropertySetItem(); - Assert.assertFalse(item.equals(null)); + assertFalse(item.equals(null)); } @Test @@ -240,7 +245,7 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertTrue(item1.equals(item2)); + assertTrue(item1.equals(item2)); } @Test @@ -255,21 +260,21 @@ public class PropertySetItemTest { PropertysetItem item5 = createPropertySetItem(); item5.addItemProperty(ID2, prop2); - Assert.assertFalse(item1.equals(item2)); - Assert.assertFalse(item1.equals(item3)); - Assert.assertFalse(item1.equals(item4)); - Assert.assertFalse(item1.equals(item5)); + assertFalse(item1.equals(item2)); + assertFalse(item1.equals(item3)); + assertFalse(item1.equals(item4)); + assertFalse(item1.equals(item5)); - Assert.assertTrue(item2.equals(item3)); - Assert.assertFalse(item2.equals(item4)); - Assert.assertFalse(item2.equals(item5)); + assertTrue(item2.equals(item3)); + assertFalse(item2.equals(item4)); + assertFalse(item2.equals(item5)); - Assert.assertFalse(item3.equals(item4)); - Assert.assertFalse(item3.equals(item5)); + assertFalse(item3.equals(item4)); + assertFalse(item3.equals(item5)); - Assert.assertFalse(item4.equals(item5)); + assertFalse(item4.equals(item5)); - Assert.assertFalse(item2.equals(item1)); + assertFalse(item2.equals(item1)); } @Test @@ -285,9 +290,9 @@ public class PropertySetItemTest { item3.addItemProperty(ID1, prop1); item3.addItemProperty(ID2, prop2); - Assert.assertFalse(item1.equals(item2)); + assertFalse(item1.equals(item2)); - Assert.assertTrue(item2.equals(item3)); + assertTrue(item2.equals(item3)); } @Test @@ -300,7 +305,7 @@ public class PropertySetItemTest { item2.addItemProperty(ID2, prop2); item2.addItemProperty(ID1, prop1); - Assert.assertFalse(item1.equals(item2)); + assertFalse(item1.equals(item2)); } @Test @@ -310,13 +315,13 @@ public class PropertySetItemTest { item1.addListener(propertySetListenerMock); - Assert.assertFalse(item1.equals(item2)); - Assert.assertFalse(item2.equals(item1)); + assertFalse(item1.equals(item2)); + assertFalse(item2.equals(item1)); item2.addListener(propertySetListenerMock); - Assert.assertTrue(item1.equals(item2)); - Assert.assertTrue(item2.equals(item1)); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); } @Test @@ -329,13 +334,13 @@ public class PropertySetItemTest { item2.addListener(propertySetListenerMock); - Assert.assertFalse(item1.equals(item2)); - Assert.assertFalse(item2.equals(item1)); + assertFalse(item1.equals(item2)); + assertFalse(item2.equals(item1)); item2.addListener(propertySetListenerMock2); - Assert.assertTrue(item1.equals(item2)); - Assert.assertTrue(item2.equals(item1)); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); } @Test @@ -346,8 +351,8 @@ public class PropertySetItemTest { item1.addListener(propertySetListenerMock); item1.removeListener(propertySetListenerMock); - Assert.assertTrue(item1.equals(item2)); - Assert.assertTrue(item2.equals(item1)); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); } @Test @@ -355,7 +360,7 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -363,7 +368,7 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); item1.addItemProperty(ID1, prop1); item1.addItemProperty(ID2, prop2); @@ -372,7 +377,7 @@ public class PropertySetItemTest { item2.addItemProperty(ID1, prop1); item2.addItemProperty(ID2, prop2); // but here hashCodes must be equal - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -380,14 +385,14 @@ public class PropertySetItemTest { PropertysetItem item1 = createPropertySetItem(); PropertysetItem item2 = createPropertySetItem(); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); item1.addListener(propertySetListenerMock); // hashCodes can be equal even if items are different item2.addListener(propertySetListenerMock); // but here hashCodes must be equal - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -398,7 +403,7 @@ public class PropertySetItemTest { item1.addItemProperty(ID1, prop1); item1.removeItemProperty(ID1); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -409,7 +414,7 @@ public class PropertySetItemTest { item1.addListener(propertySetListenerMock); item1.removeListener(propertySetListenerMock); - Assert.assertEquals(item1.hashCode(), item2.hashCode()); + assertEquals(item1.hashCode(), item2.hashCode()); } @Test @@ -417,15 +422,15 @@ public class PropertySetItemTest { // toString() behavior is specified in the class javadoc PropertysetItem item = createPropertySetItem(); - Assert.assertEquals("", item.toString()); + assertEquals("", item.toString()); item.addItemProperty(ID1, prop1); - Assert.assertEquals(String.valueOf(prop1.getValue()), item.toString()); + assertEquals(String.valueOf(prop1.getValue()), item.toString()); item.addItemProperty(ID2, prop2); - Assert.assertEquals(String.valueOf(prop1.getValue()) + " " + assertEquals(String.valueOf(prop1.getValue()) + " " + String.valueOf(prop2.getValue()), item.toString()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java index 7120a429fc..432b264e84 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AbstractFilterTestBase.java @@ -6,10 +6,7 @@ import com.vaadin.v7.data.Property; import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.data.util.PropertysetItem; -import junit.framework.TestCase; - -public abstract class AbstractFilterTestBase<FILTERTYPE extends Filter> - extends TestCase { +public abstract class AbstractFilterTestBase<FILTERTYPE extends Filter> { protected static final String PROPERTY1 = "property1"; protected static final String PROPERTY2 = "property2"; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java index 827da03790..ecdbcfaa40 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/AndOrFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -17,15 +20,15 @@ public class AndOrFilterTest public void testNoFilterAnd() { Filter filter = new And(); - Assert.assertTrue(filter.passesFilter(null, item1)); + assertTrue(filter.passesFilter(null, item1)); } @Test public void testSingleFilterAnd() { Filter filter = new And(new SameItemFilter(item1)); - Assert.assertTrue(filter.passesFilter(null, item1)); - Assert.assertFalse(filter.passesFilter(null, item2)); + assertTrue(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item2)); } @Test @@ -35,11 +38,11 @@ public class AndOrFilterTest Filter filter2 = new And(new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertFalse(filter2.passesFilter(null, item1)); - Assert.assertFalse(filter2.passesFilter(null, item2)); + assertFalse(filter2.passesFilter(null, item1)); + assertFalse(filter2.passesFilter(null, item2)); } @Test @@ -49,26 +52,26 @@ public class AndOrFilterTest Filter filter2 = new And(new SameItemFilter(item1), new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertFalse(filter2.passesFilter(null, item1)); - Assert.assertFalse(filter2.passesFilter(null, item2)); + assertFalse(filter2.passesFilter(null, item1)); + assertFalse(filter2.passesFilter(null, item2)); } @Test public void testNoFilterOr() { Filter filter = new Or(); - Assert.assertFalse(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item1)); } @Test public void testSingleFilterOr() { Filter filter = new Or(new SameItemFilter(item1)); - Assert.assertTrue(filter.passesFilter(null, item1)); - Assert.assertFalse(filter.passesFilter(null, item2)); + assertTrue(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item2)); } @Test @@ -78,11 +81,11 @@ public class AndOrFilterTest Filter filter2 = new Or(new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertTrue(filter2.passesFilter(null, item1)); - Assert.assertTrue(filter2.passesFilter(null, item2)); + assertTrue(filter2.passesFilter(null, item1)); + assertTrue(filter2.passesFilter(null, item2)); } @Test @@ -92,11 +95,11 @@ public class AndOrFilterTest Filter filter2 = new Or(new SameItemFilter(item1), new SameItemFilter(item1), new SameItemFilter(item2)); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); - Assert.assertTrue(filter2.passesFilter(null, item1)); - Assert.assertTrue(filter2.passesFilter(null, item2)); + assertTrue(filter2.passesFilter(null, item1)); + assertTrue(filter2.passesFilter(null, item2)); } @Test @@ -115,28 +118,28 @@ public class AndOrFilterTest Filter other0 = new Or(); Filter other1 = new Or(new SameItemFilter(item1)); - Assert.assertEquals(filter0, filter0); - Assert.assertEquals(filter0, filter0b); - Assert.assertFalse(filter0.equals(filter1a)); - Assert.assertFalse(filter0.equals(other0)); - Assert.assertFalse(filter0.equals(other1)); + assertEquals(filter0, filter0); + assertEquals(filter0, filter0b); + assertFalse(filter0.equals(filter1a)); + assertFalse(filter0.equals(other0)); + assertFalse(filter0.equals(other1)); - Assert.assertFalse(filter1a.equals(filter1b)); - Assert.assertFalse(filter1a.equals(other1)); + assertFalse(filter1a.equals(filter1b)); + assertFalse(filter1a.equals(other1)); - Assert.assertFalse(filter1a.equals(filter2a)); - Assert.assertFalse(filter2a.equals(filter1a)); + assertFalse(filter1a.equals(filter2a)); + assertFalse(filter2a.equals(filter1a)); - Assert.assertFalse(filter2a.equals(filter2b)); - Assert.assertEquals(filter2b, filter2b2); + assertFalse(filter2a.equals(filter2b)); + assertEquals(filter2b, filter2b2); // hashCode() - Assert.assertEquals(filter0.hashCode(), filter0.hashCode()); - Assert.assertEquals(filter0.hashCode(), filter0b.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a2.hashCode()); - Assert.assertEquals(filter2a.hashCode(), filter2a.hashCode()); - Assert.assertEquals(filter2b.hashCode(), filter2b2.hashCode()); + assertEquals(filter0.hashCode(), filter0.hashCode()); + assertEquals(filter0.hashCode(), filter0b.hashCode()); + assertEquals(filter1a.hashCode(), filter1a.hashCode()); + assertEquals(filter1a.hashCode(), filter1a2.hashCode()); + assertEquals(filter2a.hashCode(), filter2a.hashCode()); + assertEquals(filter2b.hashCode(), filter2b2.hashCode()); } @Test @@ -155,28 +158,28 @@ public class AndOrFilterTest Filter other0 = new And(); Filter other1 = new And(new SameItemFilter(item1)); - Assert.assertEquals(filter0, filter0); - Assert.assertEquals(filter0, filter0b); - Assert.assertFalse(filter0.equals(filter1a)); - Assert.assertFalse(filter0.equals(other0)); - Assert.assertFalse(filter0.equals(other1)); + assertEquals(filter0, filter0); + assertEquals(filter0, filter0b); + assertFalse(filter0.equals(filter1a)); + assertFalse(filter0.equals(other0)); + assertFalse(filter0.equals(other1)); - Assert.assertFalse(filter1a.equals(filter1b)); - Assert.assertFalse(filter1a.equals(other1)); + assertFalse(filter1a.equals(filter1b)); + assertFalse(filter1a.equals(other1)); - Assert.assertFalse(filter1a.equals(filter2a)); - Assert.assertFalse(filter2a.equals(filter1a)); + assertFalse(filter1a.equals(filter2a)); + assertFalse(filter2a.equals(filter1a)); - Assert.assertFalse(filter2a.equals(filter2b)); - Assert.assertEquals(filter2b, filter2b2); + assertFalse(filter2a.equals(filter2b)); + assertEquals(filter2b, filter2b2); // hashCode() - Assert.assertEquals(filter0.hashCode(), filter0.hashCode()); - Assert.assertEquals(filter0.hashCode(), filter0b.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a.hashCode()); - Assert.assertEquals(filter1a.hashCode(), filter1a2.hashCode()); - Assert.assertEquals(filter2a.hashCode(), filter2a.hashCode()); - Assert.assertEquals(filter2b.hashCode(), filter2b2.hashCode()); + assertEquals(filter0.hashCode(), filter0.hashCode()); + assertEquals(filter0.hashCode(), filter0b.hashCode()); + assertEquals(filter1a.hashCode(), filter1a.hashCode()); + assertEquals(filter1a.hashCode(), filter1a2.hashCode()); + assertEquals(filter2a.hashCode(), filter2a.hashCode()); + assertEquals(filter2b.hashCode(), filter2b2.hashCode()); } @Test @@ -192,23 +195,23 @@ public class AndOrFilterTest new SameItemFilter(item1, "b"), new SameItemFilter(item1, "c")); // empty And does not filter out anything - Assert.assertFalse(filter0.appliesToProperty("a")); - Assert.assertFalse(filter0.appliesToProperty("d")); - - Assert.assertTrue(filter1a.appliesToProperty("a")); - Assert.assertFalse(filter1a.appliesToProperty("b")); - Assert.assertFalse(filter1b.appliesToProperty("a")); - Assert.assertTrue(filter1b.appliesToProperty("b")); - - Assert.assertTrue(filter2aa.appliesToProperty("a")); - Assert.assertFalse(filter2aa.appliesToProperty("b")); - Assert.assertTrue(filter2ab.appliesToProperty("a")); - Assert.assertTrue(filter2ab.appliesToProperty("b")); - - Assert.assertTrue(filter3abc.appliesToProperty("a")); - Assert.assertTrue(filter3abc.appliesToProperty("b")); - Assert.assertTrue(filter3abc.appliesToProperty("c")); - Assert.assertFalse(filter3abc.appliesToProperty("d")); + assertFalse(filter0.appliesToProperty("a")); + assertFalse(filter0.appliesToProperty("d")); + + assertTrue(filter1a.appliesToProperty("a")); + assertFalse(filter1a.appliesToProperty("b")); + assertFalse(filter1b.appliesToProperty("a")); + assertTrue(filter1b.appliesToProperty("b")); + + assertTrue(filter2aa.appliesToProperty("a")); + assertFalse(filter2aa.appliesToProperty("b")); + assertTrue(filter2ab.appliesToProperty("a")); + assertTrue(filter2ab.appliesToProperty("b")); + + assertTrue(filter3abc.appliesToProperty("a")); + assertTrue(filter3abc.appliesToProperty("b")); + assertTrue(filter3abc.appliesToProperty("c")); + assertFalse(filter3abc.appliesToProperty("d")); } @Test @@ -224,23 +227,23 @@ public class AndOrFilterTest new SameItemFilter(item1, "b"), new SameItemFilter(item1, "c")); // empty Or filters out everything - Assert.assertTrue(filter0.appliesToProperty("a")); - Assert.assertTrue(filter0.appliesToProperty("d")); - - Assert.assertTrue(filter1a.appliesToProperty("a")); - Assert.assertFalse(filter1a.appliesToProperty("b")); - Assert.assertFalse(filter1b.appliesToProperty("a")); - Assert.assertTrue(filter1b.appliesToProperty("b")); - - Assert.assertTrue(filter2aa.appliesToProperty("a")); - Assert.assertFalse(filter2aa.appliesToProperty("b")); - Assert.assertTrue(filter2ab.appliesToProperty("a")); - Assert.assertTrue(filter2ab.appliesToProperty("b")); - - Assert.assertTrue(filter3abc.appliesToProperty("a")); - Assert.assertTrue(filter3abc.appliesToProperty("b")); - Assert.assertTrue(filter3abc.appliesToProperty("c")); - Assert.assertFalse(filter3abc.appliesToProperty("d")); + assertTrue(filter0.appliesToProperty("a")); + assertTrue(filter0.appliesToProperty("d")); + + assertTrue(filter1a.appliesToProperty("a")); + assertFalse(filter1a.appliesToProperty("b")); + assertFalse(filter1b.appliesToProperty("a")); + assertTrue(filter1b.appliesToProperty("b")); + + assertTrue(filter2aa.appliesToProperty("a")); + assertFalse(filter2aa.appliesToProperty("b")); + assertTrue(filter2ab.appliesToProperty("a")); + assertTrue(filter2ab.appliesToProperty("b")); + + assertTrue(filter3abc.appliesToProperty("a")); + assertTrue(filter3abc.appliesToProperty("b")); + assertTrue(filter3abc.appliesToProperty("c")); + assertFalse(filter3abc.appliesToProperty("d")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java index 89e9d08cda..8e0e88ad58 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterDateTest.java @@ -1,9 +1,13 @@ package com.vaadin.v7.data.util.filter; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.text.SimpleDateFormat; import java.util.Date; -import org.junit.Assert; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -37,10 +41,8 @@ public class CompareFilterDateTest extends AbstractFilterTestBase<Compare> { protected Filter greaterEqualCompSqlDate; protected Filter lessEqualCompSqlDate; - @Override - protected void setUp() throws Exception { - super.setUp(); - + @Before + public void setUp() throws Exception { equalCompUtilDate = new Equal(PROPERTY1, formatter.parse("26072016")); greaterCompUtilDate = new Greater(PROPERTY1, formatter.parse("26072016")); @@ -78,9 +80,8 @@ public class CompareFilterDateTest extends AbstractFilterTestBase<Compare> { java.sql.Date.class)); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { itemNullUtilDate = null; itemNullSqlDate = null; itemUtilDate = null; @@ -89,54 +90,42 @@ public class CompareFilterDateTest extends AbstractFilterTestBase<Compare> { @Test public void testCompareUtilDatesAndUtilDates() { - Assert.assertFalse( - equalCompUtilDate.passesFilter(null, itemNullUtilDate)); - Assert.assertFalse(equalCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse( - greaterCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue(lessCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse( - greaterEqualCompUtilDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue( - lessEqualCompUtilDate.passesFilter(null, itemUtilDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemNullUtilDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterCompUtilDate.passesFilter(null, itemUtilDate)); + assertTrue(lessCompUtilDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterEqualCompUtilDate.passesFilter(null, itemUtilDate)); + assertTrue(lessEqualCompUtilDate.passesFilter(null, itemUtilDate)); } @Test public void testCompareUtilDatesAndSqlDates() { - Assert.assertFalse( - equalCompUtilDate.passesFilter(null, itemNullSqlDate)); - Assert.assertFalse(equalCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse(greaterCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue(lessCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse( - greaterEqualCompUtilDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue( - lessEqualCompUtilDate.passesFilter(null, itemSqlDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemNullSqlDate)); + assertFalse(equalCompUtilDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterCompUtilDate.passesFilter(null, itemSqlDate)); + assertTrue(lessCompUtilDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterEqualCompUtilDate.passesFilter(null, itemSqlDate)); + assertTrue(lessEqualCompUtilDate.passesFilter(null, itemSqlDate)); } @Test public void testCompareSqlDatesAndSqlDates() { - Assert.assertFalse( - equalCompSqlDate.passesFilter(null, itemNullSqlDate)); - Assert.assertFalse(equalCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse(greaterCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue(lessCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertFalse( - greaterEqualCompSqlDate.passesFilter(null, itemSqlDate)); - Assert.assertTrue(lessEqualCompSqlDate.passesFilter(null, itemSqlDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemNullSqlDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterCompSqlDate.passesFilter(null, itemSqlDate)); + assertTrue(lessCompSqlDate.passesFilter(null, itemSqlDate)); + assertFalse(greaterEqualCompSqlDate.passesFilter(null, itemSqlDate)); + assertTrue(lessEqualCompSqlDate.passesFilter(null, itemSqlDate)); } @Test public void testCompareSqlDatesAndUtilDates() { - Assert.assertFalse( - equalCompSqlDate.passesFilter(null, itemNullUtilDate)); - Assert.assertFalse(equalCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse(greaterCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue(lessCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertFalse( - greaterEqualCompSqlDate.passesFilter(null, itemUtilDate)); - Assert.assertTrue( - lessEqualCompSqlDate.passesFilter(null, itemUtilDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemNullUtilDate)); + assertFalse(equalCompSqlDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterCompSqlDate.passesFilter(null, itemUtilDate)); + assertTrue(lessCompSqlDate.passesFilter(null, itemUtilDate)); + assertFalse(greaterEqualCompSqlDate.passesFilter(null, itemUtilDate)); + assertTrue(lessEqualCompSqlDate.passesFilter(null, itemUtilDate)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java index b93c72e37e..be0eeebb33 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/CompareFilterTest.java @@ -1,9 +1,14 @@ package com.vaadin.v7.data.util.filter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; import java.util.Date; -import org.junit.Assert; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -37,9 +42,8 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { null); protected final Filter lessEqualNull = new LessOrEqual(PROPERTY1, null); - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { itemNull = new PropertysetItem(); itemNull.addItemProperty(PROPERTY1, new ObjectProperty<String>(null, String.class)); @@ -57,9 +61,8 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { new ObjectProperty<String>("c", String.class)); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { itemNull = null; itemEmpty = null; itemA = null; @@ -68,52 +71,52 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { @Test public void testCompareString() { - Assert.assertFalse(equalB.passesFilter(null, itemEmpty)); - Assert.assertFalse(equalB.passesFilter(null, itemA)); - Assert.assertTrue(equalB.passesFilter(null, itemB)); - Assert.assertFalse(equalB.passesFilter(null, itemC)); - - Assert.assertFalse(greaterB.passesFilter(null, itemEmpty)); - Assert.assertFalse(greaterB.passesFilter(null, itemA)); - Assert.assertFalse(greaterB.passesFilter(null, itemB)); - Assert.assertTrue(greaterB.passesFilter(null, itemC)); - - Assert.assertTrue(lessB.passesFilter(null, itemEmpty)); - Assert.assertTrue(lessB.passesFilter(null, itemA)); - Assert.assertFalse(lessB.passesFilter(null, itemB)); - Assert.assertFalse(lessB.passesFilter(null, itemC)); - - Assert.assertFalse(greaterEqualB.passesFilter(null, itemEmpty)); - Assert.assertFalse(greaterEqualB.passesFilter(null, itemA)); - Assert.assertTrue(greaterEqualB.passesFilter(null, itemB)); - Assert.assertTrue(greaterEqualB.passesFilter(null, itemC)); - - Assert.assertTrue(lessEqualB.passesFilter(null, itemEmpty)); - Assert.assertTrue(lessEqualB.passesFilter(null, itemA)); - Assert.assertTrue(lessEqualB.passesFilter(null, itemB)); - Assert.assertFalse(lessEqualB.passesFilter(null, itemC)); + assertFalse(equalB.passesFilter(null, itemEmpty)); + assertFalse(equalB.passesFilter(null, itemA)); + assertTrue(equalB.passesFilter(null, itemB)); + assertFalse(equalB.passesFilter(null, itemC)); + + assertFalse(greaterB.passesFilter(null, itemEmpty)); + assertFalse(greaterB.passesFilter(null, itemA)); + assertFalse(greaterB.passesFilter(null, itemB)); + assertTrue(greaterB.passesFilter(null, itemC)); + + assertTrue(lessB.passesFilter(null, itemEmpty)); + assertTrue(lessB.passesFilter(null, itemA)); + assertFalse(lessB.passesFilter(null, itemB)); + assertFalse(lessB.passesFilter(null, itemC)); + + assertFalse(greaterEqualB.passesFilter(null, itemEmpty)); + assertFalse(greaterEqualB.passesFilter(null, itemA)); + assertTrue(greaterEqualB.passesFilter(null, itemB)); + assertTrue(greaterEqualB.passesFilter(null, itemC)); + + assertTrue(lessEqualB.passesFilter(null, itemEmpty)); + assertTrue(lessEqualB.passesFilter(null, itemA)); + assertTrue(lessEqualB.passesFilter(null, itemB)); + assertFalse(lessEqualB.passesFilter(null, itemC)); } @Test public void testCompareWithNull() { // null comparisons: null is less than any other value - Assert.assertFalse(equalB.passesFilter(null, itemNull)); - Assert.assertTrue(greaterB.passesFilter(null, itemNull)); - Assert.assertFalse(lessB.passesFilter(null, itemNull)); - Assert.assertTrue(greaterEqualB.passesFilter(null, itemNull)); - Assert.assertFalse(lessEqualB.passesFilter(null, itemNull)); - - Assert.assertTrue(equalNull.passesFilter(null, itemNull)); - Assert.assertFalse(greaterNull.passesFilter(null, itemNull)); - Assert.assertFalse(lessNull.passesFilter(null, itemNull)); - Assert.assertTrue(greaterEqualNull.passesFilter(null, itemNull)); - Assert.assertTrue(lessEqualNull.passesFilter(null, itemNull)); - - Assert.assertFalse(equalNull.passesFilter(null, itemA)); - Assert.assertFalse(greaterNull.passesFilter(null, itemA)); - Assert.assertTrue(lessNull.passesFilter(null, itemA)); - Assert.assertFalse(greaterEqualNull.passesFilter(null, itemA)); - Assert.assertTrue(lessEqualNull.passesFilter(null, itemA)); + assertFalse(equalB.passesFilter(null, itemNull)); + assertTrue(greaterB.passesFilter(null, itemNull)); + assertFalse(lessB.passesFilter(null, itemNull)); + assertTrue(greaterEqualB.passesFilter(null, itemNull)); + assertFalse(lessEqualB.passesFilter(null, itemNull)); + + assertTrue(equalNull.passesFilter(null, itemNull)); + assertFalse(greaterNull.passesFilter(null, itemNull)); + assertFalse(lessNull.passesFilter(null, itemNull)); + assertTrue(greaterEqualNull.passesFilter(null, itemNull)); + assertTrue(lessEqualNull.passesFilter(null, itemNull)); + + assertFalse(equalNull.passesFilter(null, itemA)); + assertFalse(greaterNull.passesFilter(null, itemA)); + assertTrue(lessNull.passesFilter(null, itemA)); + assertFalse(greaterEqualNull.passesFilter(null, itemA)); + assertTrue(lessEqualNull.passesFilter(null, itemA)); } @Test @@ -133,29 +136,29 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { new ObjectProperty<Integer>(positive, Integer.class)); Filter equalZero = new Equal(PROPERTY1, zero); - Assert.assertFalse(equalZero.passesFilter(null, itemNegative)); - Assert.assertTrue(equalZero.passesFilter(null, itemZero)); - Assert.assertFalse(equalZero.passesFilter(null, itemPositive)); + assertFalse(equalZero.passesFilter(null, itemNegative)); + assertTrue(equalZero.passesFilter(null, itemZero)); + assertFalse(equalZero.passesFilter(null, itemPositive)); Filter isPositive = new Greater(PROPERTY1, zero); - Assert.assertFalse(isPositive.passesFilter(null, itemNegative)); - Assert.assertFalse(isPositive.passesFilter(null, itemZero)); - Assert.assertTrue(isPositive.passesFilter(null, itemPositive)); + assertFalse(isPositive.passesFilter(null, itemNegative)); + assertFalse(isPositive.passesFilter(null, itemZero)); + assertTrue(isPositive.passesFilter(null, itemPositive)); Filter isNegative = new Less(PROPERTY1, zero); - Assert.assertTrue(isNegative.passesFilter(null, itemNegative)); - Assert.assertFalse(isNegative.passesFilter(null, itemZero)); - Assert.assertFalse(isNegative.passesFilter(null, itemPositive)); + assertTrue(isNegative.passesFilter(null, itemNegative)); + assertFalse(isNegative.passesFilter(null, itemZero)); + assertFalse(isNegative.passesFilter(null, itemPositive)); Filter isNonNegative = new GreaterOrEqual(PROPERTY1, zero); - Assert.assertFalse(isNonNegative.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemZero)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemPositive)); + assertFalse(isNonNegative.passesFilter(null, itemNegative)); + assertTrue(isNonNegative.passesFilter(null, itemZero)); + assertTrue(isNonNegative.passesFilter(null, itemPositive)); Filter isNonPositive = new LessOrEqual(PROPERTY1, zero); - Assert.assertTrue(isNonPositive.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonPositive.passesFilter(null, itemZero)); - Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive)); + assertTrue(isNonPositive.passesFilter(null, itemNegative)); + assertTrue(isNonPositive.passesFilter(null, itemZero)); + assertFalse(isNonPositive.passesFilter(null, itemPositive)); } @Test @@ -181,35 +184,33 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { BigDecimal.class)); Filter equalZero = new Equal(PROPERTY1, zero); - Assert.assertFalse(equalZero.passesFilter(null, itemNegative)); - Assert.assertTrue(equalZero.passesFilter(null, itemZero)); - Assert.assertFalse(equalZero.passesFilter(null, itemPositive)); + assertFalse(equalZero.passesFilter(null, itemNegative)); + assertTrue(equalZero.passesFilter(null, itemZero)); + assertFalse(equalZero.passesFilter(null, itemPositive)); Filter isPositive = new Greater(PROPERTY1, zero); - Assert.assertFalse(isPositive.passesFilter(null, itemNegative)); - Assert.assertFalse(isPositive.passesFilter(null, itemZero)); - Assert.assertTrue(isPositive.passesFilter(null, itemPositive)); + assertFalse(isPositive.passesFilter(null, itemNegative)); + assertFalse(isPositive.passesFilter(null, itemZero)); + assertTrue(isPositive.passesFilter(null, itemPositive)); Filter isNegative = new Less(PROPERTY1, zero); - Assert.assertTrue(isNegative.passesFilter(null, itemNegative)); - Assert.assertFalse(isNegative.passesFilter(null, itemZero)); - Assert.assertFalse(isNegative.passesFilter(null, itemPositive)); + assertTrue(isNegative.passesFilter(null, itemNegative)); + assertFalse(isNegative.passesFilter(null, itemZero)); + assertFalse(isNegative.passesFilter(null, itemPositive)); Filter isNonNegative = new GreaterOrEqual(PROPERTY1, zero); - Assert.assertFalse(isNonNegative.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemZero)); - Assert.assertTrue(isNonNegative.passesFilter(null, itemPositive)); + assertFalse(isNonNegative.passesFilter(null, itemNegative)); + assertTrue(isNonNegative.passesFilter(null, itemZero)); + assertTrue(isNonNegative.passesFilter(null, itemPositive)); Filter isNonPositive = new LessOrEqual(PROPERTY1, zero); - Assert.assertTrue(isNonPositive.passesFilter(null, itemNegative)); - Assert.assertTrue(isNonPositive.passesFilter(null, itemZero)); - Assert.assertFalse(isNonPositive.passesFilter(null, itemPositive)); + assertTrue(isNonPositive.passesFilter(null, itemNegative)); + assertTrue(isNonPositive.passesFilter(null, itemZero)); + assertFalse(isNonPositive.passesFilter(null, itemPositive)); Filter isPositiveScaleTwo = new Equal(PROPERTY1, positiveScaleTwo); - Assert.assertTrue( - isPositiveScaleTwo.passesFilter(null, itemPositiveScaleTwo)); - Assert.assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositive)); - + assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositiveScaleTwo)); + assertTrue(isPositiveScaleTwo.passesFilter(null, itemPositive)); } @Test @@ -231,29 +232,29 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { new ObjectProperty<Date>(later, Date.class)); Filter equalNow = new Equal(PROPERTY1, now); - Assert.assertFalse(equalNow.passesFilter(null, itemEarlier)); - Assert.assertTrue(equalNow.passesFilter(null, itemNow)); - Assert.assertFalse(equalNow.passesFilter(null, itemLater)); + assertFalse(equalNow.passesFilter(null, itemEarlier)); + assertTrue(equalNow.passesFilter(null, itemNow)); + assertFalse(equalNow.passesFilter(null, itemLater)); Filter after = new Greater(PROPERTY1, now); - Assert.assertFalse(after.passesFilter(null, itemEarlier)); - Assert.assertFalse(after.passesFilter(null, itemNow)); - Assert.assertTrue(after.passesFilter(null, itemLater)); + assertFalse(after.passesFilter(null, itemEarlier)); + assertFalse(after.passesFilter(null, itemNow)); + assertTrue(after.passesFilter(null, itemLater)); Filter before = new Less(PROPERTY1, now); - Assert.assertTrue(before.passesFilter(null, itemEarlier)); - Assert.assertFalse(before.passesFilter(null, itemNow)); - Assert.assertFalse(before.passesFilter(null, itemLater)); + assertTrue(before.passesFilter(null, itemEarlier)); + assertFalse(before.passesFilter(null, itemNow)); + assertFalse(before.passesFilter(null, itemLater)); Filter afterOrNow = new GreaterOrEqual(PROPERTY1, now); - Assert.assertFalse(afterOrNow.passesFilter(null, itemEarlier)); - Assert.assertTrue(afterOrNow.passesFilter(null, itemNow)); - Assert.assertTrue(afterOrNow.passesFilter(null, itemLater)); + assertFalse(afterOrNow.passesFilter(null, itemEarlier)); + assertTrue(afterOrNow.passesFilter(null, itemNow)); + assertTrue(afterOrNow.passesFilter(null, itemLater)); Filter beforeOrNow = new LessOrEqual(PROPERTY1, now); - Assert.assertTrue(beforeOrNow.passesFilter(null, itemEarlier)); - Assert.assertTrue(beforeOrNow.passesFilter(null, itemNow)); - Assert.assertFalse(beforeOrNow.passesFilter(null, itemLater)); + assertTrue(beforeOrNow.passesFilter(null, itemEarlier)); + assertTrue(beforeOrNow.passesFilter(null, itemNow)); + assertFalse(beforeOrNow.passesFilter(null, itemLater)); } @Test @@ -261,10 +262,10 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { Filter filterA = new Equal("a", 1); Filter filterB = new Equal("b", 1); - Assert.assertTrue(filterA.appliesToProperty("a")); - Assert.assertFalse(filterA.appliesToProperty("b")); - Assert.assertFalse(filterB.appliesToProperty("a")); - Assert.assertTrue(filterB.appliesToProperty("b")); + assertTrue(filterA.appliesToProperty("a")); + assertFalse(filterA.appliesToProperty("b")); + assertFalse(filterB.appliesToProperty("a")); + assertTrue(filterB.appliesToProperty("b")); } @Test @@ -282,41 +283,41 @@ public class CompareFilterTest extends AbstractFilterTestBase<Compare> { Filter greaterEmpty = new Greater(PROPERTY1, ""); // equals() - Assert.assertEquals(equalNull, equalNull); - Assert.assertEquals(equalNull, equalNull2); - Assert.assertFalse(equalNull.equals(equalNullProperty2)); - Assert.assertFalse(equalNull.equals(equalEmpty)); - Assert.assertFalse(equalNull.equals(equalB)); - - Assert.assertEquals(equalEmpty, equalEmpty); - Assert.assertFalse(equalEmpty.equals(equalNull)); - Assert.assertEquals(equalEmpty, equalEmpty2); - Assert.assertFalse(equalEmpty.equals(equalEmptyProperty2)); - Assert.assertFalse(equalEmpty.equals(equalB)); - - Assert.assertEquals(equalB, equalB); - Assert.assertFalse(equalB.equals(equalNull)); - Assert.assertFalse(equalB.equals(equalEmpty)); - Assert.assertEquals(equalB, equalB2); - Assert.assertFalse(equalB.equals(equalBProperty2)); - Assert.assertFalse(equalB.equals(equalA)); - - Assert.assertEquals(greaterB, greaterB); - Assert.assertFalse(greaterB.equals(lessB)); - Assert.assertFalse(greaterB.equals(greaterEqualB)); - Assert.assertFalse(greaterB.equals(lessEqualB)); - - Assert.assertFalse(greaterNull.equals(greaterEmpty)); - Assert.assertFalse(greaterNull.equals(greaterB)); - Assert.assertFalse(greaterEmpty.equals(greaterNull)); - Assert.assertFalse(greaterEmpty.equals(greaterB)); - Assert.assertFalse(greaterB.equals(greaterNull)); - Assert.assertFalse(greaterB.equals(greaterEmpty)); + assertEquals(equalNull, equalNull); + assertEquals(equalNull, equalNull2); + assertFalse(equalNull.equals(equalNullProperty2)); + assertFalse(equalNull.equals(equalEmpty)); + assertFalse(equalNull.equals(equalB)); + + assertEquals(equalEmpty, equalEmpty); + assertFalse(equalEmpty.equals(equalNull)); + assertEquals(equalEmpty, equalEmpty2); + assertFalse(equalEmpty.equals(equalEmptyProperty2)); + assertFalse(equalEmpty.equals(equalB)); + + assertEquals(equalB, equalB); + assertFalse(equalB.equals(equalNull)); + assertFalse(equalB.equals(equalEmpty)); + assertEquals(equalB, equalB2); + assertFalse(equalB.equals(equalBProperty2)); + assertFalse(equalB.equals(equalA)); + + assertEquals(greaterB, greaterB); + assertFalse(greaterB.equals(lessB)); + assertFalse(greaterB.equals(greaterEqualB)); + assertFalse(greaterB.equals(lessEqualB)); + + assertFalse(greaterNull.equals(greaterEmpty)); + assertFalse(greaterNull.equals(greaterB)); + assertFalse(greaterEmpty.equals(greaterNull)); + assertFalse(greaterEmpty.equals(greaterB)); + assertFalse(greaterB.equals(greaterNull)); + assertFalse(greaterB.equals(greaterEmpty)); // hashCode() - Assert.assertEquals(equalNull.hashCode(), equalNull2.hashCode()); - Assert.assertEquals(equalEmpty.hashCode(), equalEmpty2.hashCode()); - Assert.assertEquals(equalB.hashCode(), equalB2.hashCode()); + assertEquals(equalNull.hashCode(), equalNull2.hashCode()); + assertEquals(equalEmpty.hashCode(), equalEmpty2.hashCode()); + assertEquals(equalB.hashCode(), equalB2.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java index 1b5705ea45..68e164fbb5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/IsNullFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -26,10 +29,10 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { Filter filter1 = new IsNull("a"); Filter filter2 = new IsNull("b"); - Assert.assertTrue(filter1.passesFilter(null, item1)); - Assert.assertFalse(filter1.passesFilter(null, item2)); - Assert.assertFalse(filter2.passesFilter(null, item1)); - Assert.assertTrue(filter2.passesFilter(null, item2)); + assertTrue(filter1.passesFilter(null, item1)); + assertFalse(filter1.passesFilter(null, item2)); + assertFalse(filter2.passesFilter(null, item1)); + assertTrue(filter2.passesFilter(null, item2)); } @Test @@ -37,10 +40,10 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { Filter filterA = new IsNull("a"); Filter filterB = new IsNull("b"); - Assert.assertTrue(filterA.appliesToProperty("a")); - Assert.assertFalse(filterA.appliesToProperty("b")); - Assert.assertFalse(filterB.appliesToProperty("a")); - Assert.assertTrue(filterB.appliesToProperty("b")); + assertTrue(filterA.appliesToProperty("a")); + assertFalse(filterA.appliesToProperty("b")); + assertFalse(filterB.appliesToProperty("a")); + assertTrue(filterB.appliesToProperty("b")); } @Test @@ -50,12 +53,12 @@ public class IsNullFilterTest extends AbstractFilterTestBase<IsNull> { Filter filter2 = new IsNull("b"); // equals() - Assert.assertEquals(filter1, filter1b); - Assert.assertFalse(filter1.equals(filter2)); - Assert.assertFalse(filter1.equals(new And())); + assertEquals(filter1, filter1b); + assertFalse(filter1.equals(filter2)); + assertFalse(filter1.equals(new And())); // hashCode() - Assert.assertEquals(filter1.hashCode(), filter1b.hashCode()); + assertEquals(filter1.hashCode(), filter1b.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java index cac985f359..9d622b4ecb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/LikeFilterTest.java @@ -16,7 +16,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Item; @@ -31,7 +33,6 @@ public class LikeFilterTest extends AbstractFilterTestBase<Like> { @Test public void testLikeWithNulls() { - Like filter = new Like("value", "a"); item1.addItemProperty("value", new ObjectProperty<String>("a")); @@ -39,10 +40,9 @@ public class LikeFilterTest extends AbstractFilterTestBase<Like> { item3.addItemProperty("value", new ObjectProperty<String>(null, String.class)); - Assert.assertTrue(filter.passesFilter(null, item1)); - Assert.assertFalse(filter.passesFilter(null, item2)); - Assert.assertFalse(filter.passesFilter(null, item3)); - + assertTrue(filter.passesFilter(null, item1)); + assertFalse(filter.passesFilter(null, item2)); + assertFalse(filter.passesFilter(null, item3)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java index cdf51abe5a..8a91edca11 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/NotFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -17,10 +20,10 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> { Filter origFilter = new SameItemFilter(item1); Filter filter = new Not(origFilter); - Assert.assertTrue(origFilter.passesFilter(null, item1)); - Assert.assertFalse(origFilter.passesFilter(null, item2)); - Assert.assertFalse(filter.passesFilter(null, item1)); - Assert.assertTrue(filter.passesFilter(null, item2)); + assertTrue(origFilter.passesFilter(null, item1)); + assertFalse(origFilter.passesFilter(null, item2)); + assertFalse(filter.passesFilter(null, item1)); + assertTrue(filter.passesFilter(null, item2)); } @Test @@ -28,10 +31,10 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> { Filter filterA = new Not(new SameItemFilter(item1, "a")); Filter filterB = new Not(new SameItemFilter(item1, "b")); - Assert.assertTrue(filterA.appliesToProperty("a")); - Assert.assertFalse(filterA.appliesToProperty("b")); - Assert.assertFalse(filterB.appliesToProperty("a")); - Assert.assertTrue(filterB.appliesToProperty("b")); + assertTrue(filterA.appliesToProperty("a")); + assertFalse(filterA.appliesToProperty("b")); + assertFalse(filterB.appliesToProperty("a")); + assertTrue(filterB.appliesToProperty("b")); } @Test @@ -42,13 +45,13 @@ public class NotFilterTest extends AbstractFilterTestBase<Not> { Filter filter2 = new Not(new SameItemFilter(item2)); // equals() - Assert.assertEquals(filter1, filter1b); - Assert.assertFalse(filter1.equals(filter2)); - Assert.assertFalse(filter1.equals(origFilter)); - Assert.assertFalse(filter1.equals(new And())); + assertEquals(filter1, filter1b); + assertFalse(filter1.equals(filter2)); + assertFalse(filter1.equals(origFilter)); + assertFalse(filter1.equals(new And())); // hashCode() - Assert.assertEquals(filter1.hashCode(), filter1b.hashCode()); + assertEquals(filter1.hashCode(), filter1b.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java index cf0af5fe7b..97da946cb3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/filter/SimpleStringFilterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.filter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class SimpleStringFilterTest @@ -28,50 +31,50 @@ public class SimpleStringFilterTest @Test public void testStartsWithCaseSensitive() { - Assert.assertTrue(passes(PROPERTY1, "ab", false, true)); - Assert.assertTrue(passes(PROPERTY1, "", false, true)); + assertTrue(passes(PROPERTY1, "ab", false, true)); + assertTrue(passes(PROPERTY1, "", false, true)); - Assert.assertFalse(passes(PROPERTY2, "ab", false, true)); - Assert.assertFalse(passes(PROPERTY1, "AB", false, true)); + assertFalse(passes(PROPERTY2, "ab", false, true)); + assertFalse(passes(PROPERTY1, "AB", false, true)); } @Test public void testStartsWithCaseInsensitive() { - Assert.assertTrue(passes(PROPERTY1, "AB", true, true)); - Assert.assertTrue(passes(PROPERTY2, "te", true, true)); - Assert.assertFalse(passes(PROPERTY2, "AB", true, true)); + assertTrue(passes(PROPERTY1, "AB", true, true)); + assertTrue(passes(PROPERTY2, "te", true, true)); + assertFalse(passes(PROPERTY2, "AB", true, true)); } @Test public void testContainsCaseSensitive() { - Assert.assertTrue(passes(PROPERTY1, "ab", false, false)); - Assert.assertTrue(passes(PROPERTY1, "abcde", false, false)); - Assert.assertTrue(passes(PROPERTY1, "cd", false, false)); - Assert.assertTrue(passes(PROPERTY1, "e", false, false)); - Assert.assertTrue(passes(PROPERTY1, "", false, false)); - - Assert.assertFalse(passes(PROPERTY2, "ab", false, false)); - Assert.assertFalse(passes(PROPERTY1, "es", false, false)); + assertTrue(passes(PROPERTY1, "ab", false, false)); + assertTrue(passes(PROPERTY1, "abcde", false, false)); + assertTrue(passes(PROPERTY1, "cd", false, false)); + assertTrue(passes(PROPERTY1, "e", false, false)); + assertTrue(passes(PROPERTY1, "", false, false)); + + assertFalse(passes(PROPERTY2, "ab", false, false)); + assertFalse(passes(PROPERTY1, "es", false, false)); } @Test public void testContainsCaseInsensitive() { - Assert.assertTrue(passes(PROPERTY1, "AB", true, false)); - Assert.assertTrue(passes(PROPERTY1, "aBcDe", true, false)); - Assert.assertTrue(passes(PROPERTY1, "CD", true, false)); - Assert.assertTrue(passes(PROPERTY1, "", true, false)); + assertTrue(passes(PROPERTY1, "AB", true, false)); + assertTrue(passes(PROPERTY1, "aBcDe", true, false)); + assertTrue(passes(PROPERTY1, "CD", true, false)); + assertTrue(passes(PROPERTY1, "", true, false)); - Assert.assertTrue(passes(PROPERTY2, "es", true, false)); + assertTrue(passes(PROPERTY2, "es", true, false)); - Assert.assertFalse(passes(PROPERTY2, "ab", true, false)); + assertFalse(passes(PROPERTY2, "ab", true, false)); } @Test public void testAppliesToProperty() { SimpleStringFilter filter = f(PROPERTY1, "ab", false, true); - Assert.assertTrue(filter.appliesToProperty(PROPERTY1)); - Assert.assertFalse(filter.appliesToProperty(PROPERTY2)); - Assert.assertFalse(filter.appliesToProperty("other")); + assertTrue(filter.appliesToProperty(PROPERTY1)); + assertFalse(filter.appliesToProperty(PROPERTY2)); + assertFalse(filter.appliesToProperty("other")); } @Test @@ -88,43 +91,43 @@ public class SimpleStringFilterTest SimpleStringFilter f4b = f(PROPERTY1, "ab", false, false); // equal but not same instance - Assert.assertEquals(f1, f1b); - Assert.assertEquals(f2, f2b); - Assert.assertEquals(f3, f3b); - Assert.assertEquals(f4, f4b); + assertEquals(f1, f1b); + assertEquals(f2, f2b); + assertEquals(f3, f3b); + assertEquals(f4, f4b); // more than one property differ - Assert.assertFalse(f1.equals(f2)); - Assert.assertFalse(f1.equals(f3)); - Assert.assertFalse(f1.equals(f4)); - Assert.assertFalse(f2.equals(f1)); - Assert.assertFalse(f2.equals(f3)); - Assert.assertFalse(f2.equals(f4)); - Assert.assertFalse(f3.equals(f1)); - Assert.assertFalse(f3.equals(f2)); - Assert.assertFalse(f3.equals(f4)); - Assert.assertFalse(f4.equals(f1)); - Assert.assertFalse(f4.equals(f2)); - Assert.assertFalse(f4.equals(f3)); + assertFalse(f1.equals(f2)); + assertFalse(f1.equals(f3)); + assertFalse(f1.equals(f4)); + assertFalse(f2.equals(f1)); + assertFalse(f2.equals(f3)); + assertFalse(f2.equals(f4)); + assertFalse(f3.equals(f1)); + assertFalse(f3.equals(f2)); + assertFalse(f3.equals(f4)); + assertFalse(f4.equals(f1)); + assertFalse(f4.equals(f2)); + assertFalse(f4.equals(f3)); // only one property differs - Assert.assertFalse(filter.equals(f1)); - Assert.assertFalse(filter.equals(f2)); - Assert.assertFalse(filter.equals(f3)); - Assert.assertFalse(filter.equals(f4)); - - Assert.assertFalse(f1.equals(null)); - Assert.assertFalse(f1.equals(new Object())); - - Assert.assertEquals(f1.hashCode(), f1b.hashCode()); - Assert.assertEquals(f2.hashCode(), f2b.hashCode()); - Assert.assertEquals(f3.hashCode(), f3b.hashCode()); - Assert.assertEquals(f4.hashCode(), f4b.hashCode()); + assertFalse(filter.equals(f1)); + assertFalse(filter.equals(f2)); + assertFalse(filter.equals(f3)); + assertFalse(filter.equals(f4)); + + assertFalse(f1.equals(null)); + assertFalse(f1.equals(new Object())); + + assertEquals(f1.hashCode(), f1b.hashCode()); + assertEquals(f2.hashCode(), f2b.hashCode()); + assertEquals(f3.hashCode(), f3b.hashCode()); + assertEquals(f4.hashCode(), f4b.hashCode()); } @Test public void testNonExistentProperty() { - Assert.assertFalse(passes("other1", "ab", false, true)); + assertFalse(passes("other1", "ab", false, true)); } @Test @@ -132,8 +135,7 @@ public class SimpleStringFilterTest TestItem<String, String> item = createTestItem(); item.addItemProperty("other1", new NullProperty()); - Assert.assertFalse( - f("other1", "ab", false, true).passesFilter(null, item)); + assertFalse(f("other1", "ab", false, true).passesFilter(null, item)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java index 7392674fce..c4fd631ad0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ColumnPropertyTest.java @@ -1,5 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; @@ -9,7 +16,6 @@ import java.util.Arrays; import java.util.List; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property.ReadOnlyException; @@ -22,7 +28,7 @@ public class ColumnPropertyTest { public void constructor_legalParameters_shouldSucceed() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertNotNull(cp); + assertNotNull(cp); } @Test(expected = IllegalArgumentException.class) @@ -40,7 +46,7 @@ public class ColumnPropertyTest { public void getValue_defaultValue_returnsVille() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertEquals("Ville", cp.getValue()); + assertEquals("Ville", cp.getValue()); } @Test @@ -53,7 +59,7 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue("Kalle"); - Assert.assertEquals("Kalle", cp.getValue()); + assertEquals("Kalle", cp.getValue()); EasyMock.verify(container); } @@ -79,7 +85,7 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue(null); - Assert.assertNull(cp.getValue()); + assertNull(cp.getValue()); EasyMock.verify(container); } @@ -93,7 +99,7 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue(null); - Assert.assertNotNull(cp.getValue()); + assertNotNull(cp.getValue()); EasyMock.verify(container); } @@ -101,21 +107,21 @@ public class ColumnPropertyTest { public void getType_normal_returnsStringClass() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertSame(String.class, cp.getType()); + assertSame(String.class, cp.getType()); } @Test public void isReadOnly_readWriteNullable_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertFalse(cp.isReadOnly()); + assertFalse(cp.isReadOnly()); } @Test public void isReadOnly_readOnlyNullable_returnsTrue() { ColumnProperty cp = new ColumnProperty("NAME", true, true, true, false, "Ville", String.class); - Assert.assertTrue(cp.isReadOnly()); + assertTrue(cp.isReadOnly()); } @Test @@ -123,7 +129,7 @@ public class ColumnPropertyTest { ColumnProperty cp = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); cp.setReadOnly(true); - Assert.assertTrue(cp.isReadOnly()); + assertTrue(cp.isReadOnly()); } @Test @@ -131,14 +137,14 @@ public class ColumnPropertyTest { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, false, "Ville", String.class); cp.setReadOnly(true); - Assert.assertFalse(cp.isReadOnly()); + assertFalse(cp.isReadOnly()); } @Test public void getPropertyId_normal_returnsNAME() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, false, "Ville", String.class); - Assert.assertEquals("NAME", cp.getPropertyId()); + assertEquals("NAME", cp.getPropertyId()); } @Test @@ -151,8 +157,8 @@ public class ColumnPropertyTest { container.itemChangeNotification(owner); EasyMock.replay(container); cp.setValue("Kalle"); - Assert.assertEquals("Kalle", cp.getValue()); - Assert.assertTrue(cp.isModified()); + assertEquals("Kalle", cp.getValue()); + assertTrue(cp.isModified()); EasyMock.verify(container); } @@ -160,7 +166,7 @@ public class ColumnPropertyTest { public void isModified_valueNotModified_returnsFalse() { ColumnProperty cp = new ColumnProperty("NAME", false, false, true, false, "Ville", String.class); - Assert.assertFalse(cp.isModified()); + assertFalse(cp.isModified()); } @Test @@ -171,7 +177,7 @@ public class ColumnPropertyTest { new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); cp.setValue(null); - Assert.assertNull(cp.getValue()); + assertNull(cp.getValue()); } @Test @@ -182,9 +188,9 @@ public class ColumnPropertyTest { new RowItem(container, new RowId(new Object[] { 1 }), Arrays.asList(cp)); cp.setValue("asdf"); - Assert.assertEquals("asdf", cp.getValue()); + assertEquals("asdf", cp.getValue()); cp.setValue(null); - Assert.assertNull(cp.getValue()); + assertNull(cp.getValue()); } @Test @@ -232,8 +238,8 @@ public class ColumnPropertyTest { Arrays.asList(property)); property.setValue("Kalle"); - Assert.assertEquals("Kalle", container.value); - Assert.assertTrue(container.modified); + assertEquals("Kalle", container.value); + assertTrue(container.modified); } @Test @@ -242,7 +248,7 @@ public class ColumnPropertyTest { false, "Ville", String.class); property.setVersionColumn(true); - Assert.assertFalse(property.isPersistent()); + assertFalse(property.isPersistent()); } @Test @@ -250,7 +256,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", true, false, true, false, "Ville", String.class); - Assert.assertFalse(property.isPersistent()); + assertFalse(property.isPersistent()); } @Test @@ -258,7 +264,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertTrue(property.isPersistent()); + assertTrue(property.isPersistent()); } @Test @@ -266,7 +272,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", true, true, true, false, "Ville", String.class); - Assert.assertFalse(property.isPersistent()); + assertFalse(property.isPersistent()); } @Test @@ -274,7 +280,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", false, true, true, true, "Ville", String.class); - Assert.assertTrue(property.isRowIdentifier()); + assertTrue(property.isRowIdentifier()); } @Test @@ -283,7 +289,7 @@ public class ColumnPropertyTest { false, "Ville", String.class); property.setVersionColumn(true); - Assert.assertTrue(property.isRowIdentifier()); + assertTrue(property.isRowIdentifier()); } @Test @@ -291,7 +297,7 @@ public class ColumnPropertyTest { ColumnProperty property = new ColumnProperty("NAME", false, true, true, false, "Ville", String.class); - Assert.assertFalse(property.isRowIdentifier()); + assertFalse(property.isRowIdentifier()); } @Test @@ -311,9 +317,9 @@ public class ColumnPropertyTest { property.setValue("Kalle"); // Just check that the new value was actually set... - Assert.assertEquals("Kalle", property.getValue()); + assertEquals("Kalle", property.getValue()); // Assert that old value is the original value... - Assert.assertEquals("Ville", property.getOldValue()); + assertEquals("Ville", property.getOldValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java index 02d59e4489..4eb6bea454 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/DataGenerator.java @@ -1,12 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertTrue; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import org.junit.Assert; - import com.vaadin.v7.data.util.sqlcontainer.SQLTestsConstants.DB; import com.vaadin.v7.data.util.sqlcontainer.connection.JDBCConnectionPool; @@ -50,7 +50,7 @@ public class DataGenerator { statement.close(); statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select * from PEOPLE"); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); statement.close(); conn.commit(); connectionPool.releaseConnection(conn); @@ -102,7 +102,7 @@ public class DataGenerator { statement.close(); statement = conn.createStatement(); ResultSet rs = statement.executeQuery("select * from VERSIONED"); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); statement.close(); conn.commit(); connectionPool.releaseConnection(conn); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java index b1208c7b94..e668a081d2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/ReadOnlyRowIdTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.sqlcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class ReadOnlyRowIdTest { @@ -9,47 +12,47 @@ public class ReadOnlyRowIdTest { public void getRowNum_shouldReturnRowNumGivenInConstructor() { int rowNum = 1337; ReadOnlyRowId rid = new ReadOnlyRowId(rowNum); - Assert.assertEquals(rowNum, rid.getRowNum()); + assertEquals(rowNum, rid.getRowNum()); } @Test public void hashCode_shouldBeEqualToHashCodeOfRowNum() { int rowNum = 1337; ReadOnlyRowId rid = new ReadOnlyRowId(rowNum); - Assert.assertEquals(Integer.valueOf(rowNum).hashCode(), rid.hashCode()); + assertEquals(Integer.valueOf(rowNum).hashCode(), rid.hashCode()); } @Test public void equals_compareWithNull_shouldBeFalse() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); - Assert.assertFalse(rid.equals(null)); + assertFalse(rid.equals(null)); } @Test public void equals_compareWithSameInstance_shouldBeTrue() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); ReadOnlyRowId rid2 = rid; - Assert.assertTrue(rid.equals(rid2)); + assertTrue(rid.equals(rid2)); } @Test public void equals_compareWithOtherType_shouldBeFalse() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); - Assert.assertFalse(rid.equals(new Object())); + assertFalse(rid.equals(new Object())); } @Test public void equals_compareWithOtherRowId_shouldBeFalse() { ReadOnlyRowId rid = new ReadOnlyRowId(1337); ReadOnlyRowId rid2 = new ReadOnlyRowId(42); - Assert.assertFalse(rid.equals(rid2)); + assertFalse(rid.equals(rid2)); } @Test public void toString_rowNumberIsReturned() { int i = 1; ReadOnlyRowId rowId = new ReadOnlyRowId(i); - Assert.assertEquals("Unexpected toString value", String.valueOf(i), + assertEquals("Unexpected toString value", String.valueOf(i), rowId.toString()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java index e9e869223d..7368bacfdf 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/RowIdTest.java @@ -1,6 +1,10 @@ package com.vaadin.v7.data.util.sqlcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class RowIdTest { @@ -8,7 +12,7 @@ public class RowIdTest { @Test public void constructor_withArrayOfPrimaryKeyColumns_shouldSucceed() { RowId id = new RowId(new Object[] { "id", "name" }); - Assert.assertArrayEquals(new Object[] { "id", "name" }, id.getId()); + assertArrayEquals(new Object[] { "id", "name" }, id.getId()); } @Test(expected = IllegalArgumentException.class) @@ -20,41 +24,41 @@ public class RowIdTest { public void hashCode_samePrimaryKeys_sameResult() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id", "name" }); - Assert.assertEquals(id.hashCode(), id2.hashCode()); + assertEquals(id.hashCode(), id2.hashCode()); } @Test public void hashCode_differentPrimaryKeys_differentResult() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id" }); - Assert.assertFalse(id.hashCode() == id2.hashCode()); + assertFalse(id.hashCode() == id2.hashCode()); } @Test public void equals_samePrimaryKeys_returnsTrue() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id", "name" }); - Assert.assertEquals(id, id2); + assertEquals(id, id2); } @Test public void equals_differentPrimaryKeys_returnsFalse() { RowId id = new RowId(new Object[] { "id", "name" }); RowId id2 = new RowId(new Object[] { "id" }); - Assert.assertFalse(id.equals(id2.hashCode())); + assertFalse(id.equals(id2.hashCode())); } @Test public void equals_differentDataType_returnsFalse() { RowId id = new RowId(new Object[] { "id", "name" }); - Assert.assertFalse(id.equals("Tudiluu")); - Assert.assertFalse(id.equals(new Integer(1337))); + assertFalse(id.equals("Tudiluu")); + assertFalse(id.equals(new Integer(1337))); } @Test public void toString_defaultCtor_noException() { RowId rowId = new RowId(); - Assert.assertTrue("Unexpected to string for empty Row Id", + assertTrue("Unexpected to string for empty Row Id", rowId.toString().isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java index e04b6fc643..92e1fd61e1 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java @@ -5,9 +5,15 @@ import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.math.BigDecimal; import java.sql.Connection; @@ -19,7 +25,6 @@ import java.util.List; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -56,7 +61,7 @@ public class SQLContainerTableQueryTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -227,9 +232,9 @@ public class SQLContainerTableQueryTest { for (Object o : itemIds) { oracle.add(o.toString()); } - Assert.assertArrayEquals(correct, oracle.toArray()); + assertArrayEquals(correct, oracle.toArray()); } else { - Assert.assertArrayEquals(new Object[] { zero, one, two, three }, + assertArrayEquals(new Object[] { zero, one, two, three }, itemIds.toArray()); } } @@ -376,10 +381,10 @@ public class SQLContainerTableQueryTest { @Test public void isFirstId_tableSecondId_returnsFalse() throws SQLException { if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isFirstId( + assertFalse(container.isFirstId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse(container + assertFalse(container .isFirstId(new RowId(new Object[] { 1 + offset }))); } } @@ -387,10 +392,10 @@ public class SQLContainerTableQueryTest { @Test public void isLastId_tableSecondId_returnsFalse() throws SQLException { if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isLastId( + assertFalse(container.isLastId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse( + assertFalse( container.isLastId(new RowId(new Object[] { 1 + offset }))); } } @@ -464,7 +469,7 @@ public class SQLContainerTableQueryTest { container.setAutoCommit(true); assertTrue(container.isAutoCommit()); container.setAutoCommit(false); - Assert.assertFalse(container.isAutoCommit()); + assertFalse(container.isAutoCommit()); } @Test @@ -521,7 +526,7 @@ public class SQLContainerTableQueryTest { @Test public void addItem_tableAddOneNewItem_returnsItemId() throws SQLException { Object itemId = container.addItem(); - Assert.assertNotNull(itemId); + assertNotNull(itemId); } @Test @@ -529,9 +534,9 @@ public class SQLContainerTableQueryTest { throws SQLException { container.setAutoCommit(true); Object itemId = container.addItem(); - Assert.assertNotNull(itemId); + assertNotNull(itemId); assertTrue(itemId instanceof RowId); - Assert.assertFalse(itemId instanceof TemporaryRowId); + assertFalse(itemId instanceof TemporaryRowId); } @Test @@ -558,8 +563,8 @@ public class SQLContainerTableQueryTest { Object id1 = container.addItem(); Object id2 = container.addItem(); assertEquals(size + 2, container.size()); - Assert.assertNotSame(id1, id2); - Assert.assertFalse(id1.equals(id2)); + assertNotSame(id1, id2); + assertFalse(id1.equals(id2)); } @Test @@ -576,7 +581,7 @@ public class SQLContainerTableQueryTest { Object lastId = container.lastItemId(); Object id = container.addItem(); assertEquals(id, container.lastItemId()); - Assert.assertNotSame(lastId, container.lastItemId()); + assertNotSame(lastId, container.lastItemId()); } @Test @@ -590,7 +595,7 @@ public class SQLContainerTableQueryTest { public void getItem_tableNewlyAddedItem_returnsNewlyAdded() throws SQLException { Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); + assertNotNull(container.getItem(id)); } @Test @@ -634,7 +639,7 @@ public class SQLContainerTableQueryTest { Object id = garbageContainer.addItem(); - Assert.assertSame(id, garbageContainer.firstItemId()); + assertSame(id, garbageContainer.firstItemId()); } @Test @@ -681,7 +686,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.firstItemId()); + assertNotSame(id, container.firstItemId()); assertEquals(originalSize - 1, container.size()); } @@ -689,7 +694,7 @@ public class SQLContainerTableQueryTest { public void containsId_tableRemovedItem_returnsFalse() throws SQLException { Object id = container.firstItemId(); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); } @Test @@ -699,7 +704,7 @@ public class SQLContainerTableQueryTest { int size = container.size(); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); assertEquals(size - 1, container.size()); } @@ -708,7 +713,7 @@ public class SQLContainerTableQueryTest { Object id = container.firstItemId(); assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertNull(container.getItem(id)); } @Test @@ -716,9 +721,9 @@ public class SQLContainerTableQueryTest { throws SQLException { Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); + assertNotNull(container.getItem(id)); assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertNull(container.getItem(id)); } @Test @@ -728,7 +733,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.getItemIds().contains(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -738,7 +743,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.getItemIds().contains(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -747,7 +752,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.containsId(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); } @Test @@ -757,7 +762,7 @@ public class SQLContainerTableQueryTest { assertTrue(container.containsId(id)); assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertFalse(container.containsId(id)); } @Test @@ -810,7 +815,7 @@ public class SQLContainerTableQueryTest { Object first = container.firstItemId(); assertTrue(container.removeItem(first)); - Assert.assertNotSame(first, container.firstItemId()); + assertNotSame(first, container.firstItemId()); } @Test @@ -821,9 +826,9 @@ public class SQLContainerTableQueryTest { Object first = garbageContainer.addItem(); Object second = garbageContainer.addItem(); - Assert.assertSame(first, garbageContainer.firstItemId()); + assertSame(first, garbageContainer.firstItemId()); assertTrue(garbageContainer.removeItem(first)); - Assert.assertSame(second, garbageContainer.firstItemId()); + assertSame(second, garbageContainer.firstItemId()); } @Test @@ -832,7 +837,7 @@ public class SQLContainerTableQueryTest { Object last = container.lastItemId(); assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertNotSame(last, container.lastItemId()); } @Test @@ -840,9 +845,9 @@ public class SQLContainerTableQueryTest { throws SQLException { Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); + assertSame(last, container.lastItemId()); assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertNotSame(last, container.lastItemId()); } @Test @@ -851,7 +856,7 @@ public class SQLContainerTableQueryTest { Object first = container.firstItemId(); assertTrue(container.removeItem(first)); - Assert.assertFalse(container.isFirstId(first)); + assertFalse(container.isFirstId(first)); } @Test @@ -862,9 +867,9 @@ public class SQLContainerTableQueryTest { Object first = garbageContainer.addItem(); garbageContainer.addItem(); - Assert.assertSame(first, garbageContainer.firstItemId()); + assertSame(first, garbageContainer.firstItemId()); assertTrue(garbageContainer.removeItem(first)); - Assert.assertFalse(garbageContainer.isFirstId(first)); + assertFalse(garbageContainer.isFirstId(first)); } @Test @@ -873,7 +878,7 @@ public class SQLContainerTableQueryTest { Object last = container.lastItemId(); assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertFalse(container.isLastId(last)); } @Test @@ -881,9 +886,9 @@ public class SQLContainerTableQueryTest { throws SQLException { Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); + assertSame(last, container.lastItemId()); assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertFalse(container.isLastId(last)); } @Test @@ -910,7 +915,7 @@ public class SQLContainerTableQueryTest { Object id = container.getIdByIndex(2); assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(2)); + assertNotSame(id, container.getIdByIndex(2)); } @Test @@ -921,7 +926,7 @@ public class SQLContainerTableQueryTest { int index = container.indexOfId(id); assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(index)); + assertNotSame(id, container.getIdByIndex(index)); } @Test @@ -967,9 +972,9 @@ public class SQLContainerTableQueryTest { container.getContainerProperty(id, NAME).setValue("New Name"); assertTrue(id instanceof TemporaryRowId); - Assert.assertSame(id, container.lastItemId()); + assertSame(id, container.lastItemId()); container.commit(); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertFalse(container.lastItemId() instanceof TemporaryRowId); assertEquals("New Name", container .getContainerProperty(container.lastItemId(), NAME).getValue()); } @@ -982,14 +987,14 @@ public class SQLContainerTableQueryTest { container.getContainerProperty(id, NAME).setValue("Herbert"); container.getContainerProperty(id2, NAME).setValue("Larry"); assertTrue(id2 instanceof TemporaryRowId); - Assert.assertSame(id2, container.lastItemId()); + assertSame(id2, container.lastItemId()); container.commit(); Object nextToLast = container.getIdByIndex(container.size() - 2); - Assert.assertFalse(nextToLast instanceof TemporaryRowId); + assertFalse(nextToLast instanceof TemporaryRowId); assertEquals("Herbert", container.getContainerProperty(nextToLast, NAME).getValue()); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertFalse(container.lastItemId() instanceof TemporaryRowId); assertEquals("Larry", container .getContainerProperty(container.lastItemId(), NAME).getValue()); } @@ -1001,7 +1006,7 @@ public class SQLContainerTableQueryTest { container.removeItem(last); container.commit(); - Assert.assertFalse(last.equals(container.lastItemId())); + assertFalse(last.equals(container.lastItemId())); } @Test @@ -1036,7 +1041,7 @@ public class SQLContainerTableQueryTest { assertEquals(size + 1, container.size()); container.rollback(); assertEquals(size, container.size()); - Assert.assertFalse("foo".equals( + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), NAME) .getValue())); } @@ -1059,7 +1064,7 @@ public class SQLContainerTableQueryTest { Object last = container.lastItemId(); container.getContainerProperty(last, NAME).setValue("foo"); container.rollback(); - Assert.assertFalse("foo".equals( + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), NAME) .getValue())); } @@ -1067,7 +1072,7 @@ public class SQLContainerTableQueryTest { @Test public void itemChangeNotification_table_isModifiedReturnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); RowItem last = (RowItem) container.getItem(container.lastItemId()); container.itemChangeNotification(last); assertTrue(container.isModified()); @@ -1116,21 +1121,21 @@ public class SQLContainerTableQueryTest { @Test public void isModified_tableRemovedItem_returnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.removeItem(container.lastItemId()); assertTrue(container.isModified()); } @Test public void isModified_tableAddedItem_returnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.addItem(); assertTrue(container.isModified()); } @Test public void isModified_tableChangedItem_returnsTrue() throws SQLException { - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.getContainerProperty(container.lastItemId(), NAME) .setValue("foo"); assertTrue(container.isModified()); @@ -1146,7 +1151,7 @@ public class SQLContainerTableQueryTest { assertEquals(3, sortableIds.size()); if (SQLTestsConstants.db == DB.MSSQL || SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(sortableIds.contains("rownum")); + assertFalse(sortableIds.contains("rownum")); } } @@ -1304,21 +1309,20 @@ public class SQLContainerTableQueryTest { try { container.getIdByIndex(4); - Assert.fail( - "SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); + fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); } catch (IndexOutOfBoundsException e) { // should throw exception - item is filtered out } - Assert.assertNull(container.nextItemId(container.getIdByIndex(3))); + assertNull(container.nextItemId(container.getIdByIndex(3))); - Assert.assertFalse(container.containsId(id2)); - Assert.assertFalse(container.getItemIds().contains(id2)); + assertFalse(container.containsId(id2)); + assertFalse(container.getItemIds().contains(id2)); - Assert.assertNull(container.getItem(id2)); + assertNull(container.getItem(id2)); assertEquals(-1, container.indexOfId(id2)); - Assert.assertNotSame(id2, container.lastItemId()); - Assert.assertSame(id1, container.lastItemId()); + assertNotSame(id2, container.lastItemId()); + assertSame(id1, container.lastItemId()); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java index fe344cf8ef..1842b41734 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTest.java @@ -1,5 +1,15 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.math.BigDecimal; import java.sql.Connection; import java.sql.SQLException; @@ -14,7 +24,6 @@ import java.util.logging.Logger; import org.easymock.EasyMock; import org.easymock.IAnswer; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -50,7 +59,7 @@ public class SQLContainerTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -83,7 +92,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertTrue(container.containsId(new RowId(new Object[] { 1 }))); + assertTrue(container.containsId(new RowId(new Object[] { 1 }))); } @Test @@ -91,8 +100,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse( - container.containsId(new RowId(new Object[] { 1337 }))); + assertFalse(container.containsId(new RowId(new Object[] { 1337 }))); } @Test @@ -101,12 +109,12 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(new RowId( new Object[] { new BigDecimal(0 + offset) }), "NAME").getValue()); } else { - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty( new RowId(new Object[] { 0 + offset }), "NAME") .getValue()); @@ -118,7 +126,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertNull(container.getContainerProperty( + assertNull(container.getContainerProperty( new RowId(new Object[] { 1 + offset }), "asdf")); } @@ -127,7 +135,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertNull(container.getContainerProperty( + assertNull(container.getContainerProperty( new RowId(new Object[] { 1337 + offset }), "NAME")); } @@ -137,8 +145,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Collection<?> propertyIds = container.getContainerPropertyIds(); - Assert.assertEquals(3, propertyIds.size()); - Assert.assertArrayEquals(new String[] { "ID", "NAME", "AGE" }, + assertEquals(3, propertyIds.size()); + assertArrayEquals(new String[] { "ID", "NAME", "AGE" }, propertyIds.toArray()); } @@ -154,8 +162,8 @@ public class SQLContainerTest { } else { item = container.getItem(new RowId(new Object[] { 0 + offset })); } - Assert.assertNotNull(item); - Assert.assertEquals("Ville", item.getItemProperty("NAME").getValue()); + assertNotNull(item); + assertEquals("Ville", item.getItemProperty("NAME").getValue()); } @Test @@ -164,7 +172,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object lastItemId = container.lastItemId(); Object afterLast = container.nextItemId(lastItemId); - Assert.assertNull(afterLast); + assertNull(afterLast); } @Test @@ -173,7 +181,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object firstItemId = container.firstItemId(); Object beforeFirst = container.prevItemId(firstItemId); - Assert.assertNull(beforeFirst); + assertNull(beforeFirst); } @Test @@ -186,17 +194,15 @@ public class SQLContainerTest { if (SQLTestsConstants.db == DB.ORACLE) { item = container.getItem( new RowId(new Object[] { new BigDecimal(1337 + offset) })); - Assert.assertNotNull(item); - Assert.assertEquals(new BigDecimal(1337 + offset), + assertNotNull(item); + assertEquals(new BigDecimal(1337 + offset), item.getItemProperty("ID").getValue()); } else { item = container.getItem(new RowId(new Object[] { 1337 + offset })); - Assert.assertNotNull(item); - Assert.assertEquals(1337 + offset, - item.getItemProperty("ID").getValue()); + assertNotNull(item); + assertEquals(1337 + offset, item.getItemProperty("ID").getValue()); } - Assert.assertEquals("Person 1337", - item.getItemProperty("NAME").getValue()); + assertEquals("Person 1337", item.getItemProperty("NAME").getValue()); } @Test @@ -205,7 +211,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Collection<?> itemIds = container.getItemIds(); - Assert.assertEquals(4, itemIds.size()); + assertEquals(4, itemIds.size()); RowId zero = new RowId(new Object[] { 0 + offset }); RowId one = new RowId(new Object[] { 1 + offset }); RowId two = new RowId(new Object[] { 2 + offset }); @@ -216,9 +222,9 @@ public class SQLContainerTest { for (Object o : itemIds) { oracle.add(o.toString()); } - Assert.assertArrayEquals(correct, oracle.toArray()); + assertArrayEquals(correct, oracle.toArray()); } else { - Assert.assertArrayEquals(new Object[] { zero, one, two, three }, + assertArrayEquals(new Object[] { zero, one, two, three }, itemIds.toArray()); } } @@ -228,7 +234,7 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(String.class, container.getType("NAME")); + assertEquals(String.class, container.getType("NAME")); } @Test @@ -237,9 +243,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(BigDecimal.class, container.getType("ID")); + assertEquals(BigDecimal.class, container.getType("ID")); } else { - Assert.assertEquals(Integer.class, container.getType("ID")); + assertEquals(Integer.class, container.getType("ID")); } } @@ -248,14 +254,14 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertNull(container.getType("asdf")); + assertNull(container.getType("asdf")); } @Test public void size_freeform_returnsFour() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); } @Test @@ -274,7 +280,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(5, container.size()); + assertEquals(5, container.size()); } @Test @@ -283,10 +289,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(3, container.indexOfId( + assertEquals(3, container.indexOfId( new RowId(new Object[] { new BigDecimal(3 + offset) }))); } else { - Assert.assertEquals(3, container + assertEquals(3, container .indexOfId(new RowId(new Object[] { 3 + offset }))); } } @@ -301,11 +307,11 @@ public class SQLContainerTest { if (SQLTestsConstants.db == DB.ORACLE) { container.getItem( new RowId(new Object[] { new BigDecimal(1337 + offset) })); - Assert.assertEquals(1337, container.indexOfId( + assertEquals(1337, container.indexOfId( new RowId(new Object[] { new BigDecimal(1337 + offset) }))); } else { container.getItem(new RowId(new Object[] { 1337 + offset })); - Assert.assertEquals(1337, container + assertEquals(1337, container .indexOfId(new RowId(new Object[] { 1337 + offset }))); } } @@ -319,12 +325,11 @@ public class SQLContainerTest { connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( + assertEquals( new RowId(new Object[] { new BigDecimal(1337 + offset) }), itemId); } else { - Assert.assertEquals(new RowId(new Object[] { 1337 + offset }), - itemId); + assertEquals(new RowId(new Object[] { 1337 + offset }), itemId); } } @@ -382,12 +387,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(query); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 1337 + offset }).toString(), + assertEquals(new RowId(new Object[] { 1337 + offset }).toString(), itemId.toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 1337 + offset }), - itemId); + assertEquals(new RowId(new Object[] { 1337 + offset }), itemId); } } @@ -400,11 +403,10 @@ public class SQLContainerTest { connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 1338 + offset }).toString(), + assertEquals(new RowId(new Object[] { 1338 + offset }).toString(), container.nextItemId(itemId).toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 1338 + offset }), + assertEquals(new RowId(new Object[] { 1338 + offset }), container.nextItemId(itemId)); } } @@ -418,11 +420,10 @@ public class SQLContainerTest { connectionPool, "ID")); Object itemId = container.getIdByIndex(1337); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 1336 + offset }).toString(), + assertEquals(new RowId(new Object[] { 1336 + offset }).toString(), container.prevItemId(itemId).toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 1336 + offset }), + assertEquals(new RowId(new Object[] { 1336 + offset }), container.prevItemId(itemId)); } } @@ -432,11 +433,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 0 + offset }).toString(), + assertEquals(new RowId(new Object[] { 0 + offset }).toString(), container.firstItemId().toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 0 + offset }), + assertEquals(new RowId(new Object[] { 0 + offset }), container.firstItemId()); } } @@ -450,11 +450,10 @@ public class SQLContainerTest { new FreeformQuery("SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals( - new RowId(new Object[] { 4999 + offset }).toString(), + assertEquals(new RowId(new Object[] { 4999 + offset }).toString(), container.lastItemId().toString()); } else { - Assert.assertEquals(new RowId(new Object[] { 4999 + offset }), + assertEquals(new RowId(new Object[] { 4999 + offset }), container.lastItemId()); } } @@ -465,10 +464,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertTrue(container.isFirstId( + assertTrue(container.isFirstId( new RowId(new Object[] { new BigDecimal(0 + offset) }))); } else { - Assert.assertTrue(container + assertTrue(container .isFirstId(new RowId(new Object[] { 0 + offset }))); } } @@ -478,10 +477,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isFirstId( + assertFalse(container.isFirstId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse(container + assertFalse(container .isFirstId(new RowId(new Object[] { 1 + offset }))); } } @@ -491,10 +490,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertFalse(container.isLastId( + assertFalse(container.isLastId( new RowId(new Object[] { new BigDecimal(1 + offset) }))); } else { - Assert.assertFalse( + assertFalse( container.isLastId(new RowId(new Object[] { 1 + offset }))); } } @@ -504,10 +503,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertTrue(container.isLastId( + assertTrue(container.isLastId( new RowId(new Object[] { new BigDecimal(3 + offset) }))); } else { - Assert.assertTrue( + assertTrue( container.isLastId(new RowId(new Object[] { 3 + offset }))); } } @@ -520,10 +519,10 @@ public class SQLContainerTest { new FreeformQuery("SELECT * FROM people ORDER BY \"ID\" ASC", connectionPool, "ID")); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertTrue(container.isLastId( + assertTrue(container.isLastId( new RowId(new Object[] { new BigDecimal(4999 + offset) }))); } else { - Assert.assertTrue(container + assertTrue(container .isLastId(new RowId(new Object[] { 4999 + offset }))); } } @@ -532,10 +531,10 @@ public class SQLContainerTest { public void refresh_freeform_sizeShouldUpdate() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); DataGenerator.addFiveThousandPeople(connectionPool); container.refresh(); - Assert.assertEquals(5000, container.size()); + assertEquals(5000, container.size()); } @Test @@ -547,9 +546,9 @@ public class SQLContainerTest { // a NOP. SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); DataGenerator.addFiveThousandPeople(connectionPool); - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); } @Test @@ -557,16 +556,16 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); container.setAutoCommit(true); - Assert.assertTrue(container.isAutoCommit()); + assertTrue(container.isAutoCommit()); container.setAutoCommit(false); - Assert.assertFalse(container.isAutoCommit()); + assertFalse(container.isAutoCommit()); } @Test public void getPageLength_freeform_returnsDefault100() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertEquals(100, container.getPageLength()); + assertEquals(100, container.getPageLength()); } @Test @@ -574,9 +573,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); container.setPageLength(20); - Assert.assertEquals(20, container.getPageLength()); + assertEquals(20, container.getPageLength()); container.setPageLength(200); - Assert.assertEquals(200, container.getPageLength()); + assertEquals(200, container.getPageLength()); } @Test(expected = UnsupportedOperationException.class) @@ -637,7 +636,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object itemId = container.addItem(); - Assert.assertNotNull(itemId); + assertNotNull(itemId); } @Test @@ -647,7 +646,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); int size = container.size(); container.addItem(); - Assert.assertEquals(size + 1, container.size()); + assertEquals(size + 1, container.size()); } @Test @@ -658,9 +657,9 @@ public class SQLContainerTest { int size = container.size(); Object id1 = container.addItem(); Object id2 = container.addItem(); - Assert.assertEquals(size + 2, container.size()); - Assert.assertNotSame(id1, id2); - Assert.assertFalse(id1.equals(id2)); + assertEquals(size + 2, container.size()); + assertNotSame(id1, id2); + assertFalse(id1.equals(id2)); } @Test @@ -670,7 +669,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object lastId = container.lastItemId(); Object id = container.addItem(); - Assert.assertEquals(id, container.nextItemId(lastId)); + assertEquals(id, container.nextItemId(lastId)); } @Test @@ -680,8 +679,8 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object lastId = container.lastItemId(); Object id = container.addItem(); - Assert.assertEquals(id, container.lastItemId()); - Assert.assertNotSame(lastId, container.lastItemId()); + assertEquals(id, container.lastItemId()); + assertNotSame(lastId, container.lastItemId()); } @Test @@ -690,7 +689,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertEquals(4, container.indexOfId(id)); + assertEquals(4, container.indexOfId(id)); } @Test @@ -699,7 +698,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); + assertNotNull(container.getItem(id)); } @Test @@ -709,7 +708,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addContainerFilter(new Equal("NAME", "asdf")); Object id = container.addItem(); - Assert.assertNull(container.getItem(id)); + assertNull(container.getItem(id)); } @Test @@ -719,7 +718,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addContainerFilter(new Equal("NAME", "asdf")); Object id = container.addItem(); - Assert.assertNotNull(container.getItemUnfiltered(id)); + assertNotNull(container.getItemUnfiltered(id)); } @Test @@ -728,7 +727,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.getItemIds().contains(id)); + assertTrue(container.getItemIds().contains(id)); } @Test @@ -739,7 +738,7 @@ public class SQLContainerTest { Object id = container.addItem(); Item item = container.getItem(id); item.getItemProperty("NAME").setValue("asdf"); - Assert.assertEquals("asdf", + assertEquals("asdf", container.getContainerProperty(id, "NAME").getValue()); } @@ -749,7 +748,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.containsId(id)); + assertTrue(container.containsId(id)); } @Test @@ -759,7 +758,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object id1 = container.addItem(); Object id2 = container.addItem(); - Assert.assertEquals(id1, container.prevItemId(id2)); + assertEquals(id1, container.prevItemId(id2)); } @Test @@ -769,7 +768,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM GARBAGE", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertSame(id, container.firstItemId()); + assertSame(id, container.firstItemId()); } @Test @@ -779,7 +778,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM GARBAGE", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.isFirstId(id)); + assertTrue(container.isFirstId(id)); } @Test @@ -788,7 +787,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.isLastId(id)); + assertTrue(container.isLastId(id)); } @Test @@ -798,7 +797,7 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addItem(); Object id2 = container.addItem(); - Assert.assertTrue(container.isLastId(id2)); + assertTrue(container.isLastId(id2)); } @Test @@ -807,7 +806,7 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertEquals(id, container.getIdByIndex(container.size() - 1)); + assertEquals(id, container.getIdByIndex(container.size() - 1)); } @Test @@ -817,9 +816,9 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); int size = container.size(); Object id = container.firstItemId(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.firstItemId()); - Assert.assertEquals(size - 1, container.size()); + assertTrue(container.removeItem(id)); + assertNotSame(id, container.firstItemId()); + assertEquals(size - 1, container.size()); } @Test @@ -828,8 +827,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); } @Test @@ -839,7 +838,7 @@ public class SQLContainerTest { @Override public void publish(LogRecord record) { - Assert.fail("No messages should be logged"); + fail("No messages should be logged"); } @@ -858,7 +857,7 @@ public class SQLContainerTest { logger.addHandler(ensureNoLogging); try { - Assert.assertFalse(container.containsId(new Object())); + assertFalse(container.containsId(new Object())); } finally { logger.removeHandler(ensureNoLogging); } @@ -871,9 +870,9 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); int size = container.size(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); - Assert.assertEquals(size - 1, container.size()); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); + assertEquals(size - 1, container.size()); } @Test @@ -881,8 +880,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertTrue(container.removeItem(id)); + assertNull(container.getItem(id)); } @Test @@ -891,9 +890,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertNotNull(container.getItem(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNull(container.getItem(id)); + assertNotNull(container.getItem(id)); + assertTrue(container.removeItem(id)); + assertNull(container.getItem(id)); } @Test @@ -902,9 +901,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.getItemIds().contains(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertTrue(container.getItemIds().contains(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -913,9 +912,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.getItemIds().contains(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.getItemIds().contains(id)); + assertTrue(container.getItemIds().contains(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.getItemIds().contains(id)); } @Test @@ -924,9 +923,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.firstItemId(); - Assert.assertTrue(container.containsId(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertTrue(container.containsId(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); } @Test @@ -935,9 +934,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.containsId(id)); - Assert.assertTrue(container.removeItem(id)); - Assert.assertFalse(container.containsId(id)); + assertTrue(container.containsId(id)); + assertTrue(container.removeItem(id)); + assertFalse(container.containsId(id)); } @Test @@ -948,8 +947,8 @@ public class SQLContainerTest { Object first = container.getIdByIndex(0); Object second = container.getIdByIndex(1); Object third = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(third, container.nextItemId(first)); + assertTrue(container.removeItem(second)); + assertEquals(third, container.nextItemId(first)); } @Test @@ -960,8 +959,8 @@ public class SQLContainerTest { Object first = container.lastItemId(); Object second = container.addItem(); Object third = container.addItem(); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(third, container.nextItemId(first)); + assertTrue(container.removeItem(second)); + assertEquals(third, container.nextItemId(first)); } @Test @@ -972,8 +971,8 @@ public class SQLContainerTest { Object first = container.getIdByIndex(0); Object second = container.getIdByIndex(1); Object third = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(first, container.prevItemId(third)); + assertTrue(container.removeItem(second)); + assertEquals(first, container.prevItemId(third)); } @Test @@ -984,8 +983,8 @@ public class SQLContainerTest { Object first = container.lastItemId(); Object second = container.addItem(); Object third = container.addItem(); - Assert.assertTrue(container.removeItem(second)); - Assert.assertEquals(first, container.prevItemId(third)); + assertTrue(container.removeItem(second)); + assertEquals(first, container.prevItemId(third)); } @Test @@ -994,8 +993,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object first = container.firstItemId(); - Assert.assertTrue(container.removeItem(first)); - Assert.assertNotSame(first, container.firstItemId()); + assertTrue(container.removeItem(first)); + assertNotSame(first, container.firstItemId()); } @Test @@ -1006,9 +1005,9 @@ public class SQLContainerTest { "SELECT * FROM GARBAGE", connectionPool, "ID")); Object first = container.addItem(); Object second = container.addItem(); - Assert.assertSame(first, container.firstItemId()); - Assert.assertTrue(container.removeItem(first)); - Assert.assertSame(second, container.firstItemId()); + assertSame(first, container.firstItemId()); + assertTrue(container.removeItem(first)); + assertSame(second, container.firstItemId()); } @Test @@ -1017,8 +1016,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.lastItemId(); - Assert.assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertTrue(container.removeItem(last)); + assertNotSame(last, container.lastItemId()); } @Test @@ -1027,9 +1026,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); - Assert.assertTrue(container.removeItem(last)); - Assert.assertNotSame(last, container.lastItemId()); + assertSame(last, container.lastItemId()); + assertTrue(container.removeItem(last)); + assertNotSame(last, container.lastItemId()); } @Test @@ -1038,8 +1037,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object first = container.firstItemId(); - Assert.assertTrue(container.removeItem(first)); - Assert.assertFalse(container.isFirstId(first)); + assertTrue(container.removeItem(first)); + assertFalse(container.isFirstId(first)); } @Test @@ -1050,9 +1049,9 @@ public class SQLContainerTest { "SELECT * FROM GARBAGE", connectionPool, "ID")); Object first = container.addItem(); container.addItem(); - Assert.assertSame(first, container.firstItemId()); - Assert.assertTrue(container.removeItem(first)); - Assert.assertFalse(container.isFirstId(first)); + assertSame(first, container.firstItemId()); + assertTrue(container.removeItem(first)); + assertFalse(container.isFirstId(first)); } @Test @@ -1061,8 +1060,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.lastItemId(); - Assert.assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertTrue(container.removeItem(last)); + assertFalse(container.isLastId(last)); } @Test @@ -1071,9 +1070,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object last = container.addItem(); - Assert.assertSame(last, container.lastItemId()); - Assert.assertTrue(container.removeItem(last)); - Assert.assertFalse(container.isLastId(last)); + assertSame(last, container.lastItemId()); + assertTrue(container.removeItem(last)); + assertFalse(container.isLastId(last)); } @Test @@ -1082,8 +1081,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(id)); - Assert.assertEquals(-1, container.indexOfId(id)); + assertTrue(container.removeItem(id)); + assertEquals(-1, container.indexOfId(id)); } @Test @@ -1092,9 +1091,9 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.addItem(); - Assert.assertTrue(container.indexOfId(id) != -1); - Assert.assertTrue(container.removeItem(id)); - Assert.assertEquals(-1, container.indexOfId(id)); + assertTrue(container.indexOfId(id) != -1); + assertTrue(container.removeItem(id)); + assertEquals(-1, container.indexOfId(id)); } @Test @@ -1103,8 +1102,8 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Object id = container.getIdByIndex(2); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(2)); + assertTrue(container.removeItem(id)); + assertNotSame(id, container.getIdByIndex(2)); } @Test @@ -1115,16 +1114,16 @@ public class SQLContainerTest { Object id = container.addItem(); container.addItem(); int index = container.indexOfId(id); - Assert.assertTrue(container.removeItem(id)); - Assert.assertNotSame(id, container.getIdByIndex(index)); + assertTrue(container.removeItem(id)); + assertNotSame(id, container.getIdByIndex(index)); } @Test public void removeAllItems_freeform_shouldSucceed() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertTrue(container.removeAllItems()); - Assert.assertEquals(0, container.size()); + assertTrue(container.removeAllItems()); + assertEquals(0, container.size()); } @Test @@ -1134,8 +1133,8 @@ public class SQLContainerTest { "SELECT * FROM people", connectionPool, "ID")); container.addItem(); container.addItem(); - Assert.assertTrue(container.removeAllItems()); - Assert.assertEquals(0, container.size()); + assertTrue(container.removeAllItems()); + assertEquals(0, container.size()); } @SuppressWarnings("unchecked") @@ -1227,11 +1226,11 @@ public class SQLContainerTest { Object id = container.addItem(); container.getContainerProperty(id, "NAME").setValue("New Name"); container.getContainerProperty(id, "AGE").setValue(30); - Assert.assertTrue(id instanceof TemporaryRowId); - Assert.assertSame(id, container.lastItemId()); + assertTrue(id instanceof TemporaryRowId); + assertSame(id, container.lastItemId()); container.commit(); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); - Assert.assertEquals("New Name", + assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertEquals("New Name", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); EasyMock.verify(delegate); @@ -1329,15 +1328,15 @@ public class SQLContainerTest { container.getContainerProperty(id, "AGE").setValue(30); container.getContainerProperty(id2, "NAME").setValue("Larry"); container.getContainerProperty(id2, "AGE").setValue(50); - Assert.assertTrue(id2 instanceof TemporaryRowId); - Assert.assertSame(id2, container.lastItemId()); + assertTrue(id2 instanceof TemporaryRowId); + assertSame(id2, container.lastItemId()); container.commit(); Object nextToLast = container.getIdByIndex(container.size() - 2); - Assert.assertFalse(nextToLast instanceof TemporaryRowId); - Assert.assertEquals("Herbert", + assertFalse(nextToLast instanceof TemporaryRowId); + assertEquals("Herbert", container.getContainerProperty(nextToLast, "NAME").getValue()); - Assert.assertFalse(container.lastItemId() instanceof TemporaryRowId); - Assert.assertEquals("Larry", + assertFalse(container.lastItemId() instanceof TemporaryRowId); + assertEquals("Larry", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); EasyMock.verify(delegate); @@ -1414,7 +1413,7 @@ public class SQLContainerTest { Object last = container.lastItemId(); container.removeItem(last); container.commit(); - Assert.assertFalse(last.equals(container.lastItemId())); + assertFalse(last.equals(container.lastItemId())); EasyMock.verify(delegate); } @@ -1492,7 +1491,7 @@ public class SQLContainerTest { Object last = container.lastItemId(); container.getContainerProperty(last, "NAME").setValue("Donald"); container.commit(); - Assert.assertEquals("Donald", + assertEquals("Donald", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); EasyMock.verify(delegate); @@ -1506,10 +1505,10 @@ public class SQLContainerTest { int size = container.size(); Object id = container.addItem(); container.getContainerProperty(id, "NAME").setValue("foo"); - Assert.assertEquals(size + 1, container.size()); + assertEquals(size + 1, container.size()); container.rollback(); - Assert.assertEquals(size, container.size()); - Assert.assertFalse("foo".equals( + assertEquals(size, container.size()); + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), "NAME") .getValue())); } @@ -1522,10 +1521,10 @@ public class SQLContainerTest { int size = container.size(); Object last = container.lastItemId(); container.removeItem(last); - Assert.assertEquals(size - 1, container.size()); + assertEquals(size - 1, container.size()); container.rollback(); - Assert.assertEquals(size, container.size()); - Assert.assertEquals(last, container.lastItemId()); + assertEquals(size, container.size()); + assertEquals(last, container.lastItemId()); } @Test @@ -1536,7 +1535,7 @@ public class SQLContainerTest { Object last = container.lastItemId(); container.getContainerProperty(last, "NAME").setValue("foo"); container.rollback(); - Assert.assertFalse("foo".equals( + assertFalse("foo".equals( container.getContainerProperty(container.lastItemId(), "NAME") .getValue())); } @@ -1546,10 +1545,10 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); RowItem last = (RowItem) container.getItem(container.lastItemId()); container.itemChangeNotification(last); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test @@ -1605,18 +1604,18 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.removeItem(container.lastItemId()); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test public void isModified_freeformAddedItem_returnsTrue() throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.addItem(); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test @@ -1624,10 +1623,10 @@ public class SQLContainerTest { throws SQLException { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); - Assert.assertFalse(container.isModified()); + assertFalse(container.isModified()); container.getContainerProperty(container.lastItemId(), "NAME") .setValue("foo"); - Assert.assertTrue(container.isModified()); + assertTrue(container.isModified()); } @Test @@ -1636,10 +1635,10 @@ public class SQLContainerTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people", connectionPool, "ID")); Collection<?> sortableIds = container.getSortableContainerPropertyIds(); - Assert.assertTrue(sortableIds.contains("ID")); - Assert.assertTrue(sortableIds.contains("NAME")); - Assert.assertTrue(sortableIds.contains("AGE")); - Assert.assertEquals(3, sortableIds.size()); + assertTrue(sortableIds.contains("ID")); + assertTrue(sortableIds.contains("NAME")); + assertTrue(sortableIds.contains("AGE")); + assertEquals(3, sortableIds.size()); } @SuppressWarnings("unchecked") @@ -1733,19 +1732,19 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.addOrderBy(new OrderBy("NAME", true)); // Börje, Kalle, Pelle, Ville - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -1851,20 +1850,20 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.sort(new Object[] { "NAME" }, new boolean[] { true }); // Börje, Kalle, Pelle, Ville - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -1927,15 +1926,15 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.addContainerFilter(new Like("NAME", "%lle")); // Ville, Kalle, Pelle - Assert.assertEquals(3, container.size()); - Assert.assertEquals("Pelle", + assertEquals(3, container.size()); + assertEquals("Pelle", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -1998,13 +1997,13 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter("NAME", "Vi", false, false); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2068,14 +2067,14 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); // FIXME LIKE %asdf% doesn't match a string that begins with asdf container.addContainerFilter("NAME", "vi", true, true); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2139,20 +2138,20 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter("NAME", "Vi", false, false); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.removeAllContainerFilters(); - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2216,20 +2215,20 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter("NAME", "Vi", false, true); // Ville - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Ville", + assertEquals(1, container.size()); + assertEquals("Ville", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.removeContainerFilters("NAME"); - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2293,8 +2292,8 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2306,41 +2305,40 @@ public class SQLContainerTest { container.addContainerFilter(new Like("NAME", "%lle")); // Ville, Kalle, Pelle, Palle - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Ville", + assertEquals(4, container.size()); + assertEquals("Ville", container .getContainerProperty(container.getIdByIndex(0), "NAME") .getValue()); - Assert.assertEquals("Kalle", + assertEquals("Kalle", container .getContainerProperty(container.getIdByIndex(1), "NAME") .getValue()); - Assert.assertEquals("Pelle", + assertEquals("Pelle", container .getContainerProperty(container.getIdByIndex(2), "NAME") .getValue()); - Assert.assertEquals("Palle", + assertEquals("Palle", container .getContainerProperty(container.getIdByIndex(3), "NAME") .getValue()); try { container.getIdByIndex(4); - Assert.fail( - "SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); + fail("SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container"); } catch (IndexOutOfBoundsException e) { // should throw exception - item is filtered out } container.nextItemId(container.getIdByIndex(3)); - Assert.assertFalse(container.containsId(id2)); - Assert.assertFalse(container.getItemIds().contains(id2)); + assertFalse(container.containsId(id2)); + assertFalse(container.getItemIds().contains(id2)); - Assert.assertNull(container.getItem(id2)); - Assert.assertEquals(-1, container.indexOfId(id2)); + assertNull(container.getItem(id2)); + assertEquals(-1, container.indexOfId(id2)); - Assert.assertNotSame(id2, container.lastItemId()); - Assert.assertSame(id1, container.lastItemId()); + assertNotSame(id2, container.lastItemId()); + assertSame(id1, container.lastItemId()); EasyMock.verify(delegate); } @@ -2437,10 +2435,10 @@ public class SQLContainerTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals("Ville", + assertEquals("Ville", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); @@ -2452,14 +2450,14 @@ public class SQLContainerTest { container.sort(new Object[] { "NAME" }, new boolean[] { true }); // Börje, Kalle, Pelle, Ville, Wilbert, Albert - Assert.assertEquals("Börje", + assertEquals("Börje", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); - Assert.assertEquals("Wilbert", + assertEquals("Wilbert", container.getContainerProperty( container.getIdByIndex(container.size() - 2), "NAME") .getValue()); - Assert.assertEquals("Albert", + assertEquals("Albert", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java index cd8ad96e9a..f48524b338 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/TicketTest.java @@ -1,5 +1,8 @@ package com.vaadin.v7.data.util.sqlcontainer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; import java.sql.SQLException; import java.util.ArrayList; @@ -8,7 +11,6 @@ import java.util.List; import org.easymock.EasyMock; import org.easymock.IAnswer; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -105,23 +107,23 @@ public class TicketTest { query.setDelegate(delegate); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); - Assert.assertEquals("Börje", + assertEquals(4, container.size()); + assertEquals("Börje", container.getContainerProperty(container.lastItemId(), "NAME") .getValue()); container.addContainerFilter(new Equal("AGE", 18)); // Pelle - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Pelle", + assertEquals(1, container.size()); + assertEquals("Pelle", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(new BigDecimal(18), container + assertEquals(new BigDecimal(18), container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } else { - Assert.assertEquals(18, container + assertEquals(18, container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } @@ -135,21 +137,21 @@ public class TicketTest { SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(query); // Ville, Kalle, Pelle, Börje - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); container.addContainerFilter(new Equal("AGE", 18)); // Pelle - Assert.assertEquals(1, container.size()); - Assert.assertEquals("Pelle", + assertEquals(1, container.size()); + assertEquals("Pelle", container.getContainerProperty(container.firstItemId(), "NAME") .getValue()); if (SQLTestsConstants.db == DB.ORACLE) { - Assert.assertEquals(new BigDecimal(18), container + assertEquals(new BigDecimal(18), container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } else { - Assert.assertEquals(18, container + assertEquals(18, container .getContainerProperty(container.firstItemId(), "AGE") .getValue()); } @@ -167,18 +169,17 @@ public class TicketTest { // set a different name item.getItemProperty("NAME").setValue("otherName"); - Assert.assertEquals("otherName", - item.getItemProperty("NAME").getValue()); + assertEquals("otherName", item.getItemProperty("NAME").getValue()); // access the item and reset the name to its old value Item item2 = container.getItem(id); item2.getItemProperty("NAME").setValue(name); - Assert.assertEquals(name, item2.getItemProperty("NAME").getValue()); + assertEquals(name, item2.getItemProperty("NAME").getValue()); Item item3 = container.getItem(id); String name3 = (String) item3.getItemProperty("NAME").getValue(); - Assert.assertEquals(name, name3); + assertEquals(name, name3); } @Test @@ -189,7 +190,6 @@ public class TicketTest { SQLContainer container = new SQLContainer(new FreeformQuery( "SELECT * FROM people WHERE name='does_not_exist'", Arrays.asList("ID"), connectionPool)); - Assert.assertTrue("Got items while expected empty set", - container.size() == 0); + assertTrue("Got items while expected empty set", container.size() == 0); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java index f71c5b02e9..b5aaaa0841 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/UtilTest.java @@ -1,50 +1,49 @@ package com.vaadin.v7.data.util.sqlcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class UtilTest { @Test public void escapeSQL_noQuotes_returnsSameString() { - Assert.assertEquals("asdf", SQLUtil.escapeSQL("asdf")); + assertEquals("asdf", SQLUtil.escapeSQL("asdf")); } @Test public void escapeSQL_singleQuotes_returnsEscapedString() { - Assert.assertEquals("O''Brien", SQLUtil.escapeSQL("O'Brien")); + assertEquals("O''Brien", SQLUtil.escapeSQL("O'Brien")); } @Test public void escapeSQL_severalQuotes_returnsEscapedString() { - Assert.assertEquals("asdf''ghjk''qwerty", + assertEquals("asdf''ghjk''qwerty", SQLUtil.escapeSQL("asdf'ghjk'qwerty")); } @Test public void escapeSQL_doubleQuotes_returnsEscapedString() { - Assert.assertEquals("asdf\\\"foo", SQLUtil.escapeSQL("asdf\"foo")); + assertEquals("asdf\\\"foo", SQLUtil.escapeSQL("asdf\"foo")); } @Test public void escapeSQL_multipleDoubleQuotes_returnsEscapedString() { - Assert.assertEquals("asdf\\\"foo\\\"bar", - SQLUtil.escapeSQL("asdf\"foo\"bar")); + assertEquals("asdf\\\"foo\\\"bar", SQLUtil.escapeSQL("asdf\"foo\"bar")); } @Test public void escapeSQL_backslashes_returnsEscapedString() { - Assert.assertEquals("foo\\\\nbar\\\\r", - SQLUtil.escapeSQL("foo\\nbar\\r")); + assertEquals("foo\\\\nbar\\\\r", SQLUtil.escapeSQL("foo\\nbar\\r")); } @Test public void escapeSQL_x00_removesX00() { - Assert.assertEquals("foobar", SQLUtil.escapeSQL("foo\\x00bar")); + assertEquals("foobar", SQLUtil.escapeSQL("foo\\x00bar")); } @Test public void escapeSQL_x1a_removesX1a() { - Assert.assertEquals("foobar", SQLUtil.escapeSQL("foo\\x1abar")); + assertEquals("foobar", SQLUtil.escapeSQL("foo\\x1abar")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java index 167b7c1fe4..0fad0cfa20 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/J2EEConnectionPoolTest.java @@ -1,5 +1,7 @@ package com.vaadin.v7.data.util.sqlcontainer.connection; +import static org.junit.Assert.assertEquals; + import java.sql.Connection; import java.sql.SQLException; @@ -8,7 +10,6 @@ import javax.naming.NamingException; import javax.sql.DataSource; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; public class J2EEConnectionPoolTest { @@ -26,7 +27,7 @@ public class J2EEConnectionPoolTest { J2EEConnectionPool pool = new J2EEConnectionPool(ds); Connection c = pool.reserveConnection(); - Assert.assertEquals(connection, c); + assertEquals(connection, c); EasyMock.verify(connection, ds); } @@ -44,7 +45,7 @@ public class J2EEConnectionPoolTest { J2EEConnectionPool pool = new J2EEConnectionPool(ds); Connection c = pool.reserveConnection(); - Assert.assertEquals(connection, c); + assertEquals(connection, c); pool.releaseConnection(c); EasyMock.verify(connection, ds); } @@ -73,7 +74,7 @@ public class J2EEConnectionPoolTest { J2EEConnectionPool pool = new J2EEConnectionPool("testDataSource"); Connection c = pool.reserveConnection(); - Assert.assertEquals(connection, c); + assertEquals(connection, c); pool.releaseConnection(c); EasyMock.verify(context, connection, ds); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java index 2d63b0a6ab..0e2507bf8e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/connection/SimpleJDBCConnectionPoolTest.java @@ -1,10 +1,14 @@ package com.vaadin.v7.data.util.sqlcontainer.connection; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.SQLException; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -25,7 +29,7 @@ public class SimpleJDBCConnectionPoolTest { public void reserveConnection_reserveNewConnection_returnsConnection() throws SQLException { Connection conn = connectionPool.reserveConnection(); - Assert.assertNotNull(conn); + assertNotNull(conn); } @Test @@ -33,7 +37,7 @@ public class SimpleJDBCConnectionPoolTest { throws SQLException { Connection conn = connectionPool.reserveConnection(); connectionPool.releaseConnection(conn); - Assert.assertFalse(conn.isClosed()); + assertFalse(conn.isClosed()); } @Test(expected = SQLException.class) @@ -44,13 +48,11 @@ public class SimpleJDBCConnectionPoolTest { connectionPool.reserveConnection(); } catch (SQLException e) { e.printStackTrace(); - Assert.fail( - "Exception before all connections used! " + e.getMessage()); + fail("Exception before all connections used! " + e.getMessage()); } connectionPool.reserveConnection(); - Assert.fail( - "Reserving connection didn't fail even though no connections are available!"); + fail("Reserving connection didn't fail even though no connections are available!"); } @Test @@ -60,12 +62,11 @@ public class SimpleJDBCConnectionPoolTest { connectionPool.reserveConnection(); } catch (SQLException e) { e.printStackTrace(); - Assert.fail( - "Exception before all connections used! " + e.getMessage()); + fail("Exception before all connections used! " + e.getMessage()); } Connection conn = connectionPool.reserveConnection(); - Assert.assertNotNull(conn); + assertNotNull(conn); } @Test @@ -77,8 +78,7 @@ public class SimpleJDBCConnectionPoolTest { conn2 = connectionPool.reserveConnection(); } catch (SQLException e) { e.printStackTrace(); - Assert.fail( - "Exception before all connections used! " + e.getMessage()); + fail("Exception before all connections used! " + e.getMessage()); } connectionPool.releaseConnection(conn2); @@ -128,7 +128,7 @@ public class SimpleJDBCConnectionPoolTest { SQLTestsConstants.dbDriver, SQLTestsConstants.dbURL, SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 0, 2); Connection c = connectionPool.reserveConnection(); - Assert.assertNotNull(c); + assertNotNull(c); } @Test @@ -167,8 +167,8 @@ public class SimpleJDBCConnectionPoolTest { // not empty but only after cleanup of the real pool has been done } - Assert.assertTrue(c1.isClosed()); - Assert.assertTrue(c2.isClosed()); + assertTrue(c1.isClosed()); + assertTrue(c2.isClosed()); } @Test @@ -178,8 +178,8 @@ public class SimpleJDBCConnectionPoolTest { connectionPool.releaseConnection(c1); connectionPool.releaseConnection(c2); connectionPool.destroy(); - Assert.assertTrue(c1.isClosed()); - Assert.assertTrue(c2.isClosed()); + assertTrue(c1.isClosed()); + assertTrue(c2.isClosed()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java index 59e486b686..bb73a66cac 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/BetweenTest.java @@ -1,7 +1,10 @@ package com.vaadin.v7.data.util.sqlcontainer.filters; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Item; @@ -27,156 +30,152 @@ public class BetweenTest { public void passesFilter_valueIsInRange_shouldBeTrue() { Item item = itemWithPropertyValue("foo", 15); Between between = new Between("foo", 1, 30); - Assert.assertTrue(between.passesFilter("foo", item)); + assertTrue(between.passesFilter("foo", item)); } @Test public void passesFilter_valueIsOutOfRange_shouldBeFalse() { Item item = itemWithPropertyValue("foo", 15); Between between = new Between("foo", 0, 2); - Assert.assertFalse(between.passesFilter("foo", item)); + assertFalse(between.passesFilter("foo", item)); } @Test public void passesFilter_valueNotComparable_shouldBeFalse() { Item item = itemWithPropertyValue("foo", new Object()); Between between = new Between("foo", 0, 2); - Assert.assertFalse(between.passesFilter("foo", item)); + assertFalse(between.passesFilter("foo", item)); } @Test public void appliesToProperty_differentProperties_shoudlBeFalse() { Between between = new Between("foo", 0, 2); - Assert.assertFalse(between.appliesToProperty("bar")); + assertFalse(between.appliesToProperty("bar")); } @Test public void appliesToProperty_sameProperties_shouldBeTrue() { Between between = new Between("foo", 0, 2); - Assert.assertTrue(between.appliesToProperty("foo")); + assertTrue(between.appliesToProperty("foo")); } @Test public void hashCode_equalInstances_shouldBeEqual() { Between b1 = new Between("foo", 0, 2); Between b2 = new Between("foo", 0, 2); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void equals_differentObjects_shouldBeFalse() { Between b1 = new Between("foo", 0, 2); Object obj = new Object(); - Assert.assertFalse(b1.equals(obj)); + assertFalse(b1.equals(obj)); } @Test public void equals_sameInstance_shouldBeTrue() { Between b1 = new Between("foo", 0, 2); Between b2 = b1; - Assert.assertTrue(b1.equals(b2)); + assertTrue(b1.equals(b2)); } @Test public void equals_equalInstances_shouldBeTrue() { Between b1 = new Between("foo", 0, 2); Between b2 = new Between("foo", 0, 2); - Assert.assertTrue(b1.equals(b2)); + assertTrue(b1.equals(b2)); } @Test public void equals_equalInstances2_shouldBeTrue() { Between b1 = new Between(null, null, null); Between b2 = new Between(null, null, null); - Assert.assertTrue(b1.equals(b2)); + assertTrue(b1.equals(b2)); } @Test public void equals_secondValueDiffers_shouldBeFalse() { Between b1 = new Between("foo", 0, 1); Between b2 = new Between("foo", 0, 2); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void equals_firstAndSecondValueDiffers_shouldBeFalse() { Between b1 = new Between("foo", 0, null); Between b2 = new Between("foo", 1, 2); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void equals_propertyAndFirstAndSecondValueDiffers_shouldBeFalse() { Between b1 = new Between("foo", null, 1); Between b2 = new Between("bar", 1, 2); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void equals_propertiesDiffer_shouldBeFalse() { Between b1 = new Between(null, 0, 1); Between b2 = new Between("bar", 0, 1); - Assert.assertFalse(b1.equals(b2)); + assertFalse(b1.equals(b2)); } @Test public void hashCode_nullStartValue_shouldBeEqual() { Between b1 = new Between("foo", null, 2); Between b2 = new Between("foo", null, 2); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void hashCode_nullEndValue_shouldBeEqual() { Between b1 = new Between("foo", 0, null); Between b2 = new Between("foo", 0, null); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void hashCode_nullPropertyId_shouldBeEqual() { Between b1 = new Between(null, 0, 2); Between b2 = new Between(null, 0, 2); - Assert.assertEquals(b1.hashCode(), b2.hashCode()); + assertEquals(b1.hashCode(), b2.hashCode()); } @Test public void passesFilter_nullValue_filterIsPassed() { String id = "id"; Between between = new Between(id, null, null); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, null))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, null))); } @Test public void passesFilter_nullStartValue_filterIsPassed() { String id = "id"; Between between = new Between(id, null, 2); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, 1))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, 1))); } @Test public void passesFilter_nullEndValue_filterIsPassed() { String id = "id"; Between between = new Between(id, 0, null); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, 1))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, 1))); } @Test public void passesFilter_nullStartValueAndEndValue_filterIsPassed() { String id = "id"; Between between = new Between(id, null, null); - Assert.assertTrue( - between.passesFilter(id, itemWithPropertyValue(id, 1))); + assertTrue(between.passesFilter(id, itemWithPropertyValue(id, 1))); } @Test public void passesFilter_nullStartValueAndEndValueAndValueIsNotComparable_filterIsNotPassed() { String id = "id"; Between between = new Between(id, null, null); - Assert.assertFalse(between.passesFilter(id, + assertFalse(between.passesFilter(id, itemWithPropertyValue(id, new Object()))); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java index 9739144b7f..897944a912 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/CompareTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.data.util.sqlcontainer.filters; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.filter.Compare; @@ -26,19 +28,19 @@ public class CompareTest { public void testEquals() { Compare c1 = new Compare.Equal("prop1", "val1"); Compare c2 = new Compare.Equal("prop1", "val1"); - Assert.assertTrue(c1.equals(c2)); + assertTrue(c1.equals(c2)); } @Test public void testDifferentTypeEquals() { Compare c1 = new Compare.Equal("prop1", "val1"); Compare c2 = new Compare.Greater("prop1", "val1"); - Assert.assertFalse(c1.equals(c2)); + assertFalse(c1.equals(c2)); } @Test public void testEqualsNull() { Compare c1 = new Compare.Equal("prop1", "val1"); - Assert.assertFalse(c1.equals(null)); + assertFalse(c1.equals(null)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java index e09705e6f3..71906256c2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/filters/LikeTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.data.util.sqlcontainer.filters; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.Item; @@ -17,7 +20,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<Integer>(5)); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -27,7 +30,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdfooghij")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -38,7 +41,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdfOOghij")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -48,7 +51,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdfOOghij")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -58,7 +61,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("asdbarghij")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -68,7 +71,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("foo")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -78,7 +81,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("fo")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -88,7 +91,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("foobar")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -98,7 +101,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("barfoo")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -108,7 +111,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("barfoo")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test @@ -118,7 +121,7 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("foobar")); - Assert.assertFalse(like.passesFilter("id", item)); + assertFalse(like.passesFilter("id", item)); } @Test @@ -128,102 +131,102 @@ public class LikeTest { Item item = new PropertysetItem(); item.addItemProperty("test", new ObjectProperty<String>("fooASDFbar")); - Assert.assertTrue(like.passesFilter("id", item)); + assertTrue(like.passesFilter("id", item)); } @Test public void appliesToProperty_valueIsProperty_shouldBeTrue() { Like like = new Like("test", "%foo"); - Assert.assertTrue(like.appliesToProperty("test")); + assertTrue(like.appliesToProperty("test")); } @Test public void appliesToProperty_valueIsNotProperty_shouldBeFalse() { Like like = new Like("test", "%foo"); - Assert.assertFalse(like.appliesToProperty("bar")); + assertFalse(like.appliesToProperty("bar")); } @Test public void equals_sameInstances_shouldBeTrue() { Like like1 = new Like("test", "%foo"); Like like2 = like1; - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_twoEqualInstances_shouldBeTrue() { Like like1 = new Like("test", "foo"); Like like2 = new Like("test", "foo"); - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_differentValues_shouldBeFalse() { Like like1 = new Like("test", "foo"); Like like2 = new Like("test", "bar"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_differentProperties_shouldBeFalse() { Like like1 = new Like("foo", "test"); Like like2 = new Like("bar", "test"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_differentPropertiesAndValues_shouldBeFalse() { Like like1 = new Like("foo", "bar"); Like like2 = new Like("baz", "zomg"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_differentClasses_shouldBeFalse() { Like like1 = new Like("foo", "bar"); Object obj = new Object(); - Assert.assertFalse(like1.equals(obj)); + assertFalse(like1.equals(obj)); } @Test public void equals_bothHaveNullProperties_shouldBeTrue() { Like like1 = new Like(null, "foo"); Like like2 = new Like(null, "foo"); - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_bothHaveNullValues_shouldBeTrue() { Like like1 = new Like("foo", null); Like like2 = new Like("foo", null); - Assert.assertTrue(like1.equals(like2)); + assertTrue(like1.equals(like2)); } @Test public void equals_onePropertyIsNull_shouldBeFalse() { Like like1 = new Like(null, "bar"); Like like2 = new Like("foo", "baz"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void equals_oneValueIsNull_shouldBeFalse() { Like like1 = new Like("foo", null); Like like2 = new Like("baz", "bar"); - Assert.assertFalse(like1.equals(like2)); + assertFalse(like1.equals(like2)); } @Test public void hashCode_equalInstances_shouldBeEqual() { Like like1 = new Like("test", "foo"); Like like2 = new Like("test", "foo"); - Assert.assertEquals(like1.hashCode(), like2.hashCode()); + assertEquals(like1.hashCode(), like2.hashCode()); } @Test public void hashCode_differentPropertiesAndValues_shouldNotEqual() { Like like1 = new Like("foo", "bar"); Like like2 = new Like("baz", "zomg"); - Assert.assertTrue(like1.hashCode() != like2.hashCode()); + assertTrue(like1.hashCode() != like2.hashCode()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java index 078363af19..5bf587dd09 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java @@ -1,12 +1,15 @@ package com.vaadin.v7.data.util.sqlcontainer.generator; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -39,7 +42,7 @@ public class SQLGeneratorsTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -57,7 +60,7 @@ public class SQLGeneratorsTest { SQLGenerator sg = new DefaultSQLGenerator(); StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 0, 0, null); - Assert.assertEquals(sh.getQueryString(), "SELECT * FROM TABLE"); + assertEquals(sh.getQueryString(), "SELECT * FROM TABLE"); } @Test @@ -65,7 +68,7 @@ public class SQLGeneratorsTest { SQLGenerator sg = new DefaultSQLGenerator(); StatementHelper sh = sg.generateSelectQuery("TABLE", null, null, 4, 8, "COL1, COL2, COL3"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT COL1, COL2, COL3 FROM TABLE LIMIT 8 OFFSET 4"); } @@ -79,7 +82,7 @@ public class SQLGeneratorsTest { f.add(new Like("name", "%lle")); List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM TABLE WHERE \"name\" LIKE ? ORDER BY \"name\" ASC"); } @@ -91,7 +94,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null); // TODO - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM TABLE WHERE (\"name\" LIKE ? " + "OR \"name\" LIKE ?) ORDER BY \"name\" ASC"); } @@ -115,7 +118,7 @@ public class SQLGeneratorsTest { StatementHelper sh = sg.generateDeleteQuery("people", query.getPrimaryKeyColumns(), null, (RowItem) container .getItem(container.getItemIds().iterator().next())); - Assert.assertEquals("DELETE FROM people WHERE \"ID\" = ?", + assertEquals("DELETE FROM people WHERE \"ID\" = ?", sh.getQueryString()); } @@ -139,7 +142,7 @@ public class SQLGeneratorsTest { ri.getItemProperty("NAME").setValue("Viljami"); StatementHelper sh = sg.generateUpdateQuery("people", ri); - Assert.assertTrue( + assertTrue( "UPDATE people SET \"NAME\" = ?, \"AGE\" = ? WHERE \"ID\" = ?" .equals(sh.getQueryString()) || "UPDATE people SET \"AGE\" = ?, \"NAME\" = ? WHERE \"ID\" = ?" @@ -166,7 +169,7 @@ public class SQLGeneratorsTest { StatementHelper sh = sg.generateInsertQuery("people", ri); - Assert.assertTrue("INSERT INTO people (\"NAME\", \"AGE\") VALUES (?, ?)" + assertTrue("INSERT INTO people (\"NAME\", \"AGE\") VALUES (?, ?)" .equals(sh.getQueryString()) || "INSERT INTO people (\"AGE\", \"NAME\") VALUES (?, ?)" .equals(sh.getQueryString())); @@ -181,10 +184,9 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals( - "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM" - + " (SELECT NAME, ID FROM TABLE WHERE \"name\" LIKE ?" - + " ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12", + assertEquals("SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM" + + " (SELECT NAME, ID FROM TABLE WHERE \"name\" LIKE ?" + + " ORDER BY \"name\" ASC) x) WHERE \"rownum\" BETWEEN 5 AND 12", sh.getQueryString()); } @@ -197,7 +199,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM (SELECT row_number() OVER " + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID " + "FROM TABLE WHERE \"name\" LIKE ?) " @@ -213,7 +215,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM (SELECT x.*, ROWNUM AS \"rownum\" FROM" + " (SELECT NAME, ID FROM TABLE WHERE (\"name\" LIKE ?" + " OR \"name\" LIKE ?) " @@ -229,7 +231,7 @@ public class SQLGeneratorsTest { List<OrderBy> ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 4, 8, "NAME, ID"); - Assert.assertEquals(sh.getQueryString(), + assertEquals(sh.getQueryString(), "SELECT * FROM (SELECT row_number() OVER " + "( ORDER BY \"name\" ASC) AS rownum, NAME, ID " + "FROM TABLE WHERE (\"name\" LIKE ? " diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java index 1c6559dc73..aa9f61ddeb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/StatementHelperTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.data.util.sqlcontainer.generator; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.PreparedStatement; import java.sql.SQLException; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.sqlcontainer.query.generator.StatementHelper; @@ -39,12 +41,12 @@ public class StatementHelperTest { // should throw SQLException, not NPE try { helper.setParameterValuesToStatement(statement); - Assert.fail("Expected SQLExecption for unsupported type"); + fail("Expected SQLExecption for unsupported type"); } catch (SQLException e) { // Exception should contain info about which parameter and the type // which was unsupported - Assert.assertTrue(e.getMessage().contains("parameter 0")); - Assert.assertTrue( + assertTrue(e.getMessage().contains("parameter 0")); + assertTrue( e.getMessage().contains(StatementHelper.class.getName())); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java index ea65310fc4..7ace7ae808 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQueryTest.java @@ -1,5 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer.query; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -10,7 +17,6 @@ import java.util.List; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -39,7 +45,7 @@ public class FreeformQueryTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); @@ -56,10 +62,10 @@ public class FreeformQueryTest { public void construction_legalParameters_shouldSucceed() { FreeformQuery ffQuery = new FreeformQuery("SELECT * FROM foo", Arrays.asList("ID"), connectionPool); - Assert.assertArrayEquals(new Object[] { "ID" }, + assertArrayEquals(new Object[] { "ID" }, ffQuery.getPrimaryKeyColumns().toArray()); - Assert.assertEquals("SELECT * FROM foo", ffQuery.getQueryString()); + assertEquals("SELECT * FROM foo", ffQuery.getQueryString()); } @Test(expected = IllegalArgumentException.class) @@ -97,7 +103,7 @@ public class FreeformQueryTest { public void getCount_simpleQuery_returnsFour() throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertEquals(4, query.getCount()); + assertEquals(4, query.getCount()); } @Test(expected = SQLException.class) @@ -130,7 +136,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertEquals(6, query.getCount()); + assertEquals(6, query.getCount()); } @Test @@ -138,7 +144,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery( "SELECT * FROM people WHERE \"NAME\" LIKE '%lle'", connectionPool, "ID"); - Assert.assertEquals(3, query.getCount()); + assertEquals(3, query.getCount()); } @Test @@ -149,7 +155,7 @@ public class FreeformQueryTest { query.getCount(); query.getCount(); Connection c = connectionPool.reserveConnection(); - Assert.assertNotNull(c); + assertNotNull(c); // Cleanup to make test connection pool happy connectionPool.releaseConnection(c); } @@ -165,7 +171,7 @@ public class FreeformQueryTest { "SELECT COUNT(*) FROM people WHERE \"NAME\" LIKE '%lle'"); EasyMock.replay(delegate); query.setDelegate(delegate); - Assert.assertEquals(3, query.getCount()); + assertEquals(3, query.getCount()); EasyMock.verify(delegate); } @@ -181,7 +187,7 @@ public class FreeformQueryTest { .andReturn("SELECT COUNT(*) FROM GARBAGE"); EasyMock.replay(delegate); query.setDelegate(delegate); - Assert.assertEquals(0, query.getCount()); + assertEquals(0, query.getCount()); EasyMock.verify(delegate); } @@ -194,23 +200,23 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -223,19 +229,19 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -249,9 +255,9 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(0, 0); for (int i = 0; i < 5000; i++) { - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); } - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -290,7 +296,7 @@ public class FreeformQueryTest { try { query.storeRow(new RowItem(container, new RowId(new Object[] { 1 }), null)); - Assert.fail("storeRow should fail when there is no delegate"); + fail("storeRow should fail when there is no delegate"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -307,7 +313,7 @@ public class FreeformQueryTest { try { query.removeRow(new RowItem(container, new RowId(new Object[] { 1 }), null)); - Assert.fail("removeRow should fail when there is no delgate"); + fail("removeRow should fail when there is no delgate"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -349,7 +355,7 @@ public class FreeformQueryTest { throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); } @Test @@ -357,7 +363,7 @@ public class FreeformQueryTest { throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertFalse(query.containsRowWithKey(1337)); + assertFalse(query.containsRowWithKey(1337)); } // (expected = SQLException.class) @@ -366,7 +372,7 @@ public class FreeformQueryTest { throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); - Assert.assertFalse(query.containsRowWithKey(38796)); + assertFalse(query.containsRowWithKey(38796)); } @Test @@ -375,7 +381,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery( "SELECT * FROM people WHERE \"NAME\" LIKE '%lle'", Arrays.asList("ID"), connectionPool); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); } @Test @@ -384,7 +390,7 @@ public class FreeformQueryTest { FreeformQuery query = new FreeformQuery( "select * from people where \"NAME\" like '%lle'", Arrays.asList("ID"), connectionPool); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); } @Test @@ -413,7 +419,7 @@ public class FreeformQueryTest { FreeformQueryDelegate delegate = EasyMock .createMock(FreeformQueryDelegate.class); query.setDelegate(delegate); - Assert.assertEquals(delegate, query.getDelegate()); + assertEquals(delegate, query.getDelegate()); } @Test @@ -474,15 +480,15 @@ public class FreeformQueryTest { if (SQLTestsConstants.db == DB.MSSQL) { rsoffset++; } - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1 + rsoffset)); - Assert.assertEquals("Ville", rs.getString(2 + rsoffset)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1 + rsoffset)); + assertEquals("Ville", rs.getString(2 + rsoffset)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1 + rsoffset)); - Assert.assertEquals("Kalle", rs.getString(2 + rsoffset)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1 + rsoffset)); + assertEquals("Kalle", rs.getString(2 + rsoffset)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); EasyMock.verify(delegate); query.commit(); @@ -515,10 +521,10 @@ public class FreeformQueryTest { query.beginTransaction(); ResultSet rs = query.getResults(200, 100); for (int i = 0; i < 100; i++) { - Assert.assertTrue(rs.next()); - Assert.assertEquals(200 + i + offset, rs.getInt("ID")); + assertTrue(rs.next()); + assertEquals(200 + i + offset, rs.getInt("ID")); } - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); query.commit(); } @@ -646,8 +652,7 @@ public class FreeformQueryTest { null); try { query.storeRow(row); - Assert.fail( - "storeRow should fail when delgate does not implement storeRow"); + fail("storeRow should fail when delgate does not implement storeRow"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -695,8 +700,7 @@ public class FreeformQueryTest { null); try { query.removeRow(row); - Assert.fail( - "removeRow should fail when delegate does not implement removeRow"); + fail("removeRow should fail when delegate does not implement removeRow"); } catch (UnsupportedOperationException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -727,8 +731,7 @@ public class FreeformQueryTest { query.beginTransaction(); try { query.beginTransaction(); - Assert.fail( - "Should throw exception when starting a transaction while already in a transaction"); + fail("Should throw exception when starting a transaction while already in a transaction"); } catch (IllegalStateException e) { // Cleanup to make test connection pool happy query.rollback(); @@ -882,7 +885,7 @@ public class FreeformQueryTest { query.setDelegate(delegate); // The id (key) used should be 1337 as above, for the call with key = 1 - Assert.assertFalse(query.containsRowWithKey(1)); + assertFalse(query.containsRowWithKey(1)); EasyMock.verify(delegate); } @@ -978,7 +981,7 @@ public class FreeformQueryTest { EasyMock.replay(delegate); query.setDelegate(delegate); - Assert.assertTrue(query.containsRowWithKey(1)); + assertTrue(query.containsRowWithKey(1)); EasyMock.verify(delegate); } @@ -990,7 +993,7 @@ public class FreeformQueryTest { "p1.ID"); query.setDelegate(new NonMatchingStatementDelegateWithGroupBy()); - Assert.assertEquals(0, query.getCount()); + assertEquals(0, query.getCount()); } @Test @@ -1000,6 +1003,6 @@ public class FreeformQueryTest { "p1.ID"); query.setDelegate(new NonMatchingDelegateWithGroupBy()); - Assert.assertEquals(0, query.getCount()); + assertEquals(0, query.getCount()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java index b01af9b9ad..164a55b9c5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/QueryBuilderTest.java @@ -1,10 +1,11 @@ package com.vaadin.v7.data.util.sqlcontainer.query; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Container.Filter; @@ -42,7 +43,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_equals() { StatementHelper sh = mockedStatementHelper("Fido"); Equal f = new Equal("NAME", "Fido"); - Assert.assertEquals("\"NAME\" = ?", + assertEquals("\"NAME\" = ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -51,7 +52,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_greater() { StatementHelper sh = mockedStatementHelper(18); Greater f = new Greater("AGE", 18); - Assert.assertEquals("\"AGE\" > ?", + assertEquals("\"AGE\" > ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -60,7 +61,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_less() { StatementHelper sh = mockedStatementHelper(65); Less f = new Less("AGE", 65); - Assert.assertEquals("\"AGE\" < ?", + assertEquals("\"AGE\" < ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -69,7 +70,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_greaterOrEqual() { StatementHelper sh = mockedStatementHelper(18); GreaterOrEqual f = new GreaterOrEqual("AGE", 18); - Assert.assertEquals("\"AGE\" >= ?", + assertEquals("\"AGE\" >= ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -78,7 +79,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_lessOrEqual() { StatementHelper sh = mockedStatementHelper(65); LessOrEqual f = new LessOrEqual("AGE", 65); - Assert.assertEquals("\"AGE\" <= ?", + assertEquals("\"AGE\" <= ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -88,7 +89,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("Vi%"); SimpleStringFilter f = new SimpleStringFilter("NAME", "Vi", false, true); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -98,7 +99,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%Vi%"); SimpleStringFilter f = new SimpleStringFilter("NAME", "Vi", false, false); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -108,7 +109,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%VI%"); SimpleStringFilter f = new SimpleStringFilter("NAME", "Vi", true, false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -117,7 +118,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_startsWith() { StatementHelper sh = mockedStatementHelper("Vi%"); Like f = new Like("NAME", "Vi%"); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -126,7 +127,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_startsWithNumber() { StatementHelper sh = mockedStatementHelper("1%"); Like f = new Like("AGE", "1%"); - Assert.assertEquals("\"AGE\" LIKE ?", + assertEquals("\"AGE\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -135,7 +136,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_endsWith() { StatementHelper sh = mockedStatementHelper("%lle"); Like f = new Like("NAME", "%lle"); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -144,7 +145,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_contains() { StatementHelper sh = mockedStatementHelper("%ill%"); Like f = new Like("NAME", "%ill%"); - Assert.assertEquals("\"NAME\" LIKE ?", + assertEquals("\"NAME\" LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -153,7 +154,7 @@ public class QueryBuilderTest { public void getWhereStringForFilter_between() { StatementHelper sh = mockedStatementHelper(18, 65); Between f = new Between("AGE", 18, 65); - Assert.assertEquals("\"AGE\" BETWEEN ? AND ?", + assertEquals("\"AGE\" BETWEEN ? AND ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -163,7 +164,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("FIDO"); Like f = new Like("NAME", "Fido"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -173,7 +174,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("VI%"); Like f = new Like("NAME", "Vi%"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -183,7 +184,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%LLE"); Like f = new Like("NAME", "%lle"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -193,7 +194,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%ILL%"); Like f = new Like("NAME", "%ill%"); f.setCaseSensitive(false); - Assert.assertEquals("UPPER(\"NAME\") LIKE ?", + assertEquals("UPPER(\"NAME\") LIKE ?", QueryBuilder.getWhereStringForFilter(f, sh)); EasyMock.verify(sh); } @@ -204,7 +205,7 @@ public class QueryBuilderTest { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Like("NAME", "%lle")); filters.add(new Greater("AGE", 18)); - Assert.assertEquals(" WHERE \"NAME\" LIKE ? AND \"AGE\" > ?", + assertEquals(" WHERE \"NAME\" LIKE ? AND \"AGE\" > ?", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -214,7 +215,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%lle", 18); List<Filter> filters = new ArrayList<Filter>(); filters.add(new And(new Like("NAME", "%lle"), new Greater("AGE", 18))); - Assert.assertEquals(" WHERE (\"NAME\" LIKE ? AND \"AGE\" > ?)", + assertEquals(" WHERE (\"NAME\" LIKE ? AND \"AGE\" > ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -224,7 +225,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper("%lle", 18); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Or(new Like("NAME", "%lle"), new Greater("AGE", 18))); - Assert.assertEquals(" WHERE (\"NAME\" LIKE ? OR \"AGE\" > ?)", + assertEquals(" WHERE (\"NAME\" LIKE ? OR \"AGE\" > ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -237,7 +238,7 @@ public class QueryBuilderTest { new And(new Like("NAME", "%lle"), new Or(new Less("AGE", 18), new Greater("AGE", 65))), new Equal("NAME", "Pelle"))); - Assert.assertEquals( + assertEquals( " WHERE ((\"NAME\" LIKE ? AND (\"AGE\" < ? OR \"AGE\" > ?)) OR \"NAME\" = ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); @@ -253,7 +254,7 @@ public class QueryBuilderTest { new Or(new Less("AGE", 18), new Greater("AGE", 65))), new Equal("NAME", "Pelle"))); filters.add(new Equal("LASTNAME", "Virtanen")); - Assert.assertEquals( + assertEquals( " WHERE ((\"NAME\" LIKE ? AND (\"AGE\" < ? OR \"AGE\" > ?)) OR \"NAME\" = ?) AND \"LASTNAME\" = ?", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); @@ -262,7 +263,7 @@ public class QueryBuilderTest { @Test public void getWhereStringForFilters_emptyList_shouldReturnEmptyString() { List<Filter> filters = new ArrayList<Filter>(); - Assert.assertEquals("", QueryBuilder.getWhereStringForFilters(filters, + assertEquals("", QueryBuilder.getWhereStringForFilters(filters, new StatementHelper())); } @@ -271,7 +272,7 @@ public class QueryBuilderTest { StatementHelper sh = mockedStatementHelper(18); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Not(new Equal("AGE", 18))); - Assert.assertEquals(" WHERE NOT \"AGE\" = ?", + assertEquals(" WHERE NOT \"AGE\" = ?", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -282,7 +283,7 @@ public class QueryBuilderTest { List<Filter> filters = new ArrayList<Filter>(); filters.add( new Not(new Or(new Equal("AGE", 65), new Equal("AGE", 18)))); - Assert.assertEquals(" WHERE NOT (\"AGE\" = ? OR \"AGE\" = ?)", + assertEquals(" WHERE NOT (\"AGE\" = ? OR \"AGE\" = ?)", QueryBuilder.getWhereStringForFilters(filters, sh)); EasyMock.verify(sh); } @@ -291,7 +292,7 @@ public class QueryBuilderTest { public void getWhereStringForFilters_isNull() { List<Filter> filters = new ArrayList<Filter>(); filters.add(new IsNull("NAME")); - Assert.assertEquals(" WHERE \"NAME\" IS NULL", QueryBuilder + assertEquals(" WHERE \"NAME\" IS NULL", QueryBuilder .getWhereStringForFilters(filters, new StatementHelper())); } @@ -299,7 +300,7 @@ public class QueryBuilderTest { public void getWhereStringForFilters_isNotNull() { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Not(new IsNull("NAME"))); - Assert.assertEquals(" WHERE \"NAME\" IS NOT NULL", QueryBuilder + assertEquals(" WHERE \"NAME\" IS NOT NULL", QueryBuilder .getWhereStringForFilters(filters, new StatementHelper())); } @@ -308,7 +309,7 @@ public class QueryBuilderTest { QueryBuilder.setStringDecorator(new StringDecorator("[", "]")); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Not(new IsNull("NAME"))); - Assert.assertEquals(" WHERE [NAME] IS NOT NULL", QueryBuilder + assertEquals(" WHERE [NAME] IS NOT NULL", QueryBuilder .getWhereStringForFilters(filters, new StatementHelper())); // Reset the default string decorator QueryBuilder.setStringDecorator(new StringDecorator("\"", "\"")); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java index 23dec7cbf6..bc3d0ac518 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/query/TableQueryTest.java @@ -1,5 +1,12 @@ package com.vaadin.v7.data.util.sqlcontainer.query; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -10,7 +17,6 @@ import java.util.Arrays; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -38,7 +44,7 @@ public class TableQueryTest { SQLTestsConstants.dbUser, SQLTestsConstants.dbPwd, 2, 2); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(e.getMessage()); + fail(e.getMessage()); } DataGenerator.addPeopleToDatabase(connectionPool); } @@ -57,22 +63,22 @@ public class TableQueryTest { public void construction_legalParameters_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, new DefaultSQLGenerator()); - Assert.assertArrayEquals(new Object[] { "ID" }, + assertArrayEquals(new Object[] { "ID" }, tQuery.getPrimaryKeyColumns().toArray()); boolean correctTableName = "people" .equalsIgnoreCase(tQuery.getTableName()); - Assert.assertTrue(correctTableName); + assertTrue(correctTableName); } @Test public void construction_legalParameters_defaultGenerator_shouldSucceed() { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertArrayEquals(new Object[] { "ID" }, + assertArrayEquals(new Object[] { "ID" }, tQuery.getPrimaryKeyColumns().toArray()); boolean correctTableName = "people" .equalsIgnoreCase(tQuery.getTableName()); - Assert.assertTrue(correctTableName); + assertTrue(correctTableName); } @Test(expected = IllegalArgumentException.class) @@ -102,7 +108,7 @@ public class TableQueryTest { public void getCount_simpleQuery_returnsFour() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertEquals(4, tQuery.getCount()); + assertEquals(4, tQuery.getCount()); } @Test @@ -127,7 +133,7 @@ public class TableQueryTest { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertEquals(6, tQuery.getCount()); + assertEquals(6, tQuery.getCount()); } @Test @@ -137,7 +143,7 @@ public class TableQueryTest { tQuery.getCount(); tQuery.getCount(); Connection c = connectionPool.reserveConnection(); - Assert.assertNotNull(c); + assertNotNull(c); connectionPool.releaseConnection(c); } @@ -152,23 +158,23 @@ public class TableQueryTest { tQuery.beginTransaction(); ResultSet rs = tQuery.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -183,9 +189,9 @@ public class TableQueryTest { tQuery.beginTransaction(); ResultSet rs = tQuery.getResults(0, 0); for (int i = 0; i < 5000; i++) { - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); } - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -201,8 +207,7 @@ public class TableQueryTest { tQuery.beginTransaction(); try { tQuery.beginTransaction(); - Assert.fail( - "Should throw exception when starting a transaction while already in a transaction"); + fail("Should throw exception when starting a transaction while already in a transaction"); } catch (IllegalStateException e) { // Cleanup to make test connection pool happy tQuery.rollback(); @@ -247,7 +252,7 @@ public class TableQueryTest { throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertTrue(tQuery.containsRowWithKey(1)); + assertTrue(tQuery.containsRowWithKey(1)); } @Test @@ -256,7 +261,7 @@ public class TableQueryTest { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertFalse(tQuery.containsRowWithKey(1337)); + assertFalse(tQuery.containsRowWithKey(1337)); } @Test @@ -270,7 +275,7 @@ public class TableQueryTest { } catch (SQLException se) { return; } - Assert.assertFalse(b); + assertFalse(b); } @Test @@ -304,7 +309,7 @@ public class TableQueryTest { List<Filter> filters = new ArrayList<Filter>(); filters.add(new Like("NAME", "%lle")); tQuery.setFilters(filters); - Assert.assertEquals(3, tQuery.getCount()); + assertEquals(3, tQuery.getCount()); } @Test @@ -320,23 +325,23 @@ public class TableQueryTest { ResultSet rs; rs = tQuery.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -353,23 +358,23 @@ public class TableQueryTest { ResultSet rs; rs = tQuery.getResults(0, 0); - Assert.assertTrue(rs.next()); - Assert.assertEquals(0 + offset, rs.getInt(1)); - Assert.assertEquals("Ville", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(0 + offset, rs.getInt(1)); + assertEquals("Ville", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(2 + offset, rs.getInt(1)); - Assert.assertEquals("Pelle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(2 + offset, rs.getInt(1)); + assertEquals("Pelle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(1 + offset, rs.getInt(1)); - Assert.assertEquals("Kalle", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(1 + offset, rs.getInt(1)); + assertEquals("Kalle", rs.getString(2)); - Assert.assertTrue(rs.next()); - Assert.assertEquals(3 + offset, rs.getInt(1)); - Assert.assertEquals("Börje", rs.getString(2)); + assertTrue(rs.next()); + assertEquals(3 + offset, rs.getInt(1)); + assertEquals("Börje", rs.getString(2)); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); tQuery.commit(); } @@ -397,15 +402,15 @@ public class TableQueryTest { SQLTestsConstants.sqlGen); SQLContainer container = new SQLContainer(tQuery); container.setAutoCommit(false); - Assert.assertTrue( + assertTrue( container.removeItem(container.getItemIds().iterator().next())); - Assert.assertEquals(4, tQuery.getCount()); - Assert.assertEquals(3, container.size()); + assertEquals(4, tQuery.getCount()); + assertEquals(3, container.size()); container.commit(); - Assert.assertEquals(3, tQuery.getCount()); - Assert.assertEquals(3, container.size()); + assertEquals(3, tQuery.getCount()); + assertEquals(3, container.size()); } @Test @@ -416,7 +421,7 @@ public class TableQueryTest { SQLContainer container = new SQLContainer(tQuery); container.setAutoCommit(true); - Assert.assertFalse(container.removeItem("foo")); + assertFalse(container.removeItem("foo")); } /********************************************************************** @@ -432,14 +437,14 @@ public class TableQueryTest { container.setAutoCommit(false); Object item = container.addItem(); - Assert.assertNotNull(item); + assertNotNull(item); - Assert.assertEquals(4, tQuery.getCount()); - Assert.assertEquals(5, container.size()); + assertEquals(4, tQuery.getCount()); + assertEquals(5, container.size()); container.commit(); - Assert.assertEquals(5, tQuery.getCount()); - Assert.assertEquals(5, container.size()); + assertEquals(5, tQuery.getCount()); + assertEquals(5, container.size()); } @Test @@ -453,29 +458,29 @@ public class TableQueryTest { container.setAutoCommit(false); /* Check that the container size is correct and there is no 'Viljami' */ - Assert.assertEquals(4, container.size()); + assertEquals(4, container.size()); List<Filter> filters = new ArrayList<Filter>(); filters.add(new Equal("NAME", "Viljami")); tQuery.setFilters(filters); - Assert.assertEquals(0, tQuery.getCount()); + assertEquals(0, tQuery.getCount()); tQuery.setFilters(null); /* Fetch first item, modify and commit */ Object item = container .getItem(container.getItemIds().iterator().next()); - Assert.assertNotNull(item); + assertNotNull(item); RowItem ri = (RowItem) item; - Assert.assertNotNull(ri.getItemProperty("NAME")); + assertNotNull(ri.getItemProperty("NAME")); ri.getItemProperty("NAME").setValue("Viljami"); container.commit(); // Check that the size is still correct and only 1 'Viljami' is found - Assert.assertEquals(4, tQuery.getCount()); - Assert.assertEquals(4, container.size()); + assertEquals(4, tQuery.getCount()); + assertEquals(4, container.size()); tQuery.setFilters(filters); - Assert.assertEquals(1, tQuery.getCount()); + assertEquals(1, tQuery.getCount()); } @Test @@ -497,7 +502,7 @@ public class TableQueryTest { .prepareStatement("SELECT * FROM PEOPLE WHERE \"NAME\" = ?"); stmt.setString(1, "R2D2"); ResultSet rs = stmt.executeQuery(); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); rs.close(); stmt.close(); connectionPool.releaseConnection(conn); @@ -513,7 +518,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); row.getItemProperty("TEXT").setValue("asdf"); container.commit(); @@ -523,7 +528,7 @@ public class TableQueryTest { .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?"); stmt.setString(1, "asdf"); ResultSet rs = stmt.executeQuery(); - Assert.assertTrue(rs.next()); + assertTrue(rs.next()); rs.close(); stmt.close(); conn.commit(); @@ -545,7 +550,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); row.getItemProperty("TEXT").setValue("asdf"); @@ -573,7 +578,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); container.removeItem(container.firstItemId()); container.commit(); @@ -583,7 +588,7 @@ public class TableQueryTest { .prepareStatement("SELECT * FROM VERSIONED WHERE \"TEXT\" = ?"); stmt.setString(1, "Junk"); ResultSet rs = stmt.executeQuery(); - Assert.assertFalse(rs.next()); + assertFalse(rs.next()); rs.close(); stmt.close(); conn.commit(); @@ -605,7 +610,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); // Update the version using another connection. Connection conn = connectionPool.reserveConnection(); @@ -637,7 +642,7 @@ public class TableQueryTest { tQuery.setVersionColumn("VERSION"); SQLContainer container = new SQLContainer(tQuery); RowItem row = (RowItem) container.getItem(container.firstItemId()); - Assert.assertEquals("Junk", row.getItemProperty("TEXT").getValue()); + assertEquals("Junk", row.getItemProperty("TEXT").getValue()); // Update the version using another connection. Connection conn = connectionPool.reserveConnection(); @@ -694,7 +699,7 @@ public class TableQueryTest { // metadata scanning at query creation time should not fail TableQuery tq1 = new TableQuery(null, "oaas", "product", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertNotNull(tq1); + assertNotNull(tq1); } finally { // cleanup - might not be an in-memory DB statement.execute(SQLTestsConstants.dropSchema); @@ -737,7 +742,7 @@ public class TableQueryTest { // name TableQuery tq1 = new TableQuery("sqlcontainer", "oaas", "product", connectionPool, SQLTestsConstants.sqlGen); - Assert.assertNotNull(tq1); + assertNotNull(tq1); } finally { // cleanup - might not be an in-memory DB statement.execute(SQLTestsConstants.dropSchema); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java index db4cf97a1e..eae607048c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/AnyEnumToStringConverterTest.java @@ -16,9 +16,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -84,24 +85,23 @@ public class AnyEnumToStringConverterTest { @Test public void nullConversion() { - Assert.assertEquals(null, converter.convertToModel(null, null, null)); + assertEquals(null, converter.convertToModel(null, null, null)); } @Test public void enumToStringConversion() { - Assert.assertEquals(TestEnum.TWO.toString(), + assertEquals(TestEnum.TWO.toString(), converter.convertToModel(TestEnum.TWO, String.class, null)); - Assert.assertEquals(AnotherTestEnum.TWO.toString(), converter + assertEquals(AnotherTestEnum.TWO.toString(), converter .convertToModel(AnotherTestEnum.TWO, String.class, null)); } @Test public void stringToEnumConversion() { - Assert.assertEquals(TestEnum.TWO, converter.convertToPresentation( + assertEquals(TestEnum.TWO, converter.convertToPresentation( TestEnum.TWO.toString(), TestEnum.class, null)); - Assert.assertEquals(AnotherTestEnum.TWO, - converter.convertToPresentation(AnotherTestEnum.TWO.toString(), - AnotherTestEnum.class, null)); + assertEquals(AnotherTestEnum.TWO, converter.convertToPresentation( + AnotherTestEnum.TWO.toString(), AnotherTestEnum.class, null)); } @Test @@ -109,20 +109,19 @@ public class AnyEnumToStringConverterTest { TextField tf = new TextField(); tf.setConverter(new ReverseConverter(converter)); tf.setPropertyDataSource(new ObjectProperty(AnotherTestEnum.TWO)); - Assert.assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); tf.setValue(AnotherTestEnum.ONE.toString()); - Assert.assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); - Assert.assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); - Assert.assertEquals(AnotherTestEnum.ONE, + assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); + assertEquals(AnotherTestEnum.ONE, tf.getPropertyDataSource().getValue()); tf.setPropertyDataSource(new ObjectProperty(TestEnum.TWO)); - Assert.assertEquals(TestEnum.TWO.toString(), tf.getValue()); + assertEquals(TestEnum.TWO.toString(), tf.getValue()); tf.setValue(TestEnum.ONE.toString()); - Assert.assertEquals(TestEnum.ONE.toString(), tf.getValue()); - Assert.assertEquals(TestEnum.ONE, tf.getConvertedValue()); - Assert.assertEquals(TestEnum.ONE, - tf.getPropertyDataSource().getValue()); + assertEquals(TestEnum.ONE.toString(), tf.getValue()); + assertEquals(TestEnum.ONE, tf.getConvertedValue()); + assertEquals(TestEnum.ONE, tf.getPropertyDataSource().getValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java index 2727b610bc..1d6efcd75e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/ConverterFactoryTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.VaadinSession; @@ -85,7 +86,7 @@ public class ConverterFactoryTest { tf.setConverter(Integer.class); // The application converter always returns 42. Current application is // null - Assert.assertEquals(42, tf.getConvertedValue()); + assertEquals(42, tf.getConvertedValue()); } @Test @@ -100,7 +101,7 @@ public class ConverterFactoryTest { tf.setConverter(Integer.class); // The application converter always returns 42. Current application is // null - Assert.assertEquals(42, tf.getConvertedValue()); + assertEquals(42, tf.getConvertedValue()); } @Test @@ -121,6 +122,6 @@ public class ConverterFactoryTest { // The application converter always returns 42. Application.getCurrent() // should not be used - Assert.assertEquals(42, tf.getConvertedValue()); + assertEquals(42, tf.getConvertedValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java index 6300ed9479..87edc99c0c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToLongConverterTest.java @@ -1,8 +1,9 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Date; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.DateToLongConverter; @@ -13,14 +14,13 @@ public class DateToLongConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Long.class, null)); + assertEquals(null, converter.convertToModel(null, Long.class, null)); } @Test public void testValueConversion() { Date d = new Date(100, 0, 1); - Assert.assertEquals( + assertEquals( Long.valueOf(946677600000l + (d.getTimezoneOffset() + 120) * 60 * 1000L), converter.convertToModel(d, Long.class, null)); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java index 35a8c5dbec..3cd83f8d2a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DateToSqlDateConverterTest.java @@ -1,9 +1,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.DateToSqlDateConverter; @@ -14,7 +15,7 @@ public class DateToSqlDateConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, + assertEquals(null, converter.convertToModel(null, java.sql.Date.class, null)); } @@ -22,7 +23,7 @@ public class DateToSqlDateConverterTest { public void testValueConversion() { Date testDate = new Date(100, 0, 1); long time = testDate.getTime(); - Assert.assertEquals(testDate, converter.convertToModel( - new java.sql.Date(time), java.sql.Date.class, Locale.ENGLISH)); + assertEquals(testDate, converter.convertToModel(new java.sql.Date(time), + java.sql.Date.class, Locale.ENGLISH)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java index a157884376..8426d16e68 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/DefaultConverterFactoryTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.DefaultConverterFactory; @@ -105,18 +106,18 @@ public class DefaultConverterFactoryTest { U tConvertedToU = factory.createConverter(tClass, uClass) .convertToModel(t, uClass, Locale.ENGLISH); - Assert.assertEquals("Incorrect type of value converted from " + assertEquals("Incorrect type of value converted from " + tClass.getSimpleName() + " to " + uClass.getSimpleName(), uClass, tConvertedToU.getClass()); - Assert.assertEquals("Incorrect conversion of " + t + " to " + assertEquals("Incorrect conversion of " + t + " to " + uClass.getSimpleName(), u, tConvertedToU); T uConvertedToT = factory.createConverter(uClass, tClass) .convertToModel(u, tClass, Locale.ENGLISH); - Assert.assertEquals("Incorrect type of value converted from " + assertEquals("Incorrect type of value converted from " + uClass.getSimpleName() + " to " + tClass.getSimpleName(), tClass, uConvertedToT.getClass()); - Assert.assertEquals("Incorrect conversion of " + u + " to " + assertEquals("Incorrect conversion of " + u + " to " + tClass.getSimpleName(), t, uConvertedToT); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java index 5ec0caa5ee..366255d616 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/SpecificEnumToStringConverterTest.java @@ -16,9 +16,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -92,21 +93,19 @@ public class SpecificEnumToStringConverterTest { @Test public void nullConversion() { - Assert.assertEquals(null, - testEnumConverter.convertToModel(null, null, null)); + assertEquals(null, testEnumConverter.convertToModel(null, null, null)); } @Test public void enumToStringConversion() { - Assert.assertEquals(TestEnum.TWO.toString(), testEnumConverter + assertEquals(TestEnum.TWO.toString(), testEnumConverter .convertToModel(TestEnum.TWO, String.class, null)); } @Test public void stringToEnumConversion() { - Assert.assertEquals(TestEnum.TWO, - testEnumConverter.convertToPresentation(TestEnum.TWO.toString(), - TestEnum.class, null)); + assertEquals(TestEnum.TWO, testEnumConverter.convertToPresentation( + TestEnum.TWO.toString(), TestEnum.class, null)); } @Test @@ -114,11 +113,11 @@ public class SpecificEnumToStringConverterTest { TextField tf = new TextField(); tf.setConverter(new ReverseConverter(anotherTestEnumConverter)); tf.setPropertyDataSource(new ObjectProperty(AnotherTestEnum.TWO)); - Assert.assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.TWO.toString(), tf.getValue()); tf.setValue(AnotherTestEnum.ONE.toString()); - Assert.assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); - Assert.assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); - Assert.assertEquals(AnotherTestEnum.ONE, + assertEquals(AnotherTestEnum.ONE.toString(), tf.getValue()); + assertEquals(AnotherTestEnum.ONE, tf.getConvertedValue()); + assertEquals(AnotherTestEnum.ONE, tf.getPropertyDataSource().getValue()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java index 00e384e594..64159c1c5f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigDecimalConverterTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToBigDecimalConverter; @@ -29,13 +30,13 @@ public class StringToBigDecimalConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, + assertEquals(null, converter.convertToModel(null, BigDecimal.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, + assertEquals(null, converter.convertToModel("", BigDecimal.class, null)); } @@ -44,7 +45,7 @@ public class StringToBigDecimalConverterTest { BigDecimal converted = converter.convertToModel("10", BigDecimal.class, null); BigDecimal expected = new BigDecimal(10); - Assert.assertEquals(expected, converted); + assertEquals(expected, converted); } @Test @@ -54,6 +55,6 @@ public class StringToBigDecimalConverterTest { String converted = converter.convertToPresentation(bd, String.class, Locale.GERMAN); - Assert.assertEquals(expected, converted); + assertEquals(expected, converted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java index f613950c71..2009e8523e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBigIntegerConverterTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigInteger; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToBigIntegerConverter; @@ -29,13 +30,13 @@ public class StringToBigIntegerConverterTest { @Test public void testNullConversion() { - Assert.assertEquals("Null value was converted incorrectly", null, + assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, BigInteger.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals("Empty value was converted incorrectly", null, + assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", BigInteger.class, null)); } @@ -45,8 +46,7 @@ public class StringToBigIntegerConverterTest { BigInteger converted = converter.convertToModel(bigInt, BigInteger.class, null); BigInteger expected = new BigInteger(bigInt); - Assert.assertEquals( - "Value bigger than max long was converted incorrectly", + assertEquals("Value bigger than max long was converted incorrectly", expected, converted); } @@ -57,8 +57,7 @@ public class StringToBigIntegerConverterTest { String converted = converter.convertToPresentation(bd, String.class, Locale.GERMAN); - Assert.assertEquals( - "Value with specific locale was converted incorrectly", + assertEquals("Value with specific locale was converted incorrectly", expected, converted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java index 9f94a4185e..b472c2d02c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToBooleanConverterTest.java @@ -1,10 +1,13 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToBooleanConverter; @@ -36,47 +39,41 @@ public class StringToBooleanConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Boolean.class, null)); + assertEquals(null, converter.convertToModel(null, Boolean.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Boolean.class, null)); + assertEquals(null, converter.convertToModel("", Boolean.class, null)); } @Test public void testValueConversion() { - Assert.assertTrue( - converter.convertToModel("true", Boolean.class, null)); - Assert.assertFalse( - converter.convertToModel("false", Boolean.class, null)); + assertTrue(converter.convertToModel("true", Boolean.class, null)); + assertFalse(converter.convertToModel("false", Boolean.class, null)); } @Test public void testYesNoValueConversion() { - Assert.assertTrue( - yesNoConverter.convertToModel("yes", Boolean.class, null)); - Assert.assertFalse( - yesNoConverter.convertToModel("no", Boolean.class, null)); + assertTrue(yesNoConverter.convertToModel("yes", Boolean.class, null)); + assertFalse(yesNoConverter.convertToModel("no", Boolean.class, null)); - Assert.assertEquals("yes", + assertEquals("yes", yesNoConverter.convertToPresentation(true, String.class, null)); - Assert.assertEquals("no", yesNoConverter.convertToPresentation(false, + assertEquals("no", yesNoConverter.convertToPresentation(false, String.class, null)); } @Test public void testLocale() { - Assert.assertEquals("May 18, 2033", localeConverter - .convertToPresentation(true, String.class, Locale.US)); - Assert.assertEquals("January 24, 2065", localeConverter + assertEquals("May 18, 2033", localeConverter.convertToPresentation(true, + String.class, Locale.US)); + assertEquals("January 24, 2065", localeConverter .convertToPresentation(false, String.class, Locale.US)); - Assert.assertEquals("18. Mai 2033", localeConverter - .convertToPresentation(true, String.class, Locale.GERMANY)); - Assert.assertEquals("24. Januar 2065", localeConverter + assertEquals("18. Mai 2033", localeConverter.convertToPresentation(true, + String.class, Locale.GERMANY)); + assertEquals("24. Januar 2065", localeConverter .convertToPresentation(false, String.class, Locale.GERMANY)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java index 334114a41a..fe249f1594 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToByteConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -16,33 +18,32 @@ public class StringToByteConverterTest { @Test public void testNullConversion() { - Assert.assertEquals("Null value was converted incorrectly", null, + assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, Byte.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals("Null value reversely was converted incorrectly", - null, + assertEquals("Null value reversely was converted incorrectly", null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals("Empty value was converted incorrectly", null, + assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", Byte.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals("Byte value was converted incorrectly", + assertEquals("Byte value was converted incorrectly", Byte.valueOf((byte) 10), converter.convertToModel("10", Byte.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals("Byte value reversely was converted incorrectly", + assertEquals("Byte value reversely was converted incorrectly", reverseConverter.convertToModel((byte) 10, String.class, null), "10"); } @@ -50,17 +51,16 @@ public class StringToByteConverterTest { @Test public void testExtremeByteValueConversion() { byte b = converter.convertToModel("127", Byte.class, null); - Assert.assertEquals(Byte.MAX_VALUE, b); + assertEquals(Byte.MAX_VALUE, b); b = converter.convertToModel("-128", Byte.class, null); - Assert.assertEquals("Min byte value was converted incorrectly", - Byte.MIN_VALUE, b); + assertEquals("Min byte value was converted incorrectly", Byte.MIN_VALUE, + b); } @Test public void testValueOutOfRange() { - Double[] values = { Byte.MAX_VALUE * 2.0, - Byte.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Byte.MAX_VALUE * 2.0, Byte.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -71,6 +71,6 @@ public class StringToByteConverterTest { } catch (ConversionException expected) { } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java index f6dc22face..83f32e249f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToCollectionConverterTest.java @@ -15,6 +15,11 @@ */ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -26,7 +31,6 @@ import java.util.Locale; import java.util.Set; import java.util.Vector; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToCollectionConverter; @@ -46,11 +50,11 @@ public class StringToCollectionConverterTest { StringToCollectionConverter converter = new StringToCollectionConverter(); Collection<?> model = converter.convertToModel("a, b, c", List.class, null); - Assert.assertTrue("Unexpected model class", model instanceof ArrayList); + assertTrue("Unexpected model class", model instanceof ArrayList); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertEquals("Incorrect second token", "b", iterator.next()); - Assert.assertEquals("Incorrect third token", "c", iterator.next()); + assertEquals("Incorrect fist token", "a", iterator.next()); + assertEquals("Incorrect second token", "b", iterator.next()); + assertEquals("Incorrect third token", "c", iterator.next()); } @Test @@ -59,11 +63,11 @@ public class StringToCollectionConverterTest { "x"); Collection<?> model = converter.convertToModel("axbxc", List.class, null); - Assert.assertTrue("Unexpected model class", model instanceof ArrayList); + assertTrue("Unexpected model class", model instanceof ArrayList); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertEquals("Incorrect second token", "b", iterator.next()); - Assert.assertEquals("Incorrect third token", "c", iterator.next()); + assertEquals("Incorrect fist token", "a", iterator.next()); + assertEquals("Incorrect second token", "b", iterator.next()); + assertEquals("Incorrect third token", "c", iterator.next()); } @Test @@ -72,11 +76,11 @@ public class StringToCollectionConverterTest { ",", new StringToIntegerConverter(), Integer.class); Collection<?> model = converter.convertToModel("6,2,5", List.class, null); - Assert.assertTrue("Unexpected model class", model instanceof ArrayList); + assertTrue("Unexpected model class", model instanceof ArrayList); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", 6, iterator.next()); - Assert.assertEquals("Incorrect second token", 2, iterator.next()); - Assert.assertEquals("Incorrect third token", 5, iterator.next()); + assertEquals("Incorrect fist token", 6, iterator.next()); + assertEquals("Incorrect second token", 2, iterator.next()); + assertEquals("Incorrect third token", 5, iterator.next()); } @Test @@ -85,10 +89,10 @@ public class StringToCollectionConverterTest { " ", new StringToEnumConverter(), TestEnum.class); Collection<?> model = converter.convertToModel("Z X Y", Set.class, null); - Assert.assertTrue("Unexpected model class", model instanceof HashSet); + assertTrue("Unexpected model class", model instanceof HashSet); EnumSet<TestEnum> set = EnumSet.allOf(TestEnum.class); set.removeAll(model); - Assert.assertTrue("Some values are not in resutling collection", + assertTrue("Some values are not in resutling collection", set.isEmpty()); } @@ -106,11 +110,11 @@ public class StringToCollectionConverterTest { ", ", null, String.class, factory); Collection<?> model = converter.convertToModel("a, b, c", Collection.class, null); - Assert.assertTrue("Unexpected model class", model instanceof Vector); + assertTrue("Unexpected model class", model instanceof Vector); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertEquals("Incorrect second token", "b", iterator.next()); - Assert.assertEquals("Incorrect third token", "c", iterator.next()); + assertEquals("Incorrect fist token", "a", iterator.next()); + assertEquals("Incorrect second token", "b", iterator.next()); + assertEquals("Incorrect third token", "c", iterator.next()); } @Test @@ -119,7 +123,7 @@ public class StringToCollectionConverterTest { String presentation = converter.convertToPresentation( Arrays.asList("a", "b", "c"), String.class, null); - Assert.assertEquals("a, b, c", presentation); + assertEquals("a, b, c", presentation); } @Test @@ -129,7 +133,7 @@ public class StringToCollectionConverterTest { String presentation = converter.convertToPresentation( Arrays.asList("a", "b", "c"), String.class, null); - Assert.assertEquals("axbxc", presentation); + assertEquals("axbxc", presentation); } @Test @@ -139,7 +143,7 @@ public class StringToCollectionConverterTest { String presentation = converter.convertToPresentation( Arrays.asList(TestEnum.Z, TestEnum.Y), String.class, null); - Assert.assertEquals("Z,Y", presentation); + assertEquals("Z,Y", presentation); } @Test @@ -147,22 +151,22 @@ public class StringToCollectionConverterTest { StringToCollectionConverter converter = new StringToCollectionConverter(); Collection<?> model = converter.convertToModel("a", List.class, null); Iterator<?> iterator = model.iterator(); - Assert.assertEquals("Incorrect fist token", "a", iterator.next()); - Assert.assertFalse("More than one item detected after conversation", + assertEquals("Incorrect fist token", "a", iterator.next()); + assertFalse("More than one item detected after conversation", iterator.hasNext()); } @Test public void convertToModel_null() { StringToCollectionConverter converter = new StringToCollectionConverter(); - Assert.assertNull(converter.convertToModel(null, ArrayList.class, + assertNull(converter.convertToModel(null, ArrayList.class, Locale.ENGLISH)); } @Test public void convertToPresentation_null() { StringToCollectionConverter converter = new StringToCollectionConverter(); - Assert.assertNull(converter.convertToPresentation(null, String.class, + assertNull(converter.convertToPresentation(null, String.class, Locale.ENGLISH)); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java index c778e9e731..985ff81490 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDateConverterTest.java @@ -1,9 +1,10 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToDateConverter; @@ -14,19 +15,17 @@ public class StringToDateConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Date.class, null)); + assertEquals(null, converter.convertToModel(null, Date.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Date.class, null)); + assertEquals(null, converter.convertToModel("", Date.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(new Date(100, 0, 1), converter.convertToModel( + assertEquals(new Date(100, 0, 1), converter.convertToModel( "Jan 1, 2000 12:00:00 AM", Date.class, Locale.ENGLISH)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java index a0891ecefe..5f69c47367 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToDoubleConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToDoubleConverter; @@ -11,19 +12,17 @@ public class StringToDoubleConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Double.class, null)); + assertEquals(null, converter.convertToModel(null, Double.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Double.class, null)); + assertEquals(null, converter.convertToModel("", Double.class, null)); } @Test public void testValueConversion() { Double value = converter.convertToModel("10", Double.class, null); - Assert.assertEquals(10.0d, value, 0.01d); + assertEquals(10.0d, value, 0.01d); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java index a86b8b82e0..3bc13df230 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToEnumConverterTest.java @@ -1,6 +1,9 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -46,15 +49,14 @@ public class StringToEnumConverterTest { @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Enum.class, null)); + assertEquals(null, converter.convertToModel("", Enum.class, null)); } @Test public void testInvalidEnumClassConversion() { try { converter.convertToModel("Foo", Enum.class, null); - Assert.fail("No exception thrown"); + fail("No exception thrown"); } catch (ConversionException e) { // OK } @@ -62,69 +64,68 @@ public class StringToEnumConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Enum.class, null)); + assertEquals(null, converter.convertToModel(null, Enum.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals(null, + assertEquals(null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(FooEnum.VALUE1, + assertEquals(FooEnum.VALUE1, converter.convertToModel("Value1", FooEnum.class, null)); - Assert.assertEquals(FooEnum.SOME_VALUE, + assertEquals(FooEnum.SOME_VALUE, converter.convertToModel("Some value", FooEnum.class, null)); - Assert.assertEquals(FooEnum.FOO_BAR_BAZ, + assertEquals(FooEnum.FOO_BAR_BAZ, converter.convertToModel("Foo bar baz", FooEnum.class, null)); - Assert.assertEquals(FooEnum.Bar, + assertEquals(FooEnum.Bar, converter.convertToModel("Bar", FooEnum.class, null)); - Assert.assertEquals(FooEnum.nonStandardCase, converter + assertEquals(FooEnum.nonStandardCase, converter .convertToModel("Nonstandardcase", FooEnum.class, null)); - Assert.assertEquals(FooEnum._HUGH, + assertEquals(FooEnum._HUGH, converter.convertToModel("_hugh", FooEnum.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals("Value1", reverseConverter - .convertToModel(FooEnum.VALUE1, String.class, null)); - Assert.assertEquals("Some value", reverseConverter + assertEquals("Value1", reverseConverter.convertToModel(FooEnum.VALUE1, + String.class, null)); + assertEquals("Some value", reverseConverter .convertToModel(FooEnum.SOME_VALUE, String.class, null)); - Assert.assertEquals("Foo bar baz", reverseConverter + assertEquals("Foo bar baz", reverseConverter .convertToModel(FooEnum.FOO_BAR_BAZ, String.class, null)); - Assert.assertEquals("Bar", reverseConverter.convertToModel(FooEnum.Bar, + assertEquals("Bar", reverseConverter.convertToModel(FooEnum.Bar, String.class, null)); - Assert.assertEquals("Nonstandardcase", reverseConverter + assertEquals("Nonstandardcase", reverseConverter .convertToModel(FooEnum.nonStandardCase, String.class, null)); - Assert.assertEquals("_hugh", reverseConverter - .convertToModel(FooEnum._HUGH, String.class, null)); + assertEquals("_hugh", reverseConverter.convertToModel(FooEnum._HUGH, + String.class, null)); } @Test public void preserveFormattingWithCustomToString() { for (EnumWithCustomToString e : EnumWithCustomToString.values()) { - Assert.assertEquals(e.toString(), convertToString(e)); + assertEquals(e.toString(), convertToString(e)); } } @Test public void findEnumWithCustomToString() { for (EnumWithCustomToString e : EnumWithCustomToString.values()) { - Assert.assertSame(e, + assertSame(e, convertToEnum(e.toString(), EnumWithCustomToString.class)); - Assert.assertSame(e, + assertSame(e, convertToEnum(e.name(), EnumWithCustomToString.class)); } } @Test public void unambigousValueInEnumWithAmbigous_succeed() { - Assert.assertSame(EnumWithAmbigousToString.FOO, + assertSame(EnumWithAmbigousToString.FOO, convertToEnum("foo", EnumWithAmbigousToString.class)); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java index 70c408b808..c13782fc32 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToFloatConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.data.util.converter.StringToFloatConverter; @@ -11,19 +12,17 @@ public class StringToFloatConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Float.class, null)); + assertEquals(null, converter.convertToModel(null, Float.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Float.class, null)); + assertEquals(null, converter.convertToModel("", Float.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(Float.valueOf(10), + assertEquals(Float.valueOf(10), converter.convertToModel("10", Float.class, null)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java index 7d2f9c8d7d..a75e1a0c35 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToIntegerConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter.ConversionException; @@ -12,21 +14,18 @@ public class StringToIntegerConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Integer.class, null)); + assertEquals(null, converter.convertToModel(null, Integer.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Integer.class, null)); + assertEquals(null, converter.convertToModel("", Integer.class, null)); } @Test public void testValueOutOfRange() { - Double[] values = { Integer.MAX_VALUE * 2.0, - Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -37,12 +36,12 @@ public class StringToIntegerConverterTest { } catch (ConversionException expected) { } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } @Test public void testValueConversion() { - Assert.assertEquals(Integer.valueOf(10), + assertEquals(Integer.valueOf(10), converter.convertToModel("10", Integer.class, null)); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java index 5e5b9f1d86..4c5e3db5dc 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToLongConverterTest.java @@ -1,8 +1,9 @@ package com.vaadin.v7.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -17,51 +18,49 @@ public class StringToLongConverterTest { @Test public void testNullConversion() { - Assert.assertEquals(null, - converter.convertToModel(null, Long.class, null)); + assertEquals(null, converter.convertToModel(null, Long.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals(null, + assertEquals(null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals(null, - converter.convertToModel("", Long.class, null)); + assertEquals(null, converter.convertToModel("", Long.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals(Long.valueOf(10), + assertEquals(Long.valueOf(10), converter.convertToModel("10", Long.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals( - reverseConverter.convertToModel(10L, String.class, null), "10"); + assertEquals(reverseConverter.convertToModel(10L, String.class, null), + "10"); } @Test public void testExtremeLongValueConversion() { long l = converter.convertToModel("9223372036854775807", Long.class, null); - Assert.assertEquals(Long.MAX_VALUE, l); + assertEquals(Long.MAX_VALUE, l); l = converter.convertToModel("-9223372036854775808", Long.class, null); - Assert.assertEquals(Long.MIN_VALUE, l); + assertEquals(Long.MIN_VALUE, l); } @Test public void testExtremeReverseLongValueConversion() { String str = reverseConverter.convertToModel(Long.MAX_VALUE, String.class, Locale.ENGLISH); - Assert.assertEquals("9,223,372,036,854,775,807", str); + assertEquals("9,223,372,036,854,775,807", str); str = reverseConverter.convertToModel(Long.MIN_VALUE, String.class, Locale.ENGLISH); - Assert.assertEquals("-9,223,372,036,854,775,808", str); + assertEquals("-9,223,372,036,854,775,808", str); } @Test @@ -69,10 +68,10 @@ public class StringToLongConverterTest { // Long.MAX_VALUE+1 is converted to Long.MAX_VALUE long l = converter.convertToModel("9223372036854775808", Long.class, null); - Assert.assertEquals(Long.MAX_VALUE, l); + assertEquals(Long.MAX_VALUE, l); // Long.MIN_VALUE-1 is converted to Long.MIN_VALUE l = converter.convertToModel("-9223372036854775809", Long.class, null); - Assert.assertEquals(Long.MIN_VALUE, l); + assertEquals(Long.MIN_VALUE, l); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java index fed000555c..be29555bf0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/converter/StringToShortConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.v7.data.util.converter.Converter; @@ -16,33 +18,32 @@ public class StringToShortConverterTest { @Test public void testNullConversion() { - Assert.assertEquals("Null value was converted incorrectly", null, + assertEquals("Null value was converted incorrectly", null, converter.convertToModel(null, Short.class, null)); } @Test public void testReverseNullConversion() { - Assert.assertEquals("Null value reversely was converted incorrectly", - null, + assertEquals("Null value reversely was converted incorrectly", null, reverseConverter.convertToModel(null, String.class, null)); } @Test public void testEmptyStringConversion() { - Assert.assertEquals("Empty value was converted incorrectly", null, + assertEquals("Empty value was converted incorrectly", null, converter.convertToModel("", Short.class, null)); } @Test public void testValueConversion() { - Assert.assertEquals("Short value was converted incorrectly", + assertEquals("Short value was converted incorrectly", Short.valueOf((short) 10), converter.convertToModel("10", Short.class, null)); } @Test public void testReverseValueConversion() { - Assert.assertEquals("Short value reversely was converted incorrectly", + assertEquals("Short value reversely was converted incorrectly", reverseConverter.convertToModel((short) 10, String.class, null), "10"); } @@ -50,17 +51,16 @@ public class StringToShortConverterTest { @Test public void testExtremeShortValueConversion() { short b = converter.convertToModel("32767", Short.class, null); - Assert.assertEquals(Short.MAX_VALUE, b); + assertEquals(Short.MAX_VALUE, b); b = converter.convertToModel("-32768", Short.class, null); - Assert.assertEquals("Min short value was converted incorrectly", + assertEquals("Min short value was converted incorrectly", Short.MIN_VALUE, b); } @Test public void testValueOutOfRange() { - Double[] values = { Integer.MAX_VALUE * 2.0, - Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -71,6 +71,6 @@ public class StringToShortConverterTest { } catch (ConversionException expected) { } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java index 5547651107..37e0daca6c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigDecimalRangeValidatorTest.java @@ -1,8 +1,10 @@ package com.vaadin.v7.tests.data.validator; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.validator.BigDecimalRangeValidator; @@ -20,41 +22,41 @@ public class BigDecimalRangeValidatorTest { @Test public void testNullValue() { - Assert.assertTrue("Didn't accept null", cleanValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", maxValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minMaxValidator.isValid(null)); + assertTrue("Didn't accept null", cleanValidator.isValid(null)); + assertTrue("Didn't accept null", minValidator.isValid(null)); + assertTrue("Didn't accept null", maxValidator.isValid(null)); + assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } @Test public void testMinValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(new BigDecimal(-15.0))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minValidator.isValid(new BigDecimal(10.1))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minValidator.isValid(new BigDecimal(10.0))); } @Test public void testMaxValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(new BigDecimal(1120.0))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", maxValidator.isValid(new BigDecimal(15.0))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", maxValidator.isValid(new BigDecimal(100.6))); } @Test public void testMinMaxValue() { - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(new BigDecimal(10.5))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(new BigDecimal(100.5))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minMaxValidator.isValid(new BigDecimal(10.4))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", minMaxValidator.isValid(new BigDecimal(100.6))); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java index 144ca370fa..2f157e898c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/BigIntegerRangeValidatorTest.java @@ -1,8 +1,10 @@ package com.vaadin.v7.tests.data.validator; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.math.BigInteger; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.validator.BigIntegerRangeValidator; @@ -20,41 +22,41 @@ public class BigIntegerRangeValidatorTest { @Test public void testNullValue() { - Assert.assertTrue("Didn't accept null", cleanValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", maxValidator.isValid(null)); - Assert.assertTrue("Didn't accept null", minMaxValidator.isValid(null)); + assertTrue("Didn't accept null", cleanValidator.isValid(null)); + assertTrue("Didn't accept null", minValidator.isValid(null)); + assertTrue("Didn't accept null", maxValidator.isValid(null)); + assertTrue("Didn't accept null", minMaxValidator.isValid(null)); } @Test public void testMinValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(BigInteger.valueOf(-15))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minValidator.isValid(BigInteger.valueOf(15))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minValidator.isValid(BigInteger.valueOf(9))); } @Test public void testMaxValue() { - Assert.assertTrue("Validator without ranges didn't accept value", + assertTrue("Validator without ranges didn't accept value", cleanValidator.isValid(BigInteger.valueOf(1120))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", maxValidator.isValid(BigInteger.valueOf(15))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", maxValidator.isValid(BigInteger.valueOf(120))); } @Test public void testMinMaxValue() { - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(BigInteger.valueOf(15))); - Assert.assertTrue("Didn't accept valid value", + assertTrue("Didn't accept valid value", minMaxValidator.isValid(BigInteger.valueOf(99))); - Assert.assertFalse("Accepted too small value", + assertFalse("Accepted too small value", minMaxValidator.isValid(BigInteger.valueOf(9))); - Assert.assertFalse("Accepted too large value", + assertFalse("Accepted too large value", minMaxValidator.isValid(BigInteger.valueOf(110))); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java index b8f8109028..e55d5e071e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.data.validator; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.validator.EmailValidator; @@ -11,21 +13,21 @@ public class EmailValidatorTest { @Test public void testEmailValidatorWithNull() { - Assert.assertTrue(validator.isValid(null)); + assertTrue(validator.isValid(null)); } @Test public void testEmailValidatorWithEmptyString() { - Assert.assertTrue(validator.isValid("")); + assertTrue(validator.isValid("")); } @Test public void testEmailValidatorWithFaultyString() { - Assert.assertFalse(validator.isValid("not.an.email")); + assertFalse(validator.isValid("not.an.email")); } @Test public void testEmailValidatorWithOkEmail() { - Assert.assertTrue(validator.isValid("my.name@email.com")); + assertTrue(validator.isValid("my.name@email.com")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java index b84388ad9c..612d1027e9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/ContextClickListenerTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.v7.tests.server; +import static org.junit.Assert.fail; + import java.util.EventObject; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.event.ContextClickEvent; @@ -77,9 +78,9 @@ public class ContextClickListenerTest extends AbstractComponent { public void validate() { if (expected != null) { - Assert.fail("Expected context click never happened."); + fail("Expected context click never happened."); } else if (error != null) { - Assert.fail(error); + fail(error); } } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java index 5cc57a75b7..3557a7f87e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldDataSourceLocaleChangeTest.java @@ -1,9 +1,10 @@ package com.vaadin.v7.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; + import java.text.NumberFormat; import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -53,13 +54,13 @@ public class AbsFieldDataSourceLocaleChangeTest { }); tf.setImmediate(true); tf.setConvertedValue(10000); - Assert.assertEquals("0000010000", tf.getValue()); + assertEquals("0000010000", tf.getValue()); VerticalLayout vl = new VerticalLayout(); ui.setContent(vl); ui.setLocale(new Locale("en", "US")); vl.addComponent(tf); - Assert.assertEquals("10,000", tf.getValue()); + assertEquals("10,000", tf.getValue()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java index 12ac5ccca7..b64f51e345 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionErrorTest.java @@ -1,8 +1,8 @@ package com.vaadin.v7.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.data.bean.Address; @@ -32,7 +32,7 @@ public class AbsFieldValueConversionErrorTest { tf.validate(); fail(); } catch (InvalidValueException e) { - Assert.assertEquals( + assertEquals( "(Type: Integer) Converter exception message: Could not convert 'abc' to java.lang.Integer", e.getMessage()); } @@ -50,7 +50,7 @@ public class AbsFieldValueConversionErrorTest { tf.getConvertedValue(); fail(); } catch (ConversionException e) { - Assert.assertEquals( + assertEquals( "(Type: Integer) Converter exception message: Could not convert 'abc' to java.lang.Integer", e.getMessage()); } @@ -68,7 +68,7 @@ public class AbsFieldValueConversionErrorTest { tf.validate(); fail(); } catch (InvalidValueException e) { - Assert.assertEquals(null, e.getMessage()); + assertEquals(null, e.getMessage()); } } @@ -84,8 +84,7 @@ public class AbsFieldValueConversionErrorTest { tf.validate(); fail(); } catch (InvalidValueException e) { - Assert.assertEquals("Could not convert value to Integer", - e.getMessage()); + assertEquals("Could not convert value to Integer", e.getMessage()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java index d4bdb4fe53..7ff7058e67 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java @@ -3,10 +3,10 @@ package com.vaadin.v7.tests.server.component.abstractfield; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.VaadinSession; @@ -266,8 +266,7 @@ public class AbsFieldValueConversionsTest { try { Object v = tf.getConvertedValue(); System.out.println(v); - Assert.fail( - "Trying to convert String -> Integer should fail when there is no converter"); + fail("Trying to convert String -> Integer should fail when there is no converter"); } catch (ConversionException e) { // ok, should happen when there is no converter but conversion is // needed diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java index 3ee4ce607b..4e70a70030 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/FieldDefaultValuesTest.java @@ -15,10 +15,13 @@ */ package com.vaadin.v7.tests.server.component.abstractfield; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.tests.VaadinClasses; @@ -36,7 +39,7 @@ public class FieldDefaultValuesTest { Object clearedValue = field.getValue(); - Assert.assertEquals( + assertEquals( "Expected to get default value after clearing " + field.getClass().getName(), originalValue, clearedValue); @@ -51,18 +54,18 @@ public class FieldDefaultValuesTest { field.clear(); if (field instanceof Slider) { - Assert.assertFalse( + assertFalse( "Slider should not be empty even after being cleared", field.isEmpty()); } else { - Assert.assertTrue( + assertTrue( field.getClass().getName() + " should be empty after being cleared", field.isEmpty()); } } - Assert.assertTrue(count > 0); + assertTrue(count > 0); } @SuppressWarnings("rawtypes") diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java index 6b0315a845..be22583697 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java @@ -15,10 +15,12 @@ */ package com.vaadin.v7.tests.server.component.abstractselect; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; import org.jsoup.parser.Tag; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.ExternalResource; @@ -179,7 +181,7 @@ public class AbstractSelectDeclarativeTest container.addContainerProperty("name", String.class, null); cb.setContainerDataSource(container); cb.readDesign(design, new DesignContext()); - Assert.assertTrue("Adding new items should be allowed.", + assertTrue("Adding new items should be allowed.", cb.isNewItemsAllowed()); assertEquals("Wrong item caption mode.", AbstractSelect.ItemCaptionMode.PROPERTY, @@ -188,7 +190,7 @@ public class AbstractSelectDeclarativeTest cb.getItemCaptionPropertyId()); assertEquals("Wrong item icon property id.", "icon", cb.getItemIconPropertyId()); - Assert.assertTrue("Null selection should be allowed.", + assertTrue("Null selection should be allowed.", cb.isNullSelectionAllowed()); assertEquals("Wrong null selection item id.", "No items selected", cb.getNullSelectionItemId()); @@ -199,12 +201,11 @@ public class AbstractSelectDeclarativeTest Element design = createDesignWithAttributesMultiSelect(); ListSelect ls = new ListSelect(); ls.readDesign(design, new DesignContext()); - Assert.assertTrue("Multi select should be allowed.", - ls.isMultiSelect()); + assertTrue("Multi select should be allowed.", ls.isMultiSelect()); assertEquals("Wrong caption mode.", AbstractSelect.ItemCaptionMode.EXPLICIT, ls.getItemCaptionMode()); - Assert.assertFalse("Null selection should not be allowed.", + assertFalse("Null selection should not be allowed.", ls.isNullSelectionAllowed()); } @@ -235,13 +236,13 @@ public class AbstractSelectDeclarativeTest cb.writeDesign(e, new DesignContext()); assertEquals("Wrong caption for the combo box.", "A combo box", e.attr("caption")); - Assert.assertTrue("Adding new items should be allowed.", + assertTrue("Adding new items should be allowed.", "".equals(e.attr("new-items-allowed"))); assertEquals("Wrong item caption mode.", "icon_only", e.attr("item-caption-mode")); assertEquals("Wrong item icon property id.", "icon", e.attr("item-icon-property-id")); - Assert.assertTrue("Null selection should be allowed.", + assertTrue("Null selection should be allowed.", "".equals(e.attr("null-selection-allowed")) || "true".equals(e.attr("null-selection-allowed"))); assertEquals("Wrong null selection item id.", "No item selected", @@ -255,7 +256,7 @@ public class AbstractSelectDeclarativeTest ls.writeDesign(e, new DesignContext()); assertEquals("Null selection should not be allowed.", "false", e.attr("null-selection-allowed")); - Assert.assertTrue("Multi select should be allowed.", + assertTrue("Multi select should be allowed.", "".equals(e.attr("multi-select")) || "true".equals(e.attr("multi-select"))); } @@ -267,7 +268,7 @@ public class AbstractSelectDeclarativeTest + " <option>> Two</option>" + "</vaadin7-combo-box>"; AbstractSelect read = read(design); - Assert.assertEquals("> One", read.getItemCaption("one")); + assertEquals("> One", read.getItemCaption("one")); AbstractSelect underTest = new ComboBox(); underTest.addItem("> One"); @@ -278,7 +279,7 @@ public class AbstractSelectDeclarativeTest DeclarativeTestBaseBase.ALWAYS_WRITE_DATA); underTest.writeDesign(root, dc); - Assert.assertEquals("> One", + assertEquals("> One", root.getElementsByTag("option").first().html()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java index 14f03739d1..5348d99f25 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractselect/AbstractSelectStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.abstractselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.select.AbstractSelectState; @@ -31,7 +32,7 @@ public class AbstractSelectStateTest { public void getState_selectHasCustomState() { TestSelect select = new TestSelect(); AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + assertEquals("Unexpected state class", AbstractSelectState.class, state.getClass()); } @@ -39,14 +40,14 @@ public class AbstractSelectStateTest { public void getPrimaryStyleName_selectHasCustomPrimaryStyleName() { TestSelect combobox = new TestSelect(); AbstractSelectState state = new AbstractSelectState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, combobox.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + combobox.getPrimaryStyleName()); } @Test public void selectStateHasCustomPrimaryStyleName() { AbstractSelectState state = new AbstractSelectState(); - Assert.assertEquals("Unexpected primary style name", "v-select", + assertEquals("Unexpected primary style name", "v-select", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java index 207d50f8aa..38ee0928a0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/CalendarBasicsTest.java @@ -211,7 +211,7 @@ public class CalendarBasicsTest { @Test public void isClientChangeAllowed_connectorEnabled() { TestCalendar calendar = new TestCalendar(true); - Assert.assertTrue( + assertTrue( "Calendar with enabled connector doesn't allow client change", calendar.isClientChangeAllowed()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java index a504d64a13..347628327a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerDataSourceTest.java @@ -389,20 +389,20 @@ public class ContainerDataSourceTest { calendar.setLocale(Locale.getDefault()); calendar.beforeClientResponse(true); // simulate adding to UI - Assert.assertEquals(0, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(23, calendar.getLastVisibleHourOfDay()); + assertEquals(0, calendar.getFirstVisibleHourOfDay()); + assertEquals(23, calendar.getLastVisibleHourOfDay()); calendar.autoScaleVisibleHoursOfDay(); - Assert.assertEquals(8, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(18, calendar.getLastVisibleHourOfDay()); + assertEquals(8, calendar.getFirstVisibleHourOfDay()); + assertEquals(18, calendar.getLastVisibleHourOfDay()); // reset visible timing to something else, so that the added event is // not filtered out calendar.resetVisibleHoursOfDay(); calendar.beforeClientResponse(false); // simulate being attached - Assert.assertEquals(0, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(23, calendar.getLastVisibleHourOfDay()); + assertEquals(0, calendar.getFirstVisibleHourOfDay()); + assertEquals(23, calendar.getLastVisibleHourOfDay()); start.set(java.util.Calendar.HOUR_OF_DAY, 5); end.set(java.util.Calendar.HOUR_OF_DAY, 21); @@ -411,8 +411,8 @@ public class ContainerDataSourceTest { calendar.beforeClientResponse(false); // simulate being attached calendar.autoScaleVisibleHoursOfDay(); - Assert.assertEquals(5, calendar.getFirstVisibleHourOfDay()); - Assert.assertEquals(21, calendar.getLastVisibleHourOfDay()); + assertEquals(5, calendar.getFirstVisibleHourOfDay()); + assertEquals(21, calendar.getLastVisibleHourOfDay()); } private static Indexed createTestBeanItemContainer() { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java index 84ab1edaa2..53cecb9904 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/calendar/ContainerEventProviderTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.tests.server.component.calendar; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Calendar; import java.util.Date; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.BeanItemContainer; @@ -35,7 +37,7 @@ public class ContainerEventProviderTest { @Test public void testDefaultAllDayProperty() { ContainerEventProvider provider = new ContainerEventProvider(null); - Assert.assertEquals(ContainerEventProvider.ALL_DAY_PROPERTY, + assertEquals(ContainerEventProvider.ALL_DAY_PROPERTY, provider.getAllDayProperty()); } @@ -45,7 +47,7 @@ public class ContainerEventProviderTest { ContainerEventProvider provider = new ContainerEventProvider(null); Object prop = new Object(); provider.setAllDayProperty(prop); - Assert.assertEquals(prop, provider.getAllDayProperty()); + assertEquals(prop, provider.getAllDayProperty()); } @Test @@ -57,7 +59,7 @@ public class ContainerEventProviderTest { ContainerEventProvider provider = new ContainerEventProvider(container); List<CalendarEvent> events = provider.getEvents(bean.getStart(), bean.getEnd()); - Assert.assertTrue(events.get(0).isAllDay()); + assertTrue(events.get(0).isAllDay()); } public static class EventBean { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java index 83febabf43..d5276af153 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/combobox/ComboBoxStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.combobox.ComboBoxState; @@ -30,7 +31,7 @@ public class ComboBoxStateTest { public void getState_comboboxHasCustomState() { TestComboBox combobox = new TestComboBox(); ComboBoxState state = combobox.getState(); - Assert.assertEquals("Unexpected state class", ComboBoxState.class, + assertEquals("Unexpected state class", ComboBoxState.class, state.getClass()); } @@ -38,14 +39,14 @@ public class ComboBoxStateTest { public void getPrimaryStyleName_comboboxHasCustomPrimaryStyleName() { ComboBox combobox = new ComboBox(); ComboBoxState state = new ComboBoxState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, combobox.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + combobox.getPrimaryStyleName()); } @Test public void comboboxStateHasCustomPrimaryStyleName() { ComboBoxState state = new ComboBoxState(); - Assert.assertEquals("Unexpected primary style name", "v-filterselect", + assertEquals("Unexpected primary style name", "v-filterselect", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java index 29eaf13e70..72cb590076 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/BeanFieldGroupTest.java @@ -1,8 +1,8 @@ package com.vaadin.v7.tests.server.component.fieldgroup; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; -import org.junit.Assert; import org.junit.Test; import com.vaadin.annotations.PropertyId; @@ -88,13 +88,13 @@ public class BeanFieldGroupTest { .bindFieldsUnbuffered(myBean, viewStub); Field<String> field = (Field<String>) bindFields.getField("basicField"); - Assert.assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); + assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); field.setValue("Foo"); - Assert.assertEquals("Foo", myBean.basicField); + assertEquals("Foo", myBean.basicField); field = (Field<String>) bindFields.getField("anotherField"); field.setValue("Foo"); - Assert.assertEquals("Foo", myBean.anotherField); + assertEquals("Foo", myBean.anotherField); } @SuppressWarnings("unchecked") @@ -109,17 +109,17 @@ public class BeanFieldGroupTest { Field<String> basicField = (Field<String>) bindFields .getField("basicField"); basicField.setValue("Foo"); - Assert.assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); + assertEquals(DEFAULT_FOR_BASIC_FIELD, myBean.basicField); Field<String> anotherField = (Field<String>) bindFields .getField("anotherField"); anotherField.setValue("Foo"); - Assert.assertNull(myBean.anotherField); + assertNull(myBean.anotherField); bindFields.commit(); - Assert.assertEquals("Foo", myBean.basicField); - Assert.assertEquals("Foo", myBean.anotherField); + assertEquals("Foo", myBean.basicField); + assertEquals("Foo", myBean.anotherField); } @@ -156,7 +156,7 @@ public class BeanFieldGroupTest { group.setItemDataSource((MyBean) null); BeanItem<MyBean> dataSource = group.getItemDataSource(); - Assert.assertNull("Data source is null for null bean", dataSource); + assertNull("Data source is null for null bean", dataSource); } @Test @@ -165,7 +165,7 @@ public class BeanFieldGroupTest { group.setItemDataSource((Item) null); BeanItem<MyBean> dataSource = group.getItemDataSource(); - Assert.assertNull("Group returns not null data source", dataSource); + assertNull("Group returns not null data source", dataSource); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java index bd44a18c1a..bfb079566a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/fieldgroup/FieldGroupTest.java @@ -15,6 +15,11 @@ */ package com.vaadin.v7.tests.server.component.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -22,7 +27,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Item; @@ -51,7 +55,7 @@ public class FieldGroupTest { fieldGroup.setReadOnly(true); - Assert.assertTrue("Field is not read only", field.isReadOnly()); + assertTrue("Field is not read only", field.isReadOnly()); } @Test @@ -63,7 +67,7 @@ public class FieldGroupTest { fieldGroup.setReadOnly(false); - Assert.assertFalse("Field is not writable", field.isReadOnly()); + assertFalse("Field is not writable", field.isReadOnly()); } @Test @@ -86,7 +90,7 @@ public class FieldGroupTest { try { fieldGroup.commit(); - Assert.fail("No commit exception is thrown"); + fail("No commit exception is thrown"); } catch (CommitException exception) { Map<Field<?>, ? extends InvalidValueException> invalidFields = exception .getInvalidFields(); @@ -94,10 +98,9 @@ public class FieldGroupTest { .entrySet()) { set.remove(entry.getKey()); } - Assert.assertEquals( - "Some fields are not found in the invalid fields map", 0, - set.size()); - Assert.assertEquals( + assertEquals("Some fields are not found in the invalid fields map", + 0, set.size()); + assertEquals( "Invalid value exception should be thrown for each field", 2, invalidFields.size()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java index 0b30afbe0c..c5372bbd75 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/form/FormTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.server.component.form; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.ui.Form; @@ -60,9 +62,9 @@ public class FormTest { form.addField("b", field2); form.focus(); - Assert.assertTrue("Field with enabled connector is not focused", + assertTrue("Field with enabled connector is not focused", secondFieldIsFocused[0]); - Assert.assertFalse("Field with disabled connector is focused", + assertFalse("Field with disabled connector is focused", firstFieldIsFocused[0]); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java index f9f7d8e3c8..a98c3b6319 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridAddRowBuiltinContainerTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.server.component.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Before; import org.junit.Test; @@ -42,12 +44,12 @@ public class GridAddRowBuiltinContainerTest { public void testSimpleCase() { Object itemId = grid.addRow("Hello"); - Assert.assertEquals(Integer.valueOf(1), itemId); + assertEquals(Integer.valueOf(1), itemId); - Assert.assertEquals("There should be one item in the container", 1, + assertEquals("There should be one item in the container", 1, container.size()); - Assert.assertEquals("Hello", container.getItem(itemId) + assertEquals("Hello", container.getItem(itemId) .getItemProperty("myColumn").getValue()); } @@ -62,8 +64,8 @@ public class GridAddRowBuiltinContainerTest { // cast to Object to distinguish from a null varargs array Object itemId = grid.addRow((Object) null); - Assert.assertEquals(null, container.getItem(itemId) - .getItemProperty("myColumn").getValue()); + assertEquals(null, container.getItem(itemId).getItemProperty("myColumn") + .getValue()); } @Test(expected = IllegalArgumentException.class) @@ -78,9 +80,8 @@ public class GridAddRowBuiltinContainerTest { Object itemId = grid.addRow("Hello", Integer.valueOf(3)); Item item = container.getItem(itemId); - Assert.assertEquals("Hello", - item.getItemProperty("myColumn").getValue()); - Assert.assertEquals(Integer.valueOf(3), + assertEquals("Hello", item.getItemProperty("myColumn").getValue()); + assertEquals(Integer.valueOf(3), item.getItemProperty("myOther").getValue()); } @@ -97,9 +98,9 @@ public class GridAddRowBuiltinContainerTest { grid.addRow(Integer.valueOf(3)); Item item = container.getItem(Integer.valueOf(1)); - Assert.assertEquals("Default value should be used for removed column", - "", item.getItemProperty("myColumn").getValue()); - Assert.assertEquals(Integer.valueOf(3), + assertEquals("Default value should be used for removed column", "", + item.getItemProperty("myColumn").getValue()); + assertEquals(Integer.valueOf(3), item.getItemProperty("myOther").getValue()); } @@ -112,9 +113,8 @@ public class GridAddRowBuiltinContainerTest { grid.addRow(Integer.valueOf(3), "Hello"); Item item = container.getItem(Integer.valueOf(1)); - Assert.assertEquals("Hello", - item.getItemProperty("myColumn").getValue()); - Assert.assertEquals(Integer.valueOf(3), + assertEquals("Hello", item.getItemProperty("myColumn").getValue()); + assertEquals(Integer.valueOf(3), item.getItemProperty("myOther").getValue()); } @@ -125,10 +125,9 @@ public class GridAddRowBuiltinContainerTest { // Can't use @Test(expect = Foo.class) since we also want to verify // state after exception was thrown - Assert.fail("Adding wrong type should throw ClassCastException"); + fail("Adding wrong type should throw ClassCastException"); } catch (IllegalArgumentException e) { - Assert.assertEquals("No row should have been added", 0, - container.size()); + assertEquals("No row should have been added", 0, container.size()); } } @@ -141,11 +140,9 @@ public class GridAddRowBuiltinContainerTest { // Can't use @Test(expect = Foo.class) since we also want to verify // state after exception was thrown - Assert.fail( - "Adding to BeanItemContainer container should throw UnsupportedOperationException"); + fail("Adding to BeanItemContainer container should throw UnsupportedOperationException"); } catch (UnsupportedOperationException e) { - Assert.assertEquals("No row should have been added", 0, - container.size()); + assertEquals("No row should have been added", 0, container.size()); } } @@ -164,9 +161,9 @@ public class GridAddRowBuiltinContainerTest { grid.addRow("name"); - Assert.assertEquals(1, container.size()); + assertEquals(1, container.size()); - Assert.assertEquals("name", container.getIdByIndex(0).getFirstName()); + assertEquals("name", container.getIdByIndex(0).getFirstName()); } @Test @@ -197,12 +194,12 @@ public class GridAddRowBuiltinContainerTest { // Can't use @Test(expect = Foo.class) since we also want to verify // state after exception was thrown - Assert.fail("Adding row should throw MethodException"); + fail("Adding row should throw MethodException"); } catch (MethodException e) { - Assert.assertEquals("Got the wrong exception", "name", + assertEquals("Got the wrong exception", "name", e.getCause().getMessage()); - Assert.assertEquals("There should be no rows in the container", 0, + assertEquals("There should be no rows in the container", 0, container.size()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java index 4cee00af63..9e8da734e2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridContainerTest.java @@ -15,11 +15,14 @@ */ package com.vaadin.v7.tests.server.component.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Component; @@ -54,7 +57,7 @@ public class GridContainerTest { grid.setContainerDataSource(createContainer()); - Assert.assertEquals("DetailsGenerator changed", detGen, + assertEquals("DetailsGenerator changed", detGen, grid.getDetailsGenerator()); } @@ -91,9 +94,9 @@ public class GridContainerTest { grid.setContainerDataSource(ic); grid.setColumns("foo", "baz", "bar"); - Assert.assertEquals("foo", grid.getColumns().get(0).getPropertyId()); - Assert.assertEquals("baz", grid.getColumns().get(1).getPropertyId()); - Assert.assertEquals("bar", grid.getColumns().get(2).getPropertyId()); + assertEquals("foo", grid.getColumns().get(0).getPropertyId()); + assertEquals("baz", grid.getColumns().get(1).getPropertyId()); + assertEquals("bar", grid.getColumns().get(2).getPropertyId()); } @Test @@ -102,11 +105,10 @@ public class GridContainerTest { grid.setContainerDataSource(new IndexedContainer()); try { grid.addColumn("notInContainer"); - Assert.fail( - "Adding a property id not in the container should throw an exception"); + fail("Adding a property id not in the container should throw an exception"); } catch (IllegalStateException e) { - Assert.assertTrue(e.getMessage().contains("notInContainer")); - Assert.assertTrue( + assertTrue(e.getMessage().contains("notInContainer")); + assertTrue( e.getMessage().contains("does not exist in the container")); } } @@ -117,13 +119,12 @@ public class GridContainerTest { grid.setContainerDataSource(new IndexedContainer()); try { grid.setColumns("notInContainer", "notThereEither"); - Assert.fail( - "Setting columns for property ids not in the container should throw an exception"); + fail("Setting columns for property ids not in the container should throw an exception"); } catch (IllegalStateException e) { // addColumn is run in random order.. - Assert.assertTrue(e.getMessage().contains("notInContainer") + assertTrue(e.getMessage().contains("notInContainer") || e.getMessage().contains("notThereEither")); - Assert.assertTrue( + assertTrue( e.getMessage().contains("does not exist in the container")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java index cc72df39ab..99a0545fe8 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridEditorTest.java @@ -21,12 +21,12 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Method; import org.easymock.EasyMock; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -171,8 +171,7 @@ public class GridEditorTest { // Manual fail instead of @Test(expected=...) to check it is // saveEditor that fails and not setValue grid.saveEditor(); - Assert.fail( - "CommitException expected when saving an invalid field value"); + fail("CommitException expected when saving an invalid field value"); } catch (CommitException e) { // expected } @@ -279,7 +278,7 @@ public class GridEditorTest { try { doEditMethod.invoke(grid); } catch (Exception e) { - Assert.fail("Editing item " + ITEM_ID + " failed. Cause: " + fail("Editing item " + ITEM_ID + " failed. Cause: " + e.getCause().toString()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java index 2421e8d07a..e02d7c5286 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridSelectionTest.java @@ -379,7 +379,7 @@ public class GridSelectionTest { @Test public void selectionChangeEventWhenChangingSelectionModeSingleToNone() { grid.select(itemId1Present); - Assert.assertEquals(itemId1Present, grid.getSelectedRow()); + assertEquals(itemId1Present, grid.getSelectedRow()); mockListener.clearEvent(); grid.setSelectionMode(SelectionMode.NONE); assertTrue(mockListener.eventHasHappened()); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java index b9ae44301b..978e05a73e 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/GridStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.grid.GridState; @@ -31,14 +32,14 @@ public class GridStateTest { public void getPrimaryStyleName_gridHasCustomPrimaryStyleName() { Grid grid = new Grid(); GridState state = new GridState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, grid.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + grid.getPrimaryStyleName()); } @Test public void gridStateHasCustomPrimaryStyleName() { GridState state = new GridState(); - Assert.assertEquals("Unexpected primary style name", "v-grid", + assertEquals("Unexpected primary style name", "v-grid", state.primaryStyleName); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java index 6e43eb2b85..c75b89816c 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java @@ -1,6 +1,9 @@ package com.vaadin.v7.tests.server.component.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.server.ServerRpcManager.RpcInvocationException; @@ -63,21 +66,21 @@ public class ItemSetChangeDuringEditorCommit { .setValue("New last"); grid.saveEditor(); - Assert.assertEquals("New first", indexedContainer + assertEquals("New first", indexedContainer .getContainerProperty(grid.getEditedItemId(), "firstName") .getValue()); - Assert.assertEquals("New last", indexedContainer + assertEquals("New last", indexedContainer .getContainerProperty(grid.getEditedItemId(), "lastName") .getValue()); grid.cancelEditor(); - Assert.assertFalse(grid.isEditorActive()); + assertFalse(grid.isEditorActive()); editItem(grid, 0); - Assert.assertEquals("New first", + assertEquals("New first", ((TextField) grid.getEditorFieldGroup().getField("firstName")) .getValue()); - Assert.assertEquals("New last", + assertEquals("New last", ((TextField) grid.getEditorFieldGroup().getField("lastName")) .getValue()); saveEditor(grid, 0); @@ -90,7 +93,7 @@ public class ItemSetChangeDuringEditorCommit { invocation.setParameters(new Object[] { itemIndex }); grid.getRpcManager(EditorServerRpc.class.getName()) .applyInvocation(invocation); - Assert.assertTrue(grid.isEditorActive()); + assertTrue(grid.isEditorActive()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java index 7840b1f246..1031ad8b5a 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java @@ -15,13 +15,16 @@ */ package com.vaadin.v7.tests.server.component.grid; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,9 +73,9 @@ public class MultiSelectionModelTest { @After public void tearDown() { - Assert.assertFalse("Some expected select event did not happen.", + assertFalse("Some expected select event did not happen.", expectingEvent); - Assert.assertFalse("Some expected deselect event did not happen.", + assertFalse("Some expected deselect event did not happen.", expectingDeselectEvent); } @@ -118,13 +121,13 @@ public class MultiSelectionModelTest { @Test public void testSelectAllWithoutItems() throws Throwable { - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); dataSource.removeAllItems(); - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); model.select(); - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); model.deselect(); - Assert.assertFalse(model.getState().allSelected); + assertFalse(model.getState().allSelected); } @Test @@ -165,15 +168,15 @@ public class MultiSelectionModelTest { @Override public void select(SelectionEvent event) { - Assert.assertTrue("Selection did not contain expected items", + assertTrue("Selection did not contain expected items", event.getAdded().containsAll(select)); - Assert.assertTrue("Selection contained unexpected items", + assertTrue("Selection contained unexpected items", select.containsAll(event.getAdded())); select = new ArrayList<Object>(); - Assert.assertTrue("Deselection did not contain expected items", + assertTrue("Deselection did not contain expected items", event.getRemoved().containsAll(deselect)); - Assert.assertTrue("Deselection contained unexpected items", + assertTrue("Deselection contained unexpected items", deselect.containsAll(event.getRemoved())); deselect = new ArrayList<Object>(); @@ -189,7 +192,7 @@ public class MultiSelectionModelTest { && selected.containsAll(model.getSelectedRows())) { return; } - Assert.fail("Not all items were correctly selected"); + fail("Not all items were correctly selected"); } @Test(expected = IllegalStateException.class) diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java index 91d537824c..7a115c42ff 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java @@ -15,8 +15,10 @@ */ package com.vaadin.v7.tests.server.component.grid; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -53,8 +55,7 @@ public class SingleSelectionModelTest { @After public void tearDown() { - Assert.assertFalse("Some expected event did not happen.", - expectingEvent); + assertFalse("Some expected event did not happen.", expectingEvent); } private IndexedContainer createDataSource() { @@ -116,7 +117,7 @@ public class SingleSelectionModelTest { } catch (Exception e) { throw e.getCause(); } - Assert.assertTrue("Should still wait for event", expectingEvent); + assertTrue("Should still wait for event", expectingEvent); expectingEvent = false; } @@ -132,19 +133,18 @@ public class SingleSelectionModelTest { @Override public void select(SelectionEvent event) { if (selected != null) { - Assert.assertTrue("Selection did not contain expected item", + assertTrue("Selection did not contain expected item", event.getAdded().contains(selected)); } else { - Assert.assertTrue("Unexpected selection", + assertTrue("Unexpected selection", event.getAdded().isEmpty()); } if (deselected != null) { - Assert.assertTrue( - "DeSelection did not contain expected item", + assertTrue("DeSelection did not contain expected item", event.getRemoved().contains(deselected)); } else { - Assert.assertTrue("Unexpected selection", + assertTrue("Unexpected selection", event.getRemoved().isEmpty()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java index 71a0c7987e..a01e8dadce 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridDeclarativeTestBase.java @@ -54,14 +54,14 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { } private void compareHeaders(Grid expected, Grid actual) { - Assert.assertEquals("Different header row count", + assertEquals("Different header row count", expected.getHeaderRowCount(), actual.getHeaderRowCount()); for (int i = 0; i < expected.getHeaderRowCount(); ++i) { HeaderRow expectedRow = expected.getHeaderRow(i); HeaderRow actualRow = actual.getHeaderRow(i); if (expectedRow.equals(expected.getDefaultHeaderRow())) { - Assert.assertEquals("Different index for default header row", + assertEquals("Different index for default header row", actual.getDefaultHeaderRow(), actualRow); } @@ -74,11 +74,11 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { switch (expectedCell.getCellType()) { case TEXT: - Assert.assertEquals(baseError + "Text content", + assertEquals(baseError + "Text content", expectedCell.getText(), actualCell.getText()); break; case HTML: - Assert.assertEquals(baseError + "HTML content", + assertEquals(baseError + "HTML content", expectedCell.getHtml(), actualCell.getHtml()); break; case WIDGET: @@ -92,7 +92,7 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { } private void compareFooters(Grid expected, Grid actual) { - Assert.assertEquals("Different footer row count", + assertEquals("Different footer row count", expected.getFooterRowCount(), actual.getFooterRowCount()); for (int i = 0; i < expected.getFooterRowCount(); ++i) { FooterRow expectedRow = expected.getFooterRow(i); @@ -107,11 +107,11 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { switch (expectedCell.getCellType()) { case TEXT: - Assert.assertEquals(baseError + "Text content", + assertEquals(baseError + "Text content", expectedCell.getText(), actualCell.getText()); break; case HTML: - Assert.assertEquals(baseError + "HTML content", + assertEquals(baseError + "HTML content", expectedCell.getHtml(), actualCell.getHtml()); break; case WIDGET: @@ -127,7 +127,7 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { private void compareGridColumns(Grid expected, Grid actual) { List<Column> columns = expected.getColumns(); List<Column> actualColumns = actual.getColumns(); - Assert.assertEquals("Different amount of columns", columns.size(), + assertEquals("Different amount of columns", columns.size(), actualColumns.size()); for (int i = 0; i < columns.size(); ++i) { Column col1 = columns.get(i); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java index 064627ade1..87159d0024 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridHeaderFooterDeclarativeTest.java @@ -307,8 +307,8 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { String actualFooter = grid.getFooterRow(0).getCell("> test").getText(); String expected = "> Test"; - Assert.assertEquals(expected, actualHeader); - Assert.assertEquals(expected, actualFooter); + assertEquals(expected, actualHeader); + assertEquals(expected, actualFooter); design = design.replace("plain-text=\"true\"", ""); grid = read(design); @@ -316,8 +316,8 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { actualFooter = grid.getFooterRow(0).getCell("> test").getHtml(); expected = "> Test"; - Assert.assertEquals(expected, actualHeader); - Assert.assertEquals(expected, actualFooter); + assertEquals(expected, actualHeader); + assertEquals(expected, actualFooter); grid = new Grid(); grid.setColumns("test"); @@ -332,9 +332,9 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { Element root = new Element(Tag.valueOf("vaadin7-grid"), ""); grid.writeDesign(root, new DesignContext()); - Assert.assertEquals("&amp; Test", + assertEquals("&amp; Test", root.getElementsByTag("th").get(0).html()); - Assert.assertEquals("&amp; Test", + assertEquals("&amp; Test", root.getElementsByTag("td").get(0).html()); header = grid.addHeaderRowAt(0); @@ -347,9 +347,9 @@ public class GridHeaderFooterDeclarativeTest extends GridDeclarativeTestBase { root = new Element(Tag.valueOf("vaadin7-grid"), ""); grid.writeDesign(root, new DesignContext()); - Assert.assertEquals("& Test", + assertEquals("& Test", root.getElementsByTag("th").get(0).html()); - Assert.assertEquals("& Test", + assertEquals("& Test", root.getElementsByTag("td").get(0).html()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java index 63eb1e7a66..d5ac086d46 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java @@ -117,7 +117,7 @@ public class GridInlineDataDeclarativeTest extends GridDeclarativeTestBase { Grid read = read(design); Container cds = read.getContainerDataSource(); - Assert.assertEquals("&Test", + assertEquals("&Test", cds.getItem(cds.getItemIds().iterator().next()) .getItemProperty("test").getValue()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java index cc209c025e..5fd9096d52 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/sort/SortTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.tests.server.component.grid.sort; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -41,17 +43,15 @@ public class SortTest { @Override public void sort(Object[] propertyId, boolean[] ascending) { - Assert.assertEquals( - "Different amount of expected and actual properties,", + assertEquals("Different amount of expected and actual properties,", expectedProperties.length, propertyId.length); - Assert.assertEquals( - "Different amount of expected and actual directions", + assertEquals("Different amount of expected and actual directions", expectedAscending.length, ascending.length); for (int i = 0; i < propertyId.length; ++i) { - Assert.assertEquals("Sorting properties differ", - expectedProperties[i], propertyId[i]); - Assert.assertEquals("Sorting directions differ", - expectedAscending[i], ascending[i]); + assertEquals("Sorting properties differ", expectedProperties[i], + propertyId[i]); + assertEquals("Sorting directions differ", expectedAscending[i], + ascending[i]); } sorted = true; } @@ -83,7 +83,7 @@ public class SortTest { } public void assertEventFired(SortOrder... expectedOrder) { - Assert.assertEquals(Arrays.asList(expectedOrder), order); + assertEquals(Arrays.asList(expectedOrder), order); // Reset for nest test order = null; @@ -108,7 +108,7 @@ public class SortTest { @After public void tearDown() { - Assert.assertTrue("Container was not sorted after the test.", + assertTrue("Container was not sorted after the test.", container.isSorted()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java index d9e31e6bc1..472e514cc2 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/listselect/ListSelectStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.listselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.select.AbstractSelectState; @@ -31,7 +32,7 @@ public class ListSelectStateTest { public void getState_listSelectHasCustomState() { TestListSelect select = new TestListSelect(); AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + assertEquals("Unexpected state class", AbstractSelectState.class, state.getClass()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java index 85aff22711..ca47df9617 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/optiongroup/OptionGroupStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.optiongroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.optiongroup.OptionGroupState; @@ -31,7 +32,7 @@ public class OptionGroupStateTest { public void getState_optionGroupHasCustomState() { TestOptionGroup group = new TestOptionGroup(); OptionGroupState state = group.getState(); - Assert.assertEquals("Unexpected state class", OptionGroupState.class, + assertEquals("Unexpected state class", OptionGroupState.class, state.getClass()); } @@ -39,15 +40,15 @@ public class OptionGroupStateTest { public void getPrimaryStyleName_optionGroupHasCustomPrimaryStyleName() { OptionGroup layout = new OptionGroup(); OptionGroupState state = new OptionGroupState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, layout.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + layout.getPrimaryStyleName()); } @Test public void optionGroupStateHasCustomPrimaryStyleName() { OptionGroupState state = new OptionGroupState(); - Assert.assertEquals("Unexpected primary style name", - "v-select-optiongroup", state.primaryStyleName); + assertEquals("Unexpected primary style name", "v-select-optiongroup", + state.primaryStyleName); } private static class TestOptionGroup extends OptionGroup { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java index 131dfa329b..9c0db8a7dc 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/richtextarea/RichTextAreaStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.richtextarea; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.textarea.RichTextAreaState; @@ -30,7 +31,7 @@ public class RichTextAreaStateTest { public void getState_areaHasCustomState() { TestRichTextArea area = new TestRichTextArea(); RichTextAreaState state = area.getState(); - Assert.assertEquals("Unexpected state class", RichTextAreaState.class, + assertEquals("Unexpected state class", RichTextAreaState.class, state.getClass()); } @@ -38,14 +39,14 @@ public class RichTextAreaStateTest { public void getPrimaryStyleName_areaHasCustomPrimaryStyleName() { RichTextArea area = new RichTextArea(); RichTextAreaState state = new RichTextAreaState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, area.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + area.getPrimaryStyleName()); } @Test public void areaStateHasCustomPrimaryStyleName() { RichTextAreaState state = new RichTextAreaState(); - Assert.assertEquals("Unexpected primary style name", "v-richtextarea", + assertEquals("Unexpected primary style name", "v-richtextarea", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java index ee3afb1268..3282124ef9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/CacheUpdateExceptionCausesTest.java @@ -16,7 +16,9 @@ package com.vaadin.v7.tests.server.component.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import org.junit.Test; import com.vaadin.v7.ui.Table; @@ -26,29 +28,27 @@ public class CacheUpdateExceptionCausesTest { @Test public void testSingleCauseException() { Table table = new Table(); - Throwable[] causes = { - new RuntimeException("Broken in one way.") }; + Throwable[] causes = { new RuntimeException("Broken in one way.") }; CacheUpdateException exception = new CacheUpdateException(table, "Error during Table cache update.", causes); - Assert.assertSame(causes[0], exception.getCause()); - Assert.assertEquals("Error during Table cache update.", + assertSame(causes[0], exception.getCause()); + assertEquals("Error during Table cache update.", exception.getMessage()); } @Test public void testMultipleCauseException() { Table table = new Table(); - Throwable[] causes = { - new RuntimeException("Broken in the first way."), + Throwable[] causes = { new RuntimeException("Broken in the first way."), new RuntimeException("Broken in the second way.") }; CacheUpdateException exception = new CacheUpdateException(table, "Error during Table cache update.", causes); - Assert.assertSame(causes[0], exception.getCause()); - Assert.assertEquals( + assertSame(causes[0], exception.getCause()); + assertEquals( "Error during Table cache update. Additional causes not shown.", exception.getMessage()); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java index 5f9f19f19d..8e345a1d0d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableContextClickTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.table; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.event.ContextClickEvent; @@ -49,9 +50,9 @@ public class TableContextClickTest extends Table { Section.BODY)); if (error != null) { - Assert.fail(error); + fail(error); } else if (!handled) { - Assert.fail("Event was not handled by the ContextClickListener"); + fail("Event was not handled by the ContextClickListener"); } } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java index a58aa0a1ec..28424b86d0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTest.java @@ -171,9 +171,9 @@ public class TableDeclarativeTest extends TableDeclarativeTestBase { + " </tfoot>" + "</table>" + "</vaadin7-table>"; Table read = read(design); - Assert.assertEquals("& Test", + assertEquals("& Test", read.getContainerProperty("test", "test").getValue()); - Assert.assertEquals("& Test", read.getColumnHeader("test")); - Assert.assertEquals("& Test", read.getColumnFooter("test")); + assertEquals("& Test", read.getColumnHeader("test")); + assertEquals("& Test", read.getColumnFooter("test")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java index 4e12ed84e0..18ef3c7f2b 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableSelectableTest.java @@ -15,8 +15,10 @@ */ package com.vaadin.v7.tests.server.component.table; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.Property.ValueChangeListener; @@ -34,7 +36,7 @@ public class TableSelectableTest { Table table = new Table(); table.setSelectable(true); - Assert.assertTrue(table.isSelectable()); + assertTrue(table.isSelectable()); } @Test @@ -43,15 +45,15 @@ public class TableSelectableTest { table.addValueChangeListener( EasyMock.createMock(ValueChangeListener.class)); - Assert.assertTrue(table.isSelectable()); - Assert.assertTrue(table.markAsDirtyCalled); + assertTrue(table.isSelectable()); + assertTrue(table.markAsDirtyCalled); } @Test public void tableIsNotSelectableByDefult() { Table table = new Table(); - Assert.assertFalse(table.isSelectable()); + assertFalse(table.isSelectable()); } @Test @@ -61,7 +63,7 @@ public class TableSelectableTest { table.addValueChangeListener( EasyMock.createMock(ValueChangeListener.class)); - Assert.assertFalse(table.isSelectable()); + assertFalse(table.isSelectable()); } private static final class TestTable extends Table { diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java index f61a027c0a..8f4a1a40bb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.table.TableState; @@ -31,7 +32,7 @@ public class TableStateTest { public void getState_tableHasCustomState() { TestTable table = new TestTable(); TableState state = table.getState(); - Assert.assertEquals("Unexpected state class", TableState.class, + assertEquals("Unexpected state class", TableState.class, state.getClass()); } @@ -39,14 +40,14 @@ public class TableStateTest { public void getPrimaryStyleName_tableHasCustomPrimaryStyleName() { Table table = new Table(); TableState state = new TableState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, table.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + table.getPrimaryStyleName()); } @Test public void tableStateHasCustomPrimaryStyleName() { TableState state = new TableState(); - Assert.assertEquals("Unexpected primary style name", "v-table", + assertEquals("Unexpected primary style name", "v-table", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java index 5d0e8e80e4..fac607f833 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textarea/TextAreaDeclarativeTest.java @@ -49,7 +49,7 @@ public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> { public void testHtmlEntities() throws IOException { String design = "<vaadin7-text-area>& Test</vaadin7-text-area>"; TextArea read = read(design); - Assert.assertEquals("& Test", read.getValue()); + assertEquals("& Test", read.getValue()); read.setValue("& Test"); @@ -57,7 +57,7 @@ public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> { Element root = new Element(Tag.valueOf("vaadin-text-area"), ""); read.writeDesign(root, dc); - Assert.assertEquals("&amp; Test", root.html()); + assertEquals("&amp; Test", root.html()); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java index 9b5d4ea0a1..d746c08cf5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.server.component.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -26,24 +28,24 @@ public class TextFieldTest { @Test public void initiallyEmpty() { TextField tf = new TextField(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClearUsingPDS() { TextField tf = new TextField(new ObjectProperty<String>("foo")); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClear() { TextField tf = new TextField(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java index 9a35dbeacd..4973f2a9d8 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/textfield/TextFieldValueChangeTest.java @@ -1,10 +1,12 @@ package com.vaadin.v7.tests.server.component.textfield; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.HashMap; import java.util.Map; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -75,7 +77,7 @@ public class TextFieldValueChangeTest // get value should not fire value change again Object value = getField().getValue(); - Assert.assertEquals("Foo", value); + assertEquals("Foo", value); // Ensure listener still has been called only once EasyMock.verify(getListener()); @@ -121,7 +123,7 @@ public class TextFieldValueChangeTest // field value should be different from the original value and current // proeprty value boolean isValueEqualToInitial = value.equals(initialValue); - Assert.assertTrue(isValueEqualToInitial); + assertTrue(isValueEqualToInitial); // Ensure listener still has been called only once EasyMock.verify(getListener()); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java index 4f4bdead4e..94f6847a0f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/tree/TreeTest.java @@ -148,7 +148,7 @@ public class TreeTest { public void getState_treeHasCustomState() { TestTree table = new TestTree(); TreeState state = table.getState(); - Assert.assertEquals("Unexpected state class", TreeState.class, + assertEquals("Unexpected state class", TreeState.class, state.getClass()); } @@ -156,14 +156,14 @@ public class TreeTest { public void getPrimaryStyleName_treeHasCustomPrimaryStyleName() { Tree table = new Tree(); TreeState state = new TreeState(); - Assert.assertEquals("Unexpected primary style name", + assertEquals("Unexpected primary style name", state.primaryStyleName, table.getPrimaryStyleName()); } @Test public void treeStateHasCustomPrimaryStyleName() { TreeState state = new TreeState(); - Assert.assertEquals("Unexpected primary style name", "v-tree", + assertEquals("Unexpected primary style name", "v-tree", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java index 302a42a8af..9339dbcedd 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableDeclarativeTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.treetable; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.ui.declarative.DesignException; @@ -125,7 +126,7 @@ public class TreeTableDeclarativeTest extends TableDeclarativeTest { try { read(design); - Assert.fail("Malformed hierarchy should fail: " + hierarchy); + fail("Malformed hierarchy should fail: " + hierarchy); } catch (DesignException expected) { } } @@ -135,10 +136,10 @@ public class TreeTableDeclarativeTest extends TableDeclarativeTest { super.compareBody(read, expected); for (Object itemId : read.getItemIds()) { - Assert.assertEquals("parent of item " + itemId, + assertEquals("parent of item " + itemId, ((TreeTable) expected).getParent(itemId), ((TreeTable) read).getParent(itemId)); - Assert.assertEquals("collapsed status of item " + itemId, + assertEquals("collapsed status of item " + itemId, ((TreeTable) expected).isCollapsed(itemId), ((TreeTable) read).isCollapsed(itemId)); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java index a0e0cc6c16..1f48ec8500 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/treetable/TreeTableTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.v7.tests.server.component.treetable; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.EnumSet; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.shared.ui.treetable.TreeTableState; @@ -36,7 +39,7 @@ public class TreeTableTest { TestTreeTable tree = new TestTreeTable(); tree.setRowHeaderMode(RowHeaderMode.ICON_ONLY); - Assert.assertFalse("Row headers are enabled for Icon header mode", + assertFalse("Row headers are enabled for Icon header mode", tree.rowHeadersAreEnabled()); } @@ -45,7 +48,7 @@ public class TreeTableTest { TestTreeTable tree = new TestTreeTable(); tree.setRowHeaderMode(RowHeaderMode.HIDDEN); - Assert.assertFalse("Row headers are enabled for Hidden header mode", + assertFalse("Row headers are enabled for Hidden header mode", tree.rowHeadersAreEnabled()); } @@ -58,8 +61,7 @@ public class TreeTableTest { for (RowHeaderMode mode : modes) { tree.setRowHeaderMode(mode); - Assert.assertTrue( - "Row headers are disabled for " + mode + " header mode", + assertTrue("Row headers are disabled for " + mode + " header mode", tree.rowHeadersAreEnabled()); } } @@ -68,7 +70,7 @@ public class TreeTableTest { public void getState_treeTableHasCustomState() { TestTreeTable table = new TestTreeTable(); TreeTableState state = table.getState(); - Assert.assertEquals("Unexpected state class", TreeTableState.class, + assertEquals("Unexpected state class", TreeTableState.class, state.getClass()); } @@ -76,14 +78,14 @@ public class TreeTableTest { public void getPrimaryStyleName_treeTableHasCustomPrimaryStyleName() { TreeTable table = new TreeTable(); TreeTableState state = new TreeTableState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, table.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + table.getPrimaryStyleName()); } @Test public void treeTableStateHasCustomPrimaryStyleName() { TreeTableState state = new TreeTableState(); - Assert.assertEquals("Unexpected primary style name", "v-table", + assertEquals("Unexpected primary style name", "v-table", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java index d2498d9160..f8b40d5b57 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/twincolselect/TwinColSelectStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.server.component.twincolselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.v7.shared.ui.twincolselect.TwinColSelectState; @@ -31,7 +32,7 @@ public class TwinColSelectStateTest { public void getState_selectHasCustomState() { TestTwinColSelect select = new TestTwinColSelect(); TwinColSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", TwinColSelectState.class, + assertEquals("Unexpected state class", TwinColSelectState.class, state.getClass()); } @@ -39,14 +40,14 @@ public class TwinColSelectStateTest { public void getPrimaryStyleName_selectHasCustomPrimaryStyleName() { TwinColSelect table = new TwinColSelect(); TwinColSelectState state = new TwinColSelectState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, table.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + table.getPrimaryStyleName()); } @Test public void selectStateHasCustomPrimaryStyleName() { TwinColSelectState state = new TwinColSelectState(); - Assert.assertEquals("Unexpected primary style name", "v-select-twincol", + assertEquals("Unexpected primary style name", "v-select-twincol", state.primaryStyleName); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java index a16729da03..992fe09e92 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/validation/BeanValidationTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.server.validation; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.data.bean.BeanToValidate; @@ -70,7 +71,7 @@ public class BeanValidationTest { causes = e.getCauses(); } - Assert.assertEquals(1, causes.length); + assertEquals(1, causes.length); } @Test @@ -84,7 +85,7 @@ public class BeanValidationTest { causes = e.getCauses(); } - Assert.assertEquals(2, causes.length); + assertEquals(2, causes.length); } @Test @@ -98,14 +99,14 @@ public class BeanValidationTest { fieldGroup.setItemDataSource(beanToValidate); Field<?> nameField = fieldGroup.buildAndBind("firstname"); - Assert.assertEquals(1, nameField.getValidators().size()); + assertEquals(1, nameField.getValidators().size()); try { nameField.validate(); } catch (InvalidValueException e) { // The 1 cause is from BeanValidator, where it tells what failed // 1 validation exception never gets wrapped. - Assert.assertEquals(1, e.getCauses().length); + assertEquals(1, e.getCauses().length); } // Create new, identical bean to cause duplicate validator unless #11045 @@ -114,14 +115,14 @@ public class BeanValidationTest { beanToValidate.setFirstname("a"); fieldGroup.setItemDataSource(beanToValidate); - Assert.assertEquals(1, nameField.getValidators().size()); + assertEquals(1, nameField.getValidators().size()); try { nameField.validate(); } catch (InvalidValueException e) { // The 1 cause is from BeanValidator, where it tells what failed // 1 validation exception never gets wrapped. - Assert.assertEquals(1, e.getCauses().length); + assertEquals(1, e.getCauses().length); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java index 635ba4e0e2..f90e10066d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/AbsSelectTest.java @@ -15,11 +15,15 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -30,8 +34,8 @@ public class AbsSelectTest { public void addItemsStrings() { NativeSelect ns = new NativeSelect(); ns.addItems("Foo", "bar", "baz"); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { "Foo", "bar", "baz" }, ns.getItemIds().toArray()); } @@ -43,8 +47,8 @@ public class AbsSelectTest { NativeSelect ns = new NativeSelect(); ns.addItems(o1, o2, o3); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds().toArray()); } @@ -56,8 +60,8 @@ public class AbsSelectTest { itemIds.add("baz"); NativeSelect ns = new NativeSelect(); ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { "foo", "bar", "baz" }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { "foo", "bar", "baz" }, ns.getItemIds().toArray()); } @@ -72,8 +76,8 @@ public class AbsSelectTest { itemIds.add(o3); NativeSelect ns = new NativeSelect(); ns.addItems(itemIds); - Assert.assertEquals(3, ns.size()); - Assert.assertArrayEquals(new Object[] { o1, o2, o3 }, + assertEquals(3, ns.size()); + assertArrayEquals(new Object[] { o1, o2, o3 }, ns.getItemIds().toArray()); } @@ -81,7 +85,7 @@ public class AbsSelectTest { @Test public void singleSelectInitiallyEmpty() { AbstractSelect s = new ListSelect(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -91,9 +95,9 @@ public class AbsSelectTest { s.addItem("bar"); s.setPropertyDataSource(new ObjectProperty<String>("foo")); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -103,16 +107,16 @@ public class AbsSelectTest { s.addItem("bar"); s.setValue("bar"); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test public void multiSelectInitiallyEmpty() { AbstractSelect s = new ListSelect(); s.setMultiSelect(true); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -126,9 +130,9 @@ public class AbsSelectTest { sel.add("bar"); s.setPropertyDataSource(new ObjectProperty<HashSet>(sel)); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } @Test @@ -140,9 +144,9 @@ public class AbsSelectTest { s.select("foo"); s.select("bar"); - Assert.assertFalse(s.isEmpty()); + assertFalse(s.isEmpty()); s.clear(); - Assert.assertTrue(s.isEmpty()); + assertTrue(s.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java index 16f7eb2423..05be3a35e3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/ComboBoxTest.java @@ -1,11 +1,12 @@ package com.vaadin.v7.ui; +import static org.junit.Assert.assertEquals; + import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -29,9 +30,9 @@ public class ComboBoxTest { } List<?> options = comboBox.getFilteredOptions(); - Assert.assertEquals(10, options.size()); + assertEquals(10, options.size()); for (int i = 0; i < 10; i++) { - Assert.assertEquals("" + i, options.get(i)); + assertEquals("" + i, options.get(i)); } } @@ -45,7 +46,7 @@ public class ComboBoxTest { setFilterAndCurrentPage(comboBox, "1", 0); List<?> options = comboBox.getFilteredOptions(); - Assert.assertEquals(11, options.size()); + assertEquals(11, options.size()); } @@ -58,7 +59,7 @@ public class ComboBoxTest { setFilterAndCurrentPage(comboBox, "2", 0); List<?> options = comboBox.getFilteredOptions(); - Assert.assertEquals(3, options.size()); + assertEquals(3, options.size()); } @@ -81,7 +82,7 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), false); - Assert.assertEquals(comboBox.getPageLength(), goingToClient.size()); + assertEquals(comboBox.getPageLength(), goingToClient.size()); } @@ -96,13 +97,13 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), true); // Null item is shown on first page - Assert.assertEquals(comboBox.getPageLength() - 1, goingToClient.size()); + assertEquals(comboBox.getPageLength() - 1, goingToClient.size()); setFilterAndCurrentPage(comboBox, "", 1); goingToClient = comboBox.sanitizeList(comboBox.getFilteredOptions(), true); // Null item is not shown on the second page - Assert.assertEquals(comboBox.getPageLength(), goingToClient.size()); + assertEquals(comboBox.getPageLength(), goingToClient.size()); } @@ -116,7 +117,7 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), false); - Assert.assertEquals(nrOptions, goingToClient.size()); + assertEquals(nrOptions, goingToClient.size()); } @@ -131,7 +132,7 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), true); // All items + null still fit on one page - Assert.assertEquals(nrOptions, goingToClient.size()); + assertEquals(nrOptions, goingToClient.size()); } @@ -146,13 +147,13 @@ public class ComboBoxTest { List<?> goingToClient = comboBox .sanitizeList(comboBox.getFilteredOptions(), true); // Null item on first page - Assert.assertEquals(nrOptions - 1, goingToClient.size()); + assertEquals(nrOptions - 1, goingToClient.size()); setFilterAndCurrentPage(comboBox, "", 1); goingToClient = comboBox.sanitizeList(comboBox.getFilteredOptions(), true); // All but one was on the first page - Assert.assertEquals(1, goingToClient.size()); + assertEquals(1, goingToClient.size()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java index 42d0d72867..e6b3554d92 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/LabelDataSourceTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -52,17 +54,17 @@ public class LabelDataSourceTest { @Test public void stringDataSource() { label.setPropertyDataSource(stringDataSource); - Assert.assertEquals(STRING_DS_VALUE, label.getState().text); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); - Assert.assertEquals(stringDataSource, label.getPropertyDataSource()); + assertEquals(STRING_DS_VALUE, label.getState().text); + assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(stringDataSource, label.getPropertyDataSource()); label.setPropertyDataSource(null); - Assert.assertEquals(STRING_DS_VALUE, label.getState().text); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); - Assert.assertEquals(null, label.getPropertyDataSource()); + assertEquals(STRING_DS_VALUE, label.getState().text); + assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(null, label.getPropertyDataSource()); label.setValue("foo"); - Assert.assertEquals("foo", label.getState().text); - Assert.assertEquals("foo", label.getValue()); - Assert.assertNull(label.getPropertyDataSource()); + assertEquals("foo", label.getState().text); + assertEquals("foo", label.getValue()); + assertNull(label.getPropertyDataSource()); } @@ -70,18 +72,18 @@ public class LabelDataSourceTest { public void integerDataSourceFi() { label.setLocale(new Locale("fi", "FI")); label.setPropertyDataSource(integerDataSource); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); - Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); + assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); + assertEquals(integerDataSource, label.getPropertyDataSource()); } @Test public void integerDataSourceEn() { label.setLocale(new Locale("en", "US")); label.setPropertyDataSource(integerDataSource); - Assert.assertEquals(INTEGER_STRING_VALUE_EN_US, label.getState().text); - Assert.assertEquals(INTEGER_STRING_VALUE_EN_US, label.getValue()); - Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); + assertEquals(INTEGER_STRING_VALUE_EN_US, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_EN_US, label.getValue()); + assertEquals(integerDataSource, label.getPropertyDataSource()); } @Test @@ -89,20 +91,20 @@ public class LabelDataSourceTest { label.setLocale(new Locale("en", "US")); label.setPropertyDataSource(integerDataSource); label.setLocale(new Locale("fi", "FI")); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); - Assert.assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); - Assert.assertEquals(integerDataSource, label.getPropertyDataSource()); + assertEquals(INTEGER_STRING_VALUE_FI, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_FI, label.getValue()); + assertEquals(integerDataSource, label.getPropertyDataSource()); } @Test public void setRemoveDataSource() { label.setValue("before"); label.setPropertyDataSource(stringDataSource); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(STRING_DS_VALUE, label.getValue()); label.setPropertyDataSource(null); - Assert.assertEquals(STRING_DS_VALUE, label.getValue()); + assertEquals(STRING_DS_VALUE, label.getValue()); label.setValue("after"); - Assert.assertEquals("after", label.getValue()); + assertEquals("after", label.getValue()); } @Test @@ -113,6 +115,6 @@ public class LabelDataSourceTest { UI ui = new MockUI(); ui.setLocale(Locale.GERMANY); ui.setContent(label); - Assert.assertEquals(INTEGER_STRING_VALUE_DE, label.getState().text); + assertEquals(INTEGER_STRING_VALUE_DE, label.getState().text); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java index 5accba796d..b592927e7d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/NativeSelectTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.Collections; -import org.junit.Assert; import org.junit.Test; import com.vaadin.v7.data.util.IndexedContainer; @@ -51,7 +53,7 @@ public class NativeSelectTest { public void getState_listSelectHasCustomState() { TestNativeSelect select = new TestNativeSelect(); AbstractSelectState state = select.getState(); - Assert.assertEquals("Unexpected state class", AbstractSelectState.class, + assertEquals("Unexpected state class", AbstractSelectState.class, state.getClass()); } @@ -63,7 +65,7 @@ public class NativeSelectTest { } private void assertFocusRpcRegistered(NativeSelect s) { - Assert.assertNotNull("RPC is not correctly registered", s.getRpcManager( + assertNotNull("RPC is not correctly registered", s.getRpcManager( "com.vaadin.shared.communication.FieldRpc$FocusAndBlurServerRpc")); } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java index 9d4bb9468e..e87cfe89e5 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/RichTextAreaTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -24,24 +26,24 @@ public class RichTextAreaTest { @Test public void initiallyEmpty() { RichTextArea tf = new RichTextArea(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClearUsingPDS() { RichTextArea tf = new RichTextArea(new ObjectProperty<String>("foo")); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClear() { RichTextArea tf = new RichTextArea(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java index 9683c82424..576bdfcce9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/TableTest.java @@ -15,9 +15,13 @@ */ package com.vaadin.v7.ui; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Collection; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -34,22 +38,22 @@ public class TableTest { @Test public void initiallyEmpty() { - Assert.assertTrue(table.isEmpty()); + assertTrue(table.isEmpty()); } @Test public void emptyAfterClearSingleSelect() { table.setContainerDataSource( BeanItemContainerGenerator.createContainer(100)); - Assert.assertTrue(table.isEmpty()); + assertTrue(table.isEmpty()); Object first = table.getContainerDataSource().getItemIds().iterator() .next(); table.setValue(first); - Assert.assertEquals(first, table.getValue()); - Assert.assertFalse(table.isEmpty()); + assertEquals(first, table.getValue()); + assertFalse(table.isEmpty()); table.clear(); - Assert.assertEquals(null, table.getValue()); - Assert.assertTrue(table.isEmpty()); + assertEquals(null, table.getValue()); + assertTrue(table.isEmpty()); } @Test @@ -58,21 +62,21 @@ public class TableTest { table.setContainerDataSource( BeanItemContainerGenerator.createContainer(100)); - Assert.assertTrue(table.isEmpty()); - Assert.assertArrayEquals(new Object[] {}, + assertTrue(table.isEmpty()); + assertArrayEquals(new Object[] {}, ((Collection) table.getValue()).toArray()); Object first = table.getContainerDataSource().getItemIds().iterator() .next(); table.select(first); - Assert.assertArrayEquals(new Object[] { first }, + assertArrayEquals(new Object[] { first }, ((Collection) table.getValue()).toArray()); - Assert.assertFalse(table.isEmpty()); + assertFalse(table.isEmpty()); table.clear(); - Assert.assertArrayEquals(new Object[] {}, + assertArrayEquals(new Object[] {}, ((Collection) table.getValue()).toArray()); - Assert.assertTrue(table.isEmpty()); + assertTrue(table.isEmpty()); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java b/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java index 23b6f9f593..4d0dd17a83 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/ui/TextAreaTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.v7.data.util.ObjectProperty; @@ -24,24 +26,24 @@ public class TextAreaTest { @Test public void initiallyEmpty() { TextArea tf = new TextArea(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClearUsingPDS() { TextArea tf = new TextArea(new ObjectProperty<String>("foo")); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test public void emptyAfterClear() { TextArea tf = new TextArea(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } diff --git a/server/src/test/java/com/vaadin/data/BeanBinderTest.java b/server/src/test/java/com/vaadin/data/BeanBinderTest.java index 35722405f7..45610754d5 100644 --- a/server/src/test/java/com/vaadin/data/BeanBinderTest.java +++ b/server/src/test/java/com/vaadin/data/BeanBinderTest.java @@ -1,7 +1,9 @@ package com.vaadin.data; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import java.io.Serializable; import java.time.LocalDate; @@ -14,7 +16,6 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.hibernate.validator.constraints.NotEmpty; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -410,7 +411,7 @@ public class BeanBinderTest binder.bind(field, "firstname"); binder.setBean(bean); - Assert.assertTrue(field.isRequiredIndicatorVisible()); + assertTrue(field.isRequiredIndicatorVisible()); testSerialization(binder); } @@ -424,7 +425,7 @@ public class BeanBinderTest binder.bind(field, "age"); binder.setBean(bean); - Assert.assertTrue(field.isRequiredIndicatorVisible()); + assertTrue(field.isRequiredIndicatorVisible()); testSerialization(binder); } @@ -438,7 +439,7 @@ public class BeanBinderTest binder.bind(field, "lastname"); binder.setBean(bean); - Assert.assertTrue(field.isRequiredIndicatorVisible()); + assertTrue(field.isRequiredIndicatorVisible()); testSerialization(binder); } @@ -453,7 +454,7 @@ public class BeanBinderTest binder.bind(field, "subfield.name"); binder.setBean(bean); - Assert.assertTrue(field.isRequiredIndicatorVisible()); + assertTrue(field.isRequiredIndicatorVisible()); testSerialization(binder); } @@ -470,7 +471,7 @@ public class BeanBinderTest binder.bind(field, "subfield.subsub.value"); binder.setBean(bean); - Assert.assertTrue(field.isRequiredIndicatorVisible()); + assertTrue(field.isRequiredIndicatorVisible()); testSerialization(binder); } @@ -484,9 +485,9 @@ public class BeanBinderTest RequiredConstraints bean = new RequiredConstraints(); bean.setSubfield(new SubConstraint()); binder.setBean(bean); - Assert.assertFalse(binder.validate().isOk()); + assertFalse(binder.validate().isOk()); field.setValue("overfive"); - Assert.assertTrue(binder.validate().isOk()); + assertTrue(binder.validate().isOk()); } @Test @@ -502,9 +503,9 @@ public class BeanBinderTest subfield.setSubsub(new SubSubConstraint()); binder.setBean(bean); - Assert.assertFalse(binder.validate().isOk()); + assertFalse(binder.validate().isOk()); field.setValue("overtencharacters"); - Assert.assertTrue(binder.validate().isOk()); + assertTrue(binder.validate().isOk()); } private void assertInvalid(HasValue<?> field, String message) { diff --git a/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java b/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java index c577db6067..7b492ad012 100644 --- a/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java +++ b/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java @@ -15,6 +15,10 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -26,7 +30,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.provider.bov.Person; @@ -45,8 +48,7 @@ public class BeanPropertySetTest { PropertySet<Person> deserializedPropertySet = ClassesSerializableTest .serializeAndDeserialize(originalPropertySet); - Assert.assertSame( - "Deserialized instance should be the same as the original", + assertSame("Deserialized instance should be the same as the original", originalPropertySet, deserializedPropertySet); } @@ -74,10 +76,9 @@ public class BeanPropertySetTest { PropertySet<Person> deserializedPropertySet = (PropertySet<Person>) in .readObject(); - Assert.assertSame( - "Deserialized instance should be the same as in the cache", + assertSame("Deserialized instance should be the same as in the cache", BeanPropertySet.get(Person.class), deserializedPropertySet); - Assert.assertNotSame( + assertNotSame( "Deserialized instance should not be the same as the original", originalPropertySet, deserializedPropertySet); } @@ -95,11 +96,10 @@ public class BeanPropertySetTest { Person person = new Person("Milennial", 2000); Integer age = (Integer) getter.apply(person); - Assert.assertEquals("Deserialized definition should be functional", + assertEquals("Deserialized definition should be functional", Integer.valueOf(2000), age); - Assert.assertSame( - "Deserialized instance should be the same as in the cache", + assertSame("Deserialized instance should be the same as in the cache", BeanPropertySet.get(Person.class).getProperty("born") .orElseThrow(RuntimeException::new), deserializedDefinition); @@ -125,11 +125,10 @@ public class BeanPropertySetTest { Integer postalCode = (Integer) getter.apply(person); - Assert.assertEquals("Deserialized definition should be functional", + assertEquals("Deserialized definition should be functional", address.getPostalCode(), postalCode); - Assert.assertSame( - "Deserialized instance should be the same as in the cache", + assertSame("Deserialized instance should be the same as in the cache", BeanPropertySet.get(com.vaadin.tests.data.bean.Person.class) .getProperty("address.postalCode").orElseThrow( RuntimeException::new), @@ -153,7 +152,7 @@ public class BeanPropertySetTest { String firstName = (String) getter.apply(son); - Assert.assertEquals(grandFather.getFirstName(), firstName); + assertEquals(grandFather.getFirstName(), firstName); } @Test(expected = NullPointerException.class) @@ -188,7 +187,7 @@ public class BeanPropertySetTest { Set<String> propertyNames = propertySet.getProperties() .map(PropertyDefinition::getName).collect(Collectors.toSet()); - Assert.assertEquals(new HashSet<>(Arrays.asList("name", "born")), + assertEquals(new HashSet<>(Arrays.asList("name", "born")), propertyNames); } } diff --git a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java index 89987d5f62..2d7c6631b0 100644 --- a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java +++ b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java @@ -15,6 +15,12 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.time.LocalDate; import java.util.List; import java.util.Locale; @@ -22,7 +28,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -186,16 +191,16 @@ public class BinderBookOfVaadinTest { field.setValue("not-email"); BinderValidationStatus<?> status = binder.validate(); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals("This doesn't look like a valid email address", + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals("This doesn't look like a valid email address", status.getFieldValidationErrors().get(0).getMessage().get()); - Assert.assertEquals("This doesn't look like a valid email address", + assertEquals("This doesn't look like a valid email address", ((AbstractErrorMessage) field.getErrorMessage()).getMessage()); field.setValue("abc@vaadin.com"); status = binder.validate(); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); - Assert.assertNull(field.getErrorMessage()); + assertEquals(0, status.getBeanValidationErrors().size()); + assertNull(field.getErrorMessage()); } @Test @@ -208,16 +213,16 @@ public class BinderBookOfVaadinTest { field.setValue("a"); BinderValidationStatus<?> status = binder.validate(); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals("Last name must contain at least three characters", + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals("Last name must contain at least three characters", status.getFieldValidationErrors().get(0).getMessage().get()); - Assert.assertEquals("Last name must contain at least three characters", + assertEquals("Last name must contain at least three characters", ((AbstractErrorMessage) field.getErrorMessage()).getMessage()); field.setValue("long last name"); status = binder.validate(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertNull(field.getErrorMessage()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertNull(field.getErrorMessage()); } @Test @@ -233,24 +238,24 @@ public class BinderBookOfVaadinTest { field.setValue("not-email"); BinderValidationStatus<?> status = binder.validate(); // Only one error per field should be reported - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals("This doesn't look like a valid email address", + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals("This doesn't look like a valid email address", status.getFieldValidationErrors().get(0).getMessage().get()); - Assert.assertEquals("This doesn't look like a valid email address", + assertEquals("This doesn't look like a valid email address", ((AbstractErrorMessage) field.getErrorMessage()).getMessage()); field.setValue("abc@vaadin.com"); status = binder.validate(); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals("Only acme.com email addresses are allowed", + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals("Only acme.com email addresses are allowed", status.getFieldValidationErrors().get(0).getMessage().get()); - Assert.assertEquals("Only acme.com email addresses are allowed", + assertEquals("Only acme.com email addresses are allowed", ((AbstractErrorMessage) field.getErrorMessage()).getMessage()); field.setValue("abc@acme.com"); status = binder.validate(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertNull(field.getErrorMessage()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertNull(field.getErrorMessage()); } @Test @@ -276,20 +281,20 @@ public class BinderBookOfVaadinTest { // Test that the book code works BookPerson bookPerson = new BookPerson(1972, 4); binder.setBean(bookPerson); - Assert.assertEquals(4.0, salaryLevelField.getValue().doubleValue(), 0); - Assert.assertEquals("1,972", yearOfBirthField.getValue()); + assertEquals(4.0, salaryLevelField.getValue().doubleValue(), 0); + assertEquals("1,972", yearOfBirthField.getValue()); bookPerson.setSalaryLevel(8); binder.readBean(bookPerson); - Assert.assertEquals(8.0, salaryLevelField.getValue().doubleValue(), 0); + assertEquals(8.0, salaryLevelField.getValue().doubleValue(), 0); bookPerson.setYearOfBirth(123); binder.readBean(bookPerson); - Assert.assertEquals("123", yearOfBirthField.getValue()); + assertEquals("123", yearOfBirthField.getValue()); yearOfBirthField.setValue("2016"); salaryLevelField.setValue(1.0); - Assert.assertEquals(2016, bookPerson.getYearOfBirth()); - Assert.assertEquals(1, bookPerson.getSalaryLevel()); + assertEquals(2016, bookPerson.getYearOfBirth()); + assertEquals(1, bookPerson.getSalaryLevel()); } @Test @@ -306,7 +311,7 @@ public class BinderBookOfVaadinTest { binder.setBean(new BookPerson(1900, 5)); yearOfBirthField.setValue("abc"); binder.validate(); - Assert.assertEquals("Please enter a number", + assertEquals("Please enter a number", yearOfBirthField.getComponentError().getFormattedHtmlMessage()); } @@ -333,33 +338,33 @@ public class BinderBookOfVaadinTest { returning.setValue(after); BinderValidationStatus<Trip> status = binder.validate(); - Assert.assertTrue(status.getBeanValidationErrors().isEmpty()); - Assert.assertNull(departing.getComponentError()); - Assert.assertNull(returning.getComponentError()); + assertTrue(status.getBeanValidationErrors().isEmpty()); + assertNull(departing.getComponentError()); + assertNull(returning.getComponentError()); // update returning => validation is done against this field returning.setValue(past); status = binder.validate(); - Assert.assertFalse(status.getFieldValidationErrors().isEmpty()); - Assert.assertNotNull(returning.getComponentError()); - Assert.assertNull(departing.getComponentError()); + assertFalse(status.getFieldValidationErrors().isEmpty()); + assertNotNull(returning.getComponentError()); + assertNull(departing.getComponentError()); // set correct value back returning.setValue(before); status = binder.validate(); - Assert.assertTrue(status.getFieldValidationErrors().isEmpty()); - Assert.assertNull(departing.getComponentError()); - Assert.assertNull(returning.getComponentError()); + assertTrue(status.getFieldValidationErrors().isEmpty()); + assertNull(departing.getComponentError()); + assertNull(returning.getComponentError()); // update departing => validation is done because of listener added departing.setValue(after); status = binder.validate(); - Assert.assertFalse(status.getFieldValidationErrors().isEmpty()); - Assert.assertNotNull(returning.getComponentError()); - Assert.assertNull(departing.getComponentError()); + assertFalse(status.getFieldValidationErrors().isEmpty()); + assertNotNull(returning.getComponentError()); + assertNull(departing.getComponentError()); } @@ -386,29 +391,29 @@ public class BinderBookOfVaadinTest { returning.setValue(after); BindingValidationStatus<LocalDate> result = returnBinding.validate(); - Assert.assertFalse(result.isError()); - Assert.assertNull(departing.getComponentError()); + assertFalse(result.isError()); + assertNull(departing.getComponentError()); // update returning => validation is done against this field returning.setValue(past); result = returnBinding.validate(); - Assert.assertTrue(result.isError()); - Assert.assertNotNull(returning.getComponentError()); + assertTrue(result.isError()); + assertNotNull(returning.getComponentError()); // set correct value back returning.setValue(before); result = returnBinding.validate(); - Assert.assertFalse(result.isError()); - Assert.assertNull(departing.getComponentError()); + assertFalse(result.isError()); + assertNull(departing.getComponentError()); // update departing => validation is done because of listener added departing.setValue(after); result = returnBinding.validate(); - Assert.assertTrue(result.isError()); - Assert.assertNotNull(returning.getComponentError()); + assertTrue(result.isError()); + assertNotNull(returning.getComponentError()); } @Test @@ -423,14 +428,14 @@ public class BinderBookOfVaadinTest { field.setValue("foo"); binder.validate(); - Assert.assertTrue(emailStatus.isVisible()); - Assert.assertEquals(msg, emailStatus.getValue()); + assertTrue(emailStatus.isVisible()); + assertEquals(msg, emailStatus.getValue()); field.setValue("foo@vaadin.com"); binder.validate(); - Assert.assertFalse(emailStatus.isVisible()); - Assert.assertEquals("", emailStatus.getValue()); + assertFalse(emailStatus.isVisible()); + assertEquals("", emailStatus.getValue()); } @Test @@ -451,24 +456,24 @@ public class BinderBookOfVaadinTest { field.setValue("aa"); binder.validate(); - Assert.assertTrue(nameStatus.isVisible()); - Assert.assertEquals(msg, nameStatus.getValue()); - Assert.assertNotNull(statusCapture.get()); + assertTrue(nameStatus.isVisible()); + assertEquals(msg, nameStatus.getValue()); + assertNotNull(statusCapture.get()); BindingValidationStatus<?> status = statusCapture.get(); - Assert.assertEquals(Status.ERROR, status.getStatus()); - Assert.assertEquals(msg, status.getMessage().get()); - Assert.assertEquals(field, status.getField()); + assertEquals(Status.ERROR, status.getStatus()); + assertEquals(msg, status.getMessage().get()); + assertEquals(field, status.getField()); field.setValue("foo"); binder.validate(); - Assert.assertFalse(nameStatus.isVisible()); - Assert.assertEquals("", nameStatus.getValue()); - Assert.assertNotNull(statusCapture.get()); + assertFalse(nameStatus.isVisible()); + assertEquals("", nameStatus.getValue()); + assertNotNull(statusCapture.get()); status = statusCapture.get(); - Assert.assertEquals(Status.OK, status.getStatus()); - Assert.assertFalse(status.getMessage().isPresent()); - Assert.assertEquals(field, status.getField()); + assertEquals(Status.OK, status.getStatus()); + assertFalse(status.getMessage().isPresent()); + assertEquals(field, status.getField()); } @Test @@ -501,14 +506,14 @@ public class BinderBookOfVaadinTest { }); emailField.setValue("foo@bar.com"); - Assert.assertTrue(binder.writeBeanIfValid(person)); + assertTrue(binder.writeBeanIfValid(person)); // Person updated - Assert.assertEquals("foo@bar.com", person.getEmail()); + assertEquals("foo@bar.com", person.getEmail()); emailField.setValue(""); - Assert.assertFalse(binder.writeBeanIfValid(person)); + assertFalse(binder.writeBeanIfValid(person)); // Person updated because phone and email are both empty - Assert.assertEquals("foo@bar.com", person.getEmail()); + assertEquals("foo@bar.com", person.getEmail()); } @Test @@ -527,21 +532,21 @@ public class BinderBookOfVaadinTest { .bind(BookPerson::getYearOfBirth, BookPerson::setYearOfBirth); yearOfBirthField.setValue("abc"); - Assert.assertEquals("Doesn't look like a year", binder.validate() + assertEquals("Doesn't look like a year", binder.validate() .getFieldValidationErrors().get(0).getMessage().get()); yearOfBirthField.setValue("abcd"); - Assert.assertEquals("Must enter a number", binder.validate() + assertEquals("Must enter a number", binder.validate() .getFieldValidationErrors().get(0).getMessage().get()); yearOfBirthField.setValue("1200"); - Assert.assertEquals("Person must be born in the 20th century", + assertEquals("Person must be born in the 20th century", binder.validate().getFieldValidationErrors().get(0).getMessage() .get()); yearOfBirthField.setValue("1950"); - Assert.assertFalse(binder.validate().hasErrors()); + assertFalse(binder.validate().hasErrors()); BookPerson person = new BookPerson(1500, 12); binder.writeBean(person); - Assert.assertEquals(1950, person.getYearOfBirth()); + assertEquals(1950, person.getYearOfBirth()); } class MyConverter implements Converter<String, Integer> { @@ -580,17 +585,17 @@ public class BinderBookOfVaadinTest { binder.setBean(p); yearOfBirthField.setValue("abc"); - Assert.assertTrue(binder.validate().hasErrors()); - Assert.assertEquals("Please enter a number", binder.validate() + assertTrue(binder.validate().hasErrors()); + assertEquals("Please enter a number", binder.validate() .getFieldValidationErrors().get(0).getMessage().get()); yearOfBirthField.setValue("123"); - Assert.assertTrue(binder.validate().isOk()); + assertTrue(binder.validate().isOk()); p.setYearOfBirth(12500); binder.readBean(p); - Assert.assertEquals("12500", yearOfBirthField.getValue()); - Assert.assertTrue(binder.validate().isOk()); + assertEquals("12500", yearOfBirthField.getValue()); + assertTrue(binder.validate().isOk()); } @Test @@ -617,31 +622,31 @@ public class BinderBookOfVaadinTest { yearOfBirth.setValue("2001"); BinderValidationStatus<?> status = binder.validate(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(1, status.getBeanValidationErrors().size()); - Assert.assertEquals(message, + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(1, status.getBeanValidationErrors().size()); + assertEquals(message, status.getBeanValidationErrors().get(0).getErrorMessage()); - Assert.assertEquals(message, formStatusLabel.getValue()); + assertEquals(message, formStatusLabel.getValue()); // value is correct, status label is cleared yearOfBirth.setValue("1999"); status = binder.validate(); - Assert.assertFalse(status.hasErrors()); + assertFalse(status.hasErrors()); - Assert.assertEquals("", formStatusLabel.getValue()); + assertEquals("", formStatusLabel.getValue()); // both bean validators fail, should be two error messages chained yearOfBirth.setValue("2000"); status = binder.validate(); - Assert.assertEquals(2, status.getBeanValidationResults().size()); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, status.getBeanValidationErrors().size()); + assertEquals(2, status.getBeanValidationResults().size()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(2, status.getBeanValidationErrors().size()); // only first error is shown - Assert.assertEquals(message, formStatusLabel.getValue()); + assertEquals(message, formStatusLabel.getValue()); } @Test @@ -682,43 +687,42 @@ public class BinderBookOfVaadinTest { // first binding validation fails, no bean level validation is done yearOfBirth.setValue("2001"); BinderValidationStatus<?> status = binder.validate(); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals(bindingMessage, + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals(bindingMessage, status.getFieldValidationErrors().get(0).getMessage().get()); - Assert.assertEquals("", formStatusLabel.getValue()); + assertEquals("", formStatusLabel.getValue()); // first bean validator fails and passes error message to status label yearOfBirth.setValue("2002"); status = binder.validate(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(1, status.getBeanValidationErrors().size()); - Assert.assertEquals(message, + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(1, status.getBeanValidationErrors().size()); + assertEquals(message, status.getBeanValidationErrors().get(0).getErrorMessage()); - Assert.assertEquals(message, formStatusLabel.getValue()); + assertEquals(message, formStatusLabel.getValue()); // value is correct, status label is cleared yearOfBirth.setValue("1998"); status = binder.validate(); - Assert.assertTrue(status.isOk()); - Assert.assertFalse(status.hasErrors()); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); + assertTrue(status.isOk()); + assertFalse(status.hasErrors()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(0, status.getBeanValidationErrors().size()); - Assert.assertEquals("", formStatusLabel.getValue()); + assertEquals("", formStatusLabel.getValue()); // both bean validators fail, should be two error messages chained yearOfBirth.setValue("2000"); status = binder.validate(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, status.getBeanValidationErrors().size()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(2, status.getBeanValidationErrors().size()); - Assert.assertEquals(message + "\n" + message2, - formStatusLabel.getValue()); + assertEquals(message + "\n" + message2, formStatusLabel.getValue()); } @@ -741,43 +745,43 @@ public class BinderBookOfVaadinTest { .withValidator(new StringLengthValidator("", 1, 3)) .bind(BookPerson::getLastName, BookPerson::setLastName); // no changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); BookPerson person = new BookPerson(2000, 1); binder.readBean(person); // no changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); field.setValue("a"); // binder is not bound, no event fired // no changes: see #375. There should be a change and enabled state - Assert.assertTrue(saveButton.isEnabled()); - Assert.assertTrue(resetButton.isEnabled()); - Assert.assertTrue(eventIsFired.get()); + assertTrue(saveButton.isEnabled()); + assertTrue(resetButton.isEnabled()); + assertTrue(eventIsFired.get()); binder.writeBeanIfValid(person); // no changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); binder.validate(); // no changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); field.setValue(""); // binder is not bound, no event fired // no changes: see #375. There should be a change and disabled state for // save button because of failed validation - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertTrue(resetButton.isEnabled()); - Assert.assertTrue(eventIsFired.get()); + assertFalse(saveButton.isEnabled()); + assertTrue(resetButton.isEnabled()); + assertTrue(eventIsFired.get()); } @Test @@ -799,15 +803,15 @@ public class BinderBookOfVaadinTest { .withValidator(new StringLengthValidator("", 1, 3)) .bind(BookPerson::getLastName, BookPerson::setLastName); // no changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); BookPerson person = new BookPerson(2000, 1); binder.setBean(person); // no changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); field.setValue("a"); @@ -816,8 +820,8 @@ public class BinderBookOfVaadinTest { field.setValue(""); // there are invalid changes - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertTrue(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertTrue(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); // set valid value @@ -825,8 +829,8 @@ public class BinderBookOfVaadinTest { verifyEventIsFired(eventIsFired); binder.writeBeanIfValid(person); // there are no changes. - Assert.assertFalse(saveButton.isEnabled()); - Assert.assertFalse(resetButton.isEnabled()); + assertFalse(saveButton.isEnabled()); + assertFalse(resetButton.isEnabled()); verifyEventIsFired(eventIsFired); } @@ -846,13 +850,13 @@ public class BinderBookOfVaadinTest { binder.forField(emailField).asRequired("").bind(BookPerson::getEmail, BookPerson::setEmail); - Assert.assertFalse(saveButton.isEnabled()); + assertFalse(saveButton.isEnabled()); field.setValue("not empty"); - Assert.assertFalse(saveButton.isEnabled()); + assertFalse(saveButton.isEnabled()); emailField.setValue("not empty"); - Assert.assertTrue(saveButton.isEnabled()); + assertTrue(saveButton.isEnabled()); field.clear(); - Assert.assertFalse(saveButton.isEnabled()); + assertFalse(saveButton.isEnabled()); } @Test @@ -881,7 +885,7 @@ public class BinderBookOfVaadinTest { } private void verifyEventIsFired(AtomicBoolean flag) { - Assert.assertTrue(flag.get()); + assertTrue(flag.get()); flag.set(false); } } diff --git a/server/src/test/java/com/vaadin/data/BinderComponentTest.java b/server/src/test/java/com/vaadin/data/BinderComponentTest.java index bf3d1a5074..776816be5e 100644 --- a/server/src/test/java/com/vaadin/data/BinderComponentTest.java +++ b/server/src/test/java/com/vaadin/data/BinderComponentTest.java @@ -1,8 +1,9 @@ package com.vaadin.data; +import static org.junit.Assert.assertEquals; + import java.util.Collections; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -66,14 +67,14 @@ public class BinderComponentTest private <T> void testFieldNullRepresentation(T initialValue, HasValue<T> field) { binder.bind(field, t -> null, (str, val) -> { - Assert.assertEquals("Value update with initial value failed.", + assertEquals("Value update with initial value failed.", initialValue, field.getValue()); }); field.setValue(initialValue); - Assert.assertEquals("Initial value of field unexpected", initialValue, + assertEquals("Initial value of field unexpected", initialValue, field.getValue()); binder.setBean(item); - Assert.assertEquals("Null representation for field failed", + assertEquals("Null representation for field failed", field.getEmptyValue(), field.getValue()); field.setValue(initialValue); } diff --git a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java index 3ab4e962a0..4915bc9a5b 100644 --- a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java +++ b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java @@ -20,12 +20,12 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.Serializable; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -445,7 +445,7 @@ public class BinderConverterValidatorTest binder.writeBean(person); } finally { // Bean should not have been updated - Assert.assertEquals(firstName, person.getFirstName()); + assertEquals(firstName, person.getFirstName()); } } @@ -463,7 +463,7 @@ public class BinderConverterValidatorTest binder.writeBean(person); } finally { // Bean should have been updated for item validation but reverted - Assert.assertNull(person.getFirstName()); + assertNull(person.getFirstName()); } } @@ -479,8 +479,8 @@ public class BinderConverterValidatorTest person.setLastName("bar"); nameField.setValue("foo"); binder.writeBean(person); - Assert.assertEquals(nameField.getValue(), person.getFirstName()); - Assert.assertEquals("bar", person.getLastName()); + assertEquals(nameField.getValue(), person.getFirstName()); + assertEquals("bar", person.getLastName()); } @Test @@ -492,8 +492,8 @@ public class BinderConverterValidatorTest Person person = new Person(); person.setFirstName("foo"); nameField.setValue(""); - Assert.assertFalse(binder.writeBeanIfValid(person)); - Assert.assertEquals("foo", person.getFirstName()); + assertFalse(binder.writeBeanIfValid(person)); + assertEquals("foo", person.getFirstName()); } @Test @@ -506,8 +506,8 @@ public class BinderConverterValidatorTest person.setFirstName("foo"); nameField.setValue("bar"); - Assert.assertTrue(binder.writeBeanIfValid(person)); - Assert.assertEquals("bar", person.getFirstName()); + assertTrue(binder.writeBeanIfValid(person)); + assertEquals("bar", person.getFirstName()); } @Test @@ -524,9 +524,9 @@ public class BinderConverterValidatorTest Person person = new Person(); person.setFirstName("foo"); nameField.setValue(""); - Assert.assertFalse(binder.writeBeanIfValid(person)); + assertFalse(binder.writeBeanIfValid(person)); - Assert.assertEquals("foo", person.getFirstName()); + assertEquals("foo", person.getFirstName()); } @Test @@ -549,7 +549,7 @@ public class BinderConverterValidatorTest binder.writeBean(person); - Assert.assertNull(person.getFirstName()); + assertNull(person.getFirstName()); } @Test @@ -569,19 +569,18 @@ public class BinderConverterValidatorTest ageField.setValue("-1"); try { binder.writeBean(person); - Assert.fail(); + fail(); } catch (ValidationException exception) { List<BindingValidationStatus<?>> validationErrors = exception .getFieldValidationErrors(); - Assert.assertEquals(2, validationErrors.size()); + assertEquals(2, validationErrors.size()); BindingValidationStatus<?> error = validationErrors.get(0); - Assert.assertEquals(nameField, error.getField()); - Assert.assertEquals(msg, error.getMessage().get()); + assertEquals(nameField, error.getField()); + assertEquals(msg, error.getMessage().get()); error = validationErrors.get(1); - Assert.assertEquals(ageField, error.getField()); - Assert.assertEquals(NEGATIVE_ERROR_MESSAGE, - error.getMessage().get()); + assertEquals(ageField, error.getField()); + assertEquals(NEGATIVE_ERROR_MESSAGE, error.getMessage().get()); } } @@ -597,28 +596,28 @@ public class BinderConverterValidatorTest binder.setBean(person); // initial value is invalid but no error - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); // make error show nameField.setValue("foo"); nameField.setValue(""); - Assert.assertNotNull(nameField.getComponentError()); + assertNotNull(nameField.getComponentError()); // bind to another person to see that error is cleared person = new Person(); person.setFirstName(""); binder.setBean(person); // error has been cleared - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); // make show error nameField.setValue("foo"); nameField.setValue(""); - Assert.assertNotNull(nameField.getComponentError()); + assertNotNull(nameField.getComponentError()); // load should also clear error binder.readBean(person); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); // bind a new field that has invalid value in bean TextField lastNameField = new TextField(); @@ -628,7 +627,7 @@ public class BinderConverterValidatorTest binding2.bind(Person::getLastName, Person::setLastName); // should not have error shown - Assert.assertNull(lastNameField.getComponentError()); + assertNull(lastNameField.getComponentError()); // add status label to show bean level error Label statusLabel = new Label(); @@ -636,27 +635,27 @@ public class BinderConverterValidatorTest nameField.setValue("error"); // no error shown yet because second field validation doesn't pass - Assert.assertEquals("", statusLabel.getValue()); + assertEquals("", statusLabel.getValue()); // make second field validation pass to get bean validation error lastNameField.setValue("foo"); - Assert.assertEquals("error", statusLabel.getValue()); + assertEquals("error", statusLabel.getValue()); // reload bean to clear error binder.readBean(person); - Assert.assertEquals("", statusLabel.getValue()); + assertEquals("", statusLabel.getValue()); // reset() should clear all errors and status label nameField.setValue(""); lastNameField.setValue(""); - Assert.assertNotNull(nameField.getComponentError()); - Assert.assertNotNull(lastNameField.getComponentError()); + assertNotNull(nameField.getComponentError()); + assertNotNull(lastNameField.getComponentError()); statusLabel.setComponentError(new UserError("ERROR")); binder.removeBean(); - Assert.assertNull(nameField.getComponentError()); - Assert.assertNull(lastNameField.getComponentError()); - Assert.assertEquals("", statusLabel.getValue()); + assertNull(nameField.getComponentError()); + assertNull(lastNameField.getComponentError()); + assertEquals("", statusLabel.getValue()); } @Test @@ -682,18 +681,18 @@ public class BinderConverterValidatorTest Person person = new Person(); binder.setBean(person); - Assert.assertNull(nameField.getComponentError()); - Assert.assertNull(lastNameField.getComponentError()); + assertNull(nameField.getComponentError()); + assertNull(lastNameField.getComponentError()); nameField.setValue("x"); - Assert.assertNotNull(nameField.getComponentError()); - Assert.assertNotNull(lastNameField.getComponentError()); + assertNotNull(nameField.getComponentError()); + assertNotNull(lastNameField.getComponentError()); binder.setBean(person); - Assert.assertNull(nameField.getComponentError()); - Assert.assertNull(lastNameField.getComponentError()); + assertNull(nameField.getComponentError()); + assertNull(lastNameField.getComponentError()); } protected void bindName() { @@ -724,7 +723,7 @@ public class BinderConverterValidatorTest binder.writeBean(person); } finally { // Bean should have been updated for item validation but reverted - Assert.assertEquals(0, person.getAge()); + assertEquals(0, person.getAge()); } } } diff --git a/server/src/test/java/com/vaadin/data/BinderCustomPropertySetTest.java b/server/src/test/java/com/vaadin/data/BinderCustomPropertySetTest.java index f9609aa47a..31c48447a6 100644 --- a/server/src/test/java/com/vaadin/data/BinderCustomPropertySetTest.java +++ b/server/src/test/java/com/vaadin/data/BinderCustomPropertySetTest.java @@ -15,13 +15,16 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.Setter; @@ -59,8 +62,8 @@ public class BinderCustomPropertySetTest { public Class<String> getType() { return String.class; } - - public Class<?> getPropertyHolderType(){ + + public Class<?> getPropertyHolderType() { return Map.class; } @@ -116,7 +119,7 @@ public class BinderCustomPropertySetTest { binder.setBean(map); field.setValue("value"); - Assert.assertEquals( + assertEquals( "Field value should propagate to the corresponding key in the map", "value", map.get("key")); } @@ -130,17 +133,17 @@ public class BinderCustomPropertySetTest { binder.bindInstanceFields(instanceFields); - Assert.assertNotNull( + assertNotNull( "Field corresponding to supported property name should be bound", instanceFields.one); - Assert.assertNull( + assertNull( "Field corresponding to unsupported property name should be ignored", instanceFields.another); binder.setBean(map); instanceFields.one.setValue("value"); - Assert.assertEquals( + assertEquals( "Field value should propagate to the corresponding key in the map", "value", map.get("one")); } diff --git a/server/src/test/java/com/vaadin/data/BinderInstanceFieldTest.java b/server/src/test/java/com/vaadin/data/BinderInstanceFieldTest.java index 5b2e0a2490..a05f2eaae4 100644 --- a/server/src/test/java/com/vaadin/data/BinderInstanceFieldTest.java +++ b/server/src/test/java/com/vaadin/data/BinderInstanceFieldTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + import java.time.LocalDate; -import org.junit.Assert; import org.junit.Test; import com.vaadin.annotations.PropertyId; @@ -147,14 +150,14 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.firstName.getValue()); - Assert.assertEquals(person.getBirthDate(), form.birthDate.getValue()); + assertEquals(person.getFirstName(), form.firstName.getValue()); + assertEquals(person.getBirthDate(), form.birthDate.getValue()); form.firstName.setValue("bar"); form.birthDate.setValue(person.getBirthDate().plusDays(345)); - Assert.assertEquals(form.firstName.getValue(), person.getFirstName()); - Assert.assertEquals(form.birthDate.getValue(), person.getBirthDate()); + assertEquals(form.firstName.getValue(), person.getFirstName()); + assertEquals(form.birthDate.getValue(), person.getBirthDate()); } @Test(expected = IllegalStateException.class) @@ -175,13 +178,13 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.firstName.getValue()); + assertEquals(person.getFirstName(), form.firstName.getValue()); - Assert.assertNull(form.noFieldInPerson); + assertNull(form.noFieldInPerson); form.firstName.setValue("bar"); - Assert.assertEquals(form.firstName.getValue(), person.getFirstName()); + assertEquals(form.firstName.getValue(), person.getFirstName()); } @Test @@ -195,7 +198,7 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertNull(form.firstName); + assertNull(form.firstName); } @Test @@ -209,11 +212,11 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.firstName.getValue()); + assertEquals(person.getFirstName(), form.firstName.getValue()); form.firstName.setValue("bar"); - Assert.assertEquals(form.firstName.getValue(), person.getFirstName()); + assertEquals(form.firstName.getValue(), person.getFirstName()); } @Test(expected = IllegalStateException.class) @@ -269,11 +272,11 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.firstName.getValue()); + assertEquals(person.getFirstName(), form.firstName.getValue()); form.firstName.setValue("bar"); - Assert.assertEquals(form.firstName.getValue(), person.getFirstName()); + assertEquals(form.firstName.getValue(), person.getFirstName()); } @Test @@ -289,7 +292,7 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(name, form.firstName); + assertEquals(name, form.firstName); } @Test @@ -304,16 +307,14 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.nameField.getValue()); - Assert.assertEquals(person.getBirthDate(), - form.birthDateField.getValue()); + assertEquals(person.getFirstName(), form.nameField.getValue()); + assertEquals(person.getBirthDate(), form.birthDateField.getValue()); form.nameField.setValue("bar"); form.birthDateField.setValue(person.getBirthDate().plusDays(345)); - Assert.assertEquals(form.nameField.getValue(), person.getFirstName()); - Assert.assertEquals(form.birthDateField.getValue(), - person.getBirthDate()); + assertEquals(form.nameField.getValue(), person.getFirstName()); + assertEquals(form.birthDateField.getValue(), person.getBirthDate()); } @Test @@ -337,20 +338,20 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.firstName.getValue()); - Assert.assertEquals(person.getBirthDate(), form.birthDate.getValue()); + assertEquals(person.getFirstName(), form.firstName.getValue()); + assertEquals(person.getBirthDate(), form.birthDate.getValue()); // the instance is not overridden - Assert.assertEquals(name, form.firstName); + assertEquals(name, form.firstName); // Test automatic binding form.birthDate.setValue(person.getBirthDate().plusDays(345)); - Assert.assertEquals(form.birthDate.getValue(), person.getBirthDate()); + assertEquals(form.birthDate.getValue(), person.getBirthDate()); // Test custom binding form.firstName.setValue("aa"); - Assert.assertEquals(personName, person.getFirstName()); + assertEquals(personName, person.getFirstName()); - Assert.assertFalse(binder.validate().isOk()); + assertFalse(binder.validate().isOk()); } @Test @@ -380,24 +381,24 @@ public class BinderInstanceFieldTest { binder.setBean(person); - Assert.assertEquals(person.getFirstName(), form.firstName.getValue()); - Assert.assertEquals(String.valueOf(person.getAge()), + assertEquals(person.getFirstName(), form.firstName.getValue()); + assertEquals(String.valueOf(person.getAge()), form.noFieldInPerson.getValue()); // the instances are not overridden - Assert.assertEquals(name, form.firstName); - Assert.assertEquals(ageField, form.noFieldInPerson); + assertEquals(name, form.firstName); + assertEquals(ageField, form.noFieldInPerson); // Test correct age age += 56; form.noFieldInPerson.setValue(String.valueOf(age)); - Assert.assertEquals(form.noFieldInPerson.getValue(), + assertEquals(form.noFieldInPerson.getValue(), String.valueOf(person.getAge())); // Test incorrect name form.firstName.setValue("aa"); - Assert.assertEquals(personName, person.getFirstName()); + assertEquals(personName, person.getFirstName()); - Assert.assertFalse(binder.validate().isOk()); + assertFalse(binder.validate().isOk()); } @Test @@ -415,7 +416,7 @@ public class BinderInstanceFieldTest { person.setFirstName("first"); person.setAge(45); binder.setBean(person); - Assert.assertEquals("90", form.age.getValue()); + assertEquals("90", form.age.getValue()); } @Test diff --git a/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java b/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java index 1ab39ee46f..f2cb147e70 100644 --- a/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java +++ b/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.concurrent.atomic.AtomicReference; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -49,7 +52,7 @@ public class BinderStatusChangeTest BindingBuilder<Person, String> binding = binder.forField(nameField); nameField.setValue(""); - Assert.assertNull(event.get()); + assertNull(event.get()); binding.bind(Person::getFirstName, Person::setFirstName); verifyEvent(); @@ -59,7 +62,7 @@ public class BinderStatusChangeTest public void bindBinder_unbound_singleEventWhenBound() { binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.setBean(item); @@ -72,7 +75,7 @@ public class BinderStatusChangeTest binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.removeBean(); verifyEvent(); } @@ -81,9 +84,9 @@ public class BinderStatusChangeTest public void removeBean_unbound_noEventWhenUnBound() { binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.removeBean(); - Assert.assertNull(event.get()); + assertNull(event.get()); } @Test @@ -94,7 +97,7 @@ public class BinderStatusChangeTest binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); nameField.setValue("foo"); verifyEvent(); } @@ -110,7 +113,7 @@ public class BinderStatusChangeTest binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); nameField.setValue("foo"); verifyEvent(); } @@ -123,7 +126,7 @@ public class BinderStatusChangeTest binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); nameField.setValue("foo"); verifyEvent(true); } @@ -138,7 +141,7 @@ public class BinderStatusChangeTest binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); nameField.setValue("foo"); verifyEvent(true); } @@ -148,7 +151,7 @@ public class BinderStatusChangeTest binder.forField(nameField).bind(Person::getFirstName, Person::setFirstName); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.readBean(item); verifyEvent(); } @@ -161,7 +164,7 @@ public class BinderStatusChangeTest .withConverter(new StringToIntegerConverter("")) .bind(Person::getAge, Person::setAge); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.readBean(item); verifyEvent(); } @@ -169,7 +172,7 @@ public class BinderStatusChangeTest @Test public void readBean_hasNoBindings_singleEvent() { binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.readBean(item); verifyEvent(); } @@ -178,7 +181,7 @@ public class BinderStatusChangeTest public void writeBean_hasNoBindings_singleEvent() throws ValidationException { binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBean(item); verifyEvent(); } @@ -186,7 +189,7 @@ public class BinderStatusChangeTest @Test public void writeBeanIfValid_hasNoBindings_singleEvent() { binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(); } @@ -198,7 +201,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBean(item); verifyEvent(); } @@ -214,7 +217,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBean(item); verifyEvent(); } @@ -226,7 +229,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(); } @@ -241,7 +244,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(); } @@ -253,7 +256,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); try { binder.writeBean(item); } catch (ValidationException ignore) { @@ -268,7 +271,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(true); } @@ -283,7 +286,7 @@ public class BinderStatusChangeTest binder.readBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(true); } @@ -296,7 +299,7 @@ public class BinderStatusChangeTest binder.withValidator(Validator.from(person -> false, "")); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); try { binder.writeBean(item); } catch (ValidationException ignore) { @@ -312,7 +315,7 @@ public class BinderStatusChangeTest binder.withValidator(Validator.from(person -> false, "")); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(true); } @@ -326,7 +329,7 @@ public class BinderStatusChangeTest binder.withValidator(Validator.from(person -> true, "")); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBean(item); verifyEvent(); } @@ -339,7 +342,7 @@ public class BinderStatusChangeTest binder.withValidator(Validator.from(person -> true, "")); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.writeBeanIfValid(item); verifyEvent(); } @@ -354,7 +357,7 @@ public class BinderStatusChangeTest binder.setBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.validate(); verifyEvent(); @@ -370,7 +373,7 @@ public class BinderStatusChangeTest binder.setBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.validate(); verifyEvent(true); @@ -386,7 +389,7 @@ public class BinderStatusChangeTest binder.setBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binding.validate(); verifyEvent(); @@ -403,7 +406,7 @@ public class BinderStatusChangeTest binder.setBean(item); binder.addStatusChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binding.validate(); verifyEvent(true); @@ -415,15 +418,14 @@ public class BinderStatusChangeTest private void verifyEvent(boolean validationErrors) { StatusChangeEvent statusChangeEvent = event.get(); - Assert.assertNotNull(statusChangeEvent); - Assert.assertEquals(binder, statusChangeEvent.getBinder()); - Assert.assertEquals(binder, statusChangeEvent.getSource()); - Assert.assertEquals(validationErrors, - statusChangeEvent.hasValidationErrors()); + assertNotNull(statusChangeEvent); + assertEquals(binder, statusChangeEvent.getBinder()); + assertEquals(binder, statusChangeEvent.getSource()); + assertEquals(validationErrors, statusChangeEvent.hasValidationErrors()); } private void statusChanged(StatusChangeEvent evt) { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(evt); } } diff --git a/server/src/test/java/com/vaadin/data/BinderTest.java b/server/src/test/java/com/vaadin/data/BinderTest.java index 36d1692fcb..1169eb8a5d 100644 --- a/server/src/test/java/com/vaadin/data/BinderTest.java +++ b/server/src/test/java/com/vaadin/data/BinderTest.java @@ -1,7 +1,9 @@ package com.vaadin.data; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -12,7 +14,6 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -232,7 +233,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.writeBean(person); - Assert.assertEquals(age, person.getAge()); + assertEquals(age, person.getAge()); } @Test @@ -249,7 +250,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.writeBean(person); - Assert.assertEquals(fieldValue, person.getFirstName()); + assertEquals(fieldValue, person.getFirstName()); } @Test @@ -262,7 +263,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { person.setFirstName(name); binder.readBean(person); - Assert.assertEquals(name, nameField.getValue()); + assertEquals(name, nameField.getValue()); } @Test @@ -275,7 +276,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { person.setFirstName(name); binder.readBean(person); - Assert.assertEquals("", nameField.getValue()); + assertEquals("", nameField.getValue()); } protected void bindName() { @@ -296,19 +297,19 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { // Bind a person with null value and check that null representation is // used binder.setBean(namelessPerson); - Assert.assertEquals( + assertEquals( "Null value from bean was not converted to explicit null representation", nullRepresentation, nameField.getValue()); // Verify that changes are applied to bean nameField.setValue(realName); - Assert.assertEquals( + assertEquals( "Bean was not correctly updated from a change in the field", realName, namelessPerson.getFirstName()); // Verify conversion back to null nameField.setValue(nullRepresentation); - Assert.assertEquals( + assertEquals( "Two-way null representation did not change value back to null", null, namelessPerson.getFirstName()); } @@ -328,19 +329,19 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.setBean(namelessPerson); assertTrue(nullTextField.isEmpty()); - Assert.assertEquals(null, namelessPerson.getFirstName()); + assertEquals(null, namelessPerson.getFirstName()); // Change value, see that textfield is not empty and bean is updated. nullTextField.setValue(""); assertFalse(nullTextField.isEmpty()); - Assert.assertEquals("First name of person was not properly updated", "", + assertEquals("First name of person was not properly updated", "", namelessPerson.getFirstName()); // Verify that default null representation does not map back to null nullTextField.setValue("null"); assertTrue(nullTextField.isEmpty()); - Assert.assertEquals("Default one-way null representation failed.", - "null", namelessPerson.getFirstName()); + assertEquals("Default one-way null representation failed.", "null", + namelessPerson.getFirstName()); } @Test @@ -354,8 +355,8 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { Objects.isNull(item.getFirstName())); binder.setBean(item); - Assert.assertEquals("Field value was not set correctly", - item.getFirstName(), nameField.getValue()); + assertEquals("Field value was not set correctly", item.getFirstName(), + nameField.getValue()); } @Test @@ -368,12 +369,11 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { .bind(Person::getSalary, Person::setSalary); binder.setBean(item); - Assert.assertEquals(customNullConverter.toString(), - ageField.getValue()); + assertEquals(customNullConverter.toString(), ageField.getValue()); Integer salary = 11; ageField.setValue(salary.toString()); - Assert.assertEquals(11, salary.intValue()); + assertEquals(11, salary.intValue()); } @Test @@ -384,7 +384,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { Person person = new Person(); binder.setBean(person); - Assert.assertEquals("", nameField.getValue()); + assertEquals("", nameField.getValue()); } @Test @@ -392,15 +392,15 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { String customNullPointerRepresentation = "foo"; Binder<Person> binder = new Binder<>(Person.class); binder.forField(nameField) - .withConverter(value -> value, value -> value == null - ? customNullPointerRepresentation : value) + .withConverter(value -> value, + value -> value == null ? customNullPointerRepresentation + : value) .bind("firstName"); Person person = new Person(); binder.setBean(person); - Assert.assertEquals(customNullPointerRepresentation, - nameField.getValue()); + assertEquals(customNullPointerRepresentation, nameField.getValue()); } @Test @@ -412,11 +412,11 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { item.setFirstName(null); binder.setBean(item); - Assert.assertEquals(nullRepresentation, nameField.getValue()); + assertEquals(nullRepresentation, nameField.getValue()); String newValue = "bar"; nameField.setValue(newValue); - Assert.assertEquals(newValue, item.getFirstName()); + assertEquals(newValue, item.getFirstName()); } @Test @@ -432,15 +432,15 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binding.bind(Person::getFirstName, Person::setFirstName); binder.setBean(item); - Assert.assertNull(textField.getErrorMessage()); + assertNull(textField.getErrorMessage()); textField.setValue(textField.getEmptyValue()); ErrorMessage errorMessage = textField.getErrorMessage(); - Assert.assertNotNull(errorMessage); - Assert.assertEquals("foobar", errorMessage.getFormattedHtmlMessage()); + assertNotNull(errorMessage); + assertEquals("foobar", errorMessage.getFormattedHtmlMessage()); textField.setValue("value"); - Assert.assertNull(textField.getErrorMessage()); + assertNull(textField.getErrorMessage()); assertTrue(textField.isRequiredIndicatorVisible()); } @@ -449,19 +449,19 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { TextField textField = new TextField(); binder.forField(textField).asRequired("foobar") .bind(Person::getFirstName, Person::setFirstName); - Assert.assertTrue(textField.isRequiredIndicatorVisible()); - Assert.assertNull(textField.getErrorMessage()); + assertTrue(textField.isRequiredIndicatorVisible()); + assertNull(textField.getErrorMessage()); binder.readBean(item); - Assert.assertNull(textField.getErrorMessage()); + assertNull(textField.getErrorMessage()); textField.setValue(textField.getEmptyValue()); - Assert.assertTrue(textField.isRequiredIndicatorVisible()); - Assert.assertNotNull(textField.getErrorMessage()); + assertTrue(textField.isRequiredIndicatorVisible()); + assertNotNull(textField.getErrorMessage()); binder.readBean(null); assertTrue(textField.isRequiredIndicatorVisible()); - Assert.assertNull(textField.getErrorMessage()); + assertNull(textField.getErrorMessage()); } @Test @@ -476,25 +476,25 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binding.asRequired(context -> { invokes.incrementAndGet(); - Assert.assertSame(Locale.CANADA, context.getLocale().get()); + assertSame(Locale.CANADA, context.getLocale().get()); return "foobar"; }); assertTrue(textField.isRequiredIndicatorVisible()); binding.bind(Person::getFirstName, Person::setFirstName); binder.setBean(item); - Assert.assertNull(textField.getErrorMessage()); - Assert.assertEquals(0, invokes.get()); + assertNull(textField.getErrorMessage()); + assertEquals(0, invokes.get()); textField.setValue(textField.getEmptyValue()); ErrorMessage errorMessage = textField.getErrorMessage(); - Assert.assertNotNull(errorMessage); - Assert.assertEquals("foobar", errorMessage.getFormattedHtmlMessage()); + assertNotNull(errorMessage); + assertEquals("foobar", errorMessage.getFormattedHtmlMessage()); // validation is done for the whole bean at once. - Assert.assertEquals(1, invokes.get()); + assertEquals(1, invokes.get()); textField.setValue("value"); - Assert.assertNull(textField.getErrorMessage()); + assertNull(textField.getErrorMessage()); assertTrue(textField.isRequiredIndicatorVisible()); } @@ -516,13 +516,13 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.setBean(item); // setting the bean causes 2: - Assert.assertEquals(2, invokes.get()); + assertEquals(2, invokes.get()); lastNameField.setValue(""); - Assert.assertEquals(2, invokes.get()); + assertEquals(2, invokes.get()); firstNameField.setValue(""); - Assert.assertEquals(3, invokes.get()); + assertEquals(3, invokes.get()); binder.removeBean(); Person person = new Person(); @@ -530,13 +530,13 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { person.setLastName("a"); binder.readBean(person); // reading from a bean causes 2: - Assert.assertEquals(5, invokes.get()); + assertEquals(5, invokes.get()); lastNameField.setValue(""); - Assert.assertEquals(5, invokes.get()); + assertEquals(5, invokes.get()); firstNameField.setValue(""); - Assert.assertEquals(6, invokes.get()); + assertEquals(6, invokes.get()); } @Test(expected = IllegalStateException.class) @@ -619,16 +619,16 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.setBean(item); - Assert.assertTrue(binder.isValid()); + assertTrue(binder.isValid()); nameField.setValue("fail field validation"); - Assert.assertFalse(binder.isValid()); + assertFalse(binder.isValid()); nameField.setValue(""); - Assert.assertTrue(binder.isValid()); + assertTrue(binder.isValid()); nameField.setValue("fail bean validation"); - Assert.assertFalse(binder.isValid()); + assertFalse(binder.isValid()); } @Test @@ -638,13 +638,13 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { name -> !name.equals("fail field validation"), "")) .bind(Person::getFirstName, Person::setFirstName); - Assert.assertTrue(binder.isValid()); + assertTrue(binder.isValid()); nameField.setValue("fail field validation"); - Assert.assertFalse(binder.isValid()); + assertFalse(binder.isValid()); nameField.setValue(""); - Assert.assertTrue(binder.isValid()); + assertTrue(binder.isValid()); } @Test(expected = IllegalStateException.class) @@ -659,7 +659,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { @Test public void getFields_returnsFields() { - Assert.assertEquals(0, binder.getFields().count()); + assertEquals(0, binder.getFields().count()); binder.forField(nameField).bind(Person::getFirstName, Person::setFirstName); assertStreamEquals(Stream.of(nameField), binder.getFields()); @@ -670,7 +670,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { } private void assertStreamEquals(Stream<?> s1, Stream<?> s2) { - Assert.assertArrayEquals(s1.toArray(), s2.toArray()); + assertArrayEquals(s1.toArray(), s2.toArray()); } @Test @@ -691,23 +691,23 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { ageField.setValue("123123"); validation = bind.validate(); - Assert.assertTrue(validation.isError()); - Assert.assertEquals(stringLength, validation.getMessage().get()); + assertTrue(validation.isError()); + assertEquals(stringLength, validation.getMessage().get()); ageField.setValue("age"); validation = bind.validate(); - Assert.assertTrue(validation.isError()); - Assert.assertEquals(conversion, validation.getMessage().get()); + assertTrue(validation.isError()); + assertEquals(conversion, validation.getMessage().get()); ageField.setValue("256"); validation = bind.validate(); - Assert.assertTrue(validation.isError()); - Assert.assertEquals(ageLimit, validation.getMessage().get()); + assertTrue(validation.isError()); + assertEquals(ageLimit, validation.getMessage().get()); ageField.setValue("30"); validation = bind.validate(); - Assert.assertFalse(validation.isError()); - Assert.assertEquals(30, item.getAge()); + assertFalse(validation.isError()); + assertEquals(30, item.getAge()); } @Test @@ -717,19 +717,19 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { .bind(Person::getAge, Person::setAge); // Test that the binding does work - Assert.assertTrue("Field not initially empty", ageField.isEmpty()); + assertTrue("Field not initially empty", ageField.isEmpty()); binder.setBean(item); - Assert.assertEquals("Binding did not work", - String.valueOf(item.getAge()), ageField.getValue()); + assertEquals("Binding did not work", String.valueOf(item.getAge()), + ageField.getValue()); binder.setBean(null); - Assert.assertTrue("Field not cleared", ageField.isEmpty()); + assertTrue("Field not cleared", ageField.isEmpty()); // Remove the binding binder.removeBinding(ageField); // Test that it does not work anymore binder.setBean(item); - Assert.assertNotEquals("Binding was not removed", + assertNotEquals("Binding was not removed", String.valueOf(item.getAge()), ageField.getValue()); } @@ -741,19 +741,19 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.bind(nameField, "firstName"); // Test that the binding does work - Assert.assertTrue("Field not initially empty", nameField.isEmpty()); + assertTrue("Field not initially empty", nameField.isEmpty()); binder.setBean(item); - Assert.assertEquals("Binding did not work", item.getFirstName(), + assertEquals("Binding did not work", item.getFirstName(), nameField.getValue()); binder.setBean(null); - Assert.assertTrue("Field not cleared", nameField.isEmpty()); + assertTrue("Field not cleared", nameField.isEmpty()); // Remove the binding binder.removeBinding("firstName"); // Test that it does not work anymore binder.setBean(item); - Assert.assertNotEquals("Binding was not removed", item.getFirstName(), + assertNotEquals("Binding was not removed", item.getFirstName(), nameField.getValue()); } @@ -764,19 +764,19 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { .bind(Person::getAge, Person::setAge); // Test that the binding does work - Assert.assertTrue("Field not initially empty", ageField.isEmpty()); + assertTrue("Field not initially empty", ageField.isEmpty()); binder.setBean(item); - Assert.assertEquals("Binding did not work", - String.valueOf(item.getAge()), ageField.getValue()); + assertEquals("Binding did not work", String.valueOf(item.getAge()), + ageField.getValue()); binder.setBean(null); - Assert.assertTrue("Field not cleared", ageField.isEmpty()); + assertTrue("Field not cleared", ageField.isEmpty()); // Remove the binding binder.removeBinding(binding); // Test that it does not work anymore binder.setBean(item); - Assert.assertNotEquals("Binding was not removed", + assertNotEquals("Binding was not removed", String.valueOf(item.getAge()), ageField.getValue()); } @@ -788,38 +788,33 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { item.setLastName("Valid"); binder.setBean(item); - Assert.assertFalse("Should not have changes initially", - binder.hasChanges()); - Assert.assertTrue("Should be ok initially", binder.validate().isOk()); - Assert.assertNotEquals( - "First name and last name are not same initially", + assertFalse("Should not have changes initially", binder.hasChanges()); + assertTrue("Should be ok initially", binder.validate().isOk()); + assertNotEquals("First name and last name are not same initially", item.getFirstName(), item.getLastName()); nameField.setValue("Invalid"); - Assert.assertFalse("First name change not handled", - binder.hasChanges()); - Assert.assertTrue( + assertFalse("First name change not handled", binder.hasChanges()); + assertTrue( "Changing first name to something else than last name should be ok", binder.validate().isOk()); lastNameField.setValue("Invalid"); - Assert.assertTrue("Last name should not be saved yet", - binder.hasChanges()); - Assert.assertFalse( - "Binder validation should fail with pending illegal value", + assertTrue("Last name should not be saved yet", binder.hasChanges()); + assertFalse("Binder validation should fail with pending illegal value", binder.validate().isOk()); - Assert.assertNotEquals("Illegal last name should not be stored to bean", + assertNotEquals("Illegal last name should not be stored to bean", item.getFirstName(), item.getLastName()); nameField.setValue("Valid"); - Assert.assertFalse("With new first name both changes should be saved", + assertFalse("With new first name both changes should be saved", binder.hasChanges()); - Assert.assertTrue("Everything should be ok for 'Valid Invalid'", + assertTrue("Everything should be ok for 'Valid Invalid'", binder.validate().isOk()); - Assert.assertNotEquals("First name and last name should never match.", + assertNotEquals("First name and last name should never match.", item.getFirstName(), item.getLastName()); } @@ -831,8 +826,8 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { item.setLastName(item.getFirstName()); binder.setBean(item); - Assert.assertFalse(binder.isValid()); - Assert.assertFalse(binder.validate().isOk()); + assertFalse(binder.isValid()); + assertFalse(binder.validate().isOk()); } @Test(expected = IllegalStateException.class) @@ -842,7 +837,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.readBean(item); - Assert.assertTrue(binder.isValid()); + assertTrue(binder.isValid()); } @Test(expected = IllegalStateException.class) @@ -852,7 +847,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { binder.readBean(item); - Assert.assertTrue(binder.validate().isOk()); + assertTrue(binder.validate().isOk()); } protected void setBeanValidationFirstNameNotEqualsLastName( @@ -876,9 +871,9 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { public void statusChange(BindingValidationStatus<?> statusChange) { ++callCount; if (expectingError) { - Assert.assertTrue("Expecting error", statusChange.isError()); + assertTrue("Expecting error", statusChange.isError()); } else { - Assert.assertFalse("Unexpected error", statusChange.isError()); + assertFalse("Unexpected error", statusChange.isError()); } } } @@ -911,20 +906,20 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { // Test default error handling. ageField.setValue("foo"); - Assert.assertTrue("Component error does not contain error message", + assertTrue("Component error does not contain error message", ageField.getComponentError().getFormattedHtmlMessage() .contains(ageError)); // Restore values and test no errors. ageField.setValue(String.valueOf(initialAge)); - Assert.assertNull("There should be no component error", + assertNull("There should be no component error", ageField.getComponentError()); bindingHandler.expectingError = false; nameField.setValue(initialName); // Assert that the handler was called. - Assert.assertEquals( + assertEquals( "Unexpected callCount to binding validation status handler", 6, bindingHandler.callCount); } @@ -944,7 +939,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { ageField.setValue(modifiedAge); - Assert.assertEquals("Binding still affects bean even after unbind", + assertEquals("Binding still affects bean even after unbind", ageBeforeUnbind, String.valueOf(item.getAge())); } } diff --git a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java index 6e1f7614bb..dcf568cafc 100644 --- a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java +++ b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java @@ -15,10 +15,17 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -51,7 +58,7 @@ public class BinderValidationStatusTest AtomicReference<BindingValidationStatus<?>> statusCapture = new AtomicReference<>(); BindingBuilder<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withValidationStatusHandler(evt -> { - Assert.assertNull(statusCapture.get()); + assertNull(statusCapture.get()); statusCapture.set(evt); }); binding.bind(Person::getFirstName, Person::setFirstName); @@ -62,11 +69,11 @@ public class BinderValidationStatusTest // message binder.validate(); - Assert.assertNotNull(statusCapture.get()); + assertNotNull(statusCapture.get()); BindingValidationStatus<?> evt = statusCapture.get(); - Assert.assertEquals(Status.ERROR, evt.getStatus()); - Assert.assertEquals(EMPTY_ERROR_MESSAGE, evt.getMessage().get()); - Assert.assertEquals(nameField, evt.getField()); + assertEquals(Status.ERROR, evt.getStatus()); + assertEquals(EMPTY_ERROR_MESSAGE, evt.getMessage().get()); + assertEquals(nameField, evt.getField()); statusCapture.set(null); nameField.setValue("foo"); @@ -77,10 +84,10 @@ public class BinderValidationStatusTest binder.validate(); evt = statusCapture.get(); - Assert.assertNotNull(evt); - Assert.assertEquals(Status.OK, evt.getStatus()); - Assert.assertFalse(evt.getMessage().isPresent()); - Assert.assertEquals(nameField, evt.getField()); + assertNotNull(evt); + assertEquals(Status.OK, evt.getStatus()); + assertFalse(evt.getMessage().isPresent()); + assertEquals(nameField, evt.getField()); } @Test @@ -89,7 +96,7 @@ public class BinderValidationStatusTest .withValidator(notEmpty).withValidationStatusHandler(evt -> { }).bind(Person::getFirstName, Person::setFirstName); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); nameField.setValue(""); @@ -98,7 +105,7 @@ public class BinderValidationStatusTest binding.validate(); // default behavior should update component error for the nameField - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); } @Test @@ -115,8 +122,8 @@ public class BinderValidationStatusTest // message binding.validate(); - Assert.assertTrue(label.isVisible()); - Assert.assertEquals(EMPTY_ERROR_MESSAGE, label.getValue()); + assertTrue(label.isVisible()); + assertEquals(EMPTY_ERROR_MESSAGE, label.getValue()); nameField.setValue("foo"); @@ -124,8 +131,8 @@ public class BinderValidationStatusTest // no message binding.validate(); - Assert.assertFalse(label.isVisible()); - Assert.assertEquals("", label.getValue()); + assertFalse(label.isVisible()); + assertEquals("", label.getValue()); } @Test @@ -136,7 +143,7 @@ public class BinderValidationStatusTest .withValidator(notEmpty).withStatusLabel(label) .bind(Person::getFirstName, Person::setFirstName); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); nameField.setValue(""); @@ -145,7 +152,7 @@ public class BinderValidationStatusTest binding.validate(); // default behavior should update component error for the nameField - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); } @Test(expected = IllegalStateException.class) @@ -154,7 +161,7 @@ public class BinderValidationStatusTest .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); - binding.withValidationStatusHandler(evt -> Assert.fail()); + binding.withValidationStatusHandler(evt -> fail()); } @Test(expected = IllegalStateException.class) @@ -209,20 +216,18 @@ public class BinderValidationStatusTest AtomicReference<BinderValidationStatus<?>> statusCapture = new AtomicReference<>(); binder.forField(nameField).withValidator(notEmpty) .withValidationStatusHandler(evt -> { - Assert.fail( - "Using a custom status change handler so no change should end up here"); + fail("Using a custom status change handler so no change should end up here"); }).bind(Person::getFirstName, Person::setFirstName); binder.forField(ageField).withConverter(stringToInteger) .withValidator(notNegative).withValidationStatusHandler(evt -> { - Assert.fail( - "Using a custom status change handler so no change should end up here"); + fail("Using a custom status change handler so no change should end up here"); }).bind(Person::getAge, Person::setAge); binder.setValidationStatusHandler(r -> { statusCapture.set(r); }); binder.setBean(item); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); nameField.setValue(""); ageField.setValue("5"); @@ -231,28 +236,28 @@ public class BinderValidationStatusTest // and message BinderValidationStatus<Person> status2 = binder.validate(); BinderValidationStatus<?> status = statusCapture.get(); - Assert.assertSame(status2, status); + assertSame(status2, status); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); List<BindingValidationStatus<?>> bindingStatuses = status .getFieldValidationStatuses(); - Assert.assertNotNull(bindingStatuses); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, bindingStatuses.size()); + assertNotNull(bindingStatuses); + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals(2, bindingStatuses.size()); BindingValidationStatus<?> r = bindingStatuses.get(0); - Assert.assertTrue(r.isError()); - Assert.assertEquals(EMPTY_ERROR_MESSAGE, r.getMessage().get()); - Assert.assertEquals(nameField, r.getField()); + assertTrue(r.isError()); + assertEquals(EMPTY_ERROR_MESSAGE, r.getMessage().get()); + assertEquals(nameField, r.getField()); r = bindingStatuses.get(1); - Assert.assertFalse(r.isError()); - Assert.assertFalse(r.getMessage().isPresent()); - Assert.assertEquals(ageField, r.getField()); + assertFalse(r.isError()); + assertFalse(r.getMessage().isPresent()); + assertEquals(ageField, r.getField()); - Assert.assertEquals(0, status.getBeanValidationResults().size()); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); + assertEquals(0, status.getBeanValidationResults().size()); + assertEquals(0, status.getBeanValidationErrors().size()); nameField.setValue("foo"); ageField.setValue(""); @@ -264,21 +269,21 @@ public class BinderValidationStatusTest status = statusCapture.get(); bindingStatuses = status.getFieldValidationStatuses(); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, bindingStatuses.size()); + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals(2, bindingStatuses.size()); r = bindingStatuses.get(0); - Assert.assertFalse(r.isError()); - Assert.assertFalse(r.getMessage().isPresent()); - Assert.assertEquals(nameField, r.getField()); + assertFalse(r.isError()); + assertFalse(r.getMessage().isPresent()); + assertEquals(nameField, r.getField()); r = bindingStatuses.get(1); - Assert.assertTrue(r.isError()); - Assert.assertEquals("Value must be a number", r.getMessage().get()); - Assert.assertEquals(ageField, r.getField()); + assertTrue(r.isError()); + assertEquals("Value must be a number", r.getMessage().get()); + assertEquals(ageField, r.getField()); - Assert.assertEquals(0, status.getBeanValidationResults().size()); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); + assertEquals(0, status.getBeanValidationResults().size()); + assertEquals(0, status.getBeanValidationErrors().size()); statusCapture.set(null); // binding validations pass, binder validation fails @@ -287,11 +292,11 @@ public class BinderValidationStatusTest status = statusCapture.get(); bindingStatuses = status.getFieldValidationStatuses(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, bindingStatuses.size()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(2, bindingStatuses.size()); - Assert.assertEquals(0, status.getBeanValidationResults().size()); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); + assertEquals(0, status.getBeanValidationResults().size()); + assertEquals(0, status.getBeanValidationErrors().size()); } @Test @@ -299,13 +304,11 @@ public class BinderValidationStatusTest AtomicReference<BinderValidationStatus<?>> statusCapture = new AtomicReference<>(); binder.forField(nameField).withValidator(notEmpty) .withValidationStatusHandler(evt -> { - Assert.fail( - "Using a custom status change handler so no change should end up here"); + fail("Using a custom status change handler so no change should end up here"); }).bind(Person::getFirstName, Person::setFirstName); binder.forField(ageField).withConverter(stringToInteger) .withValidator(notNegative).withValidationStatusHandler(evt -> { - Assert.fail( - "Using a custom status change handler so no change should end up here"); + fail("Using a custom status change handler so no change should end up here"); }).bind(Person::getAge, Person::setAge); binder.withValidator( bean -> !bean.getFirstName().isEmpty() && bean.getAge() > 0, @@ -315,7 +318,7 @@ public class BinderValidationStatusTest statusCapture.set(r); }); binder.setBean(item); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); nameField.setValue(""); ageField.setValue("5"); @@ -324,28 +327,28 @@ public class BinderValidationStatusTest // and message BinderValidationStatus<Person> status2 = binder.validate(); BinderValidationStatus<?> status = statusCapture.get(); - Assert.assertSame(status2, status); + assertSame(status2, status); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); List<BindingValidationStatus<?>> bindingStatuses = status .getFieldValidationStatuses(); - Assert.assertNotNull(bindingStatuses); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, bindingStatuses.size()); + assertNotNull(bindingStatuses); + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals(2, bindingStatuses.size()); BindingValidationStatus<?> r = bindingStatuses.get(0); - Assert.assertTrue(r.isError()); - Assert.assertEquals(EMPTY_ERROR_MESSAGE, r.getMessage().get()); - Assert.assertEquals(nameField, r.getField()); + assertTrue(r.isError()); + assertEquals(EMPTY_ERROR_MESSAGE, r.getMessage().get()); + assertEquals(nameField, r.getField()); r = bindingStatuses.get(1); - Assert.assertFalse(r.isError()); - Assert.assertFalse(r.getMessage().isPresent()); - Assert.assertEquals(ageField, r.getField()); + assertFalse(r.isError()); + assertFalse(r.getMessage().isPresent()); + assertEquals(ageField, r.getField()); - Assert.assertEquals(0, status.getBeanValidationResults().size()); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); + assertEquals(0, status.getBeanValidationResults().size()); + assertEquals(0, status.getBeanValidationErrors().size()); nameField.setValue("foo"); ageField.setValue(""); @@ -357,21 +360,21 @@ public class BinderValidationStatusTest status = statusCapture.get(); bindingStatuses = status.getFieldValidationStatuses(); - Assert.assertEquals(1, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, bindingStatuses.size()); + assertEquals(1, status.getFieldValidationErrors().size()); + assertEquals(2, bindingStatuses.size()); r = bindingStatuses.get(0); - Assert.assertFalse(r.isError()); - Assert.assertFalse(r.getMessage().isPresent()); - Assert.assertEquals(nameField, r.getField()); + assertFalse(r.isError()); + assertFalse(r.getMessage().isPresent()); + assertEquals(nameField, r.getField()); r = bindingStatuses.get(1); - Assert.assertTrue(r.isError()); - Assert.assertEquals("Value must be a number", r.getMessage().get()); - Assert.assertEquals(ageField, r.getField()); + assertTrue(r.isError()); + assertEquals("Value must be a number", r.getMessage().get()); + assertEquals(ageField, r.getField()); - Assert.assertEquals(0, status.getBeanValidationResults().size()); - Assert.assertEquals(0, status.getBeanValidationErrors().size()); + assertEquals(0, status.getBeanValidationResults().size()); + assertEquals(0, status.getBeanValidationErrors().size()); statusCapture.set(null); // binding validations pass, binder validation fails @@ -380,13 +383,13 @@ public class BinderValidationStatusTest status = statusCapture.get(); bindingStatuses = status.getFieldValidationStatuses(); - Assert.assertEquals(0, status.getFieldValidationErrors().size()); - Assert.assertEquals(2, bindingStatuses.size()); + assertEquals(0, status.getFieldValidationErrors().size()); + assertEquals(2, bindingStatuses.size()); - Assert.assertEquals(1, status.getBeanValidationResults().size()); - Assert.assertEquals(1, status.getBeanValidationErrors().size()); + assertEquals(1, status.getBeanValidationResults().size()); + assertEquals(1, status.getBeanValidationErrors().size()); - Assert.assertEquals("Need first name and age", + assertEquals("Need first name and age", status.getBeanValidationErrors().get(0).getErrorMessage()); } @@ -396,7 +399,7 @@ public class BinderValidationStatusTest .withValidator(notEmpty).withValidationStatusHandler(evt -> { }).bind(Person::getFirstName, Person::setFirstName); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); nameField.setValue(""); @@ -405,7 +408,7 @@ public class BinderValidationStatusTest binding.validate(); // no component error since default handler is replaced - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); } @Test @@ -416,7 +419,7 @@ public class BinderValidationStatusTest .withValidator(notEmpty).withStatusLabel(label) .bind(Person::getFirstName, Person::setFirstName); - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); nameField.setValue(""); @@ -425,7 +428,7 @@ public class BinderValidationStatusTest binding.validate(); // default behavior should update component error for the nameField - Assert.assertNull(nameField.getComponentError()); + assertNull(nameField.getComponentError()); } @Test(expected = IllegalStateException.class) @@ -434,7 +437,7 @@ public class BinderValidationStatusTest .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); - binding.withValidationStatusHandler(evt -> Assert.fail()); + binding.withValidationStatusHandler(evt -> fail()); } @Test(expected = IllegalStateException.class) @@ -487,7 +490,7 @@ public class BinderValidationStatusTest binding.bind(Person::getFirstName, Person::setFirstName); binder.setValidationStatusHandler(results -> { - Assert.fail(); + fail(); }); binder.setValidationStatusHandler(results -> { @@ -499,8 +502,8 @@ public class BinderValidationStatusTest List<BindingValidationStatus<?>> results = capture.get() .getFieldValidationStatuses(); - Assert.assertNotNull(results); - Assert.assertEquals(1, results.size()); - Assert.assertFalse(results.get(0).isError()); + assertNotNull(results); + assertEquals(1, results.size()); + assertFalse(results.get(0).isError()); } } diff --git a/server/src/test/java/com/vaadin/data/BinderValueChangeTest.java b/server/src/test/java/com/vaadin/data/BinderValueChangeTest.java index 985d0cc650..fbe1ee1d1f 100644 --- a/server/src/test/java/com/vaadin/data/BinderValueChangeTest.java +++ b/server/src/test/java/com/vaadin/data/BinderValueChangeTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.concurrent.atomic.AtomicReference; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,32 +60,32 @@ public class BinderValueChangeTest BindingBuilder<Person, String> binding = binder.forField(nameField); nameField.setValue(""); - Assert.assertNull(event.get()); + assertNull(event.get()); binding.bind(Person::getFirstName, Person::setFirstName); - Assert.assertNull(event.get()); + assertNull(event.get()); } @Test public void setBean_unbound_noEvents() { binder.addValueChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.setBean(item); - Assert.assertNull(event.get()); + assertNull(event.get()); } @Test public void readBean_unbound_noEvents() { binder.addValueChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); binder.readBean(item); - Assert.assertNull(event.get()); + assertNull(event.get()); } @Test @@ -95,7 +98,7 @@ public class BinderValueChangeTest binder.addValueChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); nameField.setValue("foo"); verifyEvent(nameField); } @@ -111,7 +114,7 @@ public class BinderValueChangeTest binder.addValueChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); nameField.setValue("foo"); verifyEvent(nameField); } @@ -127,7 +130,7 @@ public class BinderValueChangeTest binder.addValueChangeListener(this::statusChanged); - Assert.assertNull(event.get()); + assertNull(event.get()); field.setValue("foo", true); verifyEvent(field, true); } @@ -143,7 +146,7 @@ public class BinderValueChangeTest .bind(Person::getAge, Person::setAge); binder.setBean(item); - Assert.assertNull(event.get()); + assertNull(event.get()); ageField.setValue(String.valueOf(1)); verifyEvent(ageField); } @@ -154,14 +157,14 @@ public class BinderValueChangeTest private void verifyEvent(HasValue<?> field, boolean isUserOriginated) { ValueChangeEvent<?> changeEvent = event.get(); - Assert.assertNotNull(changeEvent); - Assert.assertEquals(field, changeEvent.getSource()); - Assert.assertEquals(field, changeEvent.getComponent()); - Assert.assertEquals(isUserOriginated, changeEvent.isUserOriginated()); + assertNotNull(changeEvent); + assertEquals(field, changeEvent.getSource()); + assertEquals(field, changeEvent.getComponent()); + assertEquals(isUserOriginated, changeEvent.isUserOriginated()); } private void statusChanged(ValueChangeEvent<?> evt) { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(evt); } } diff --git a/server/src/test/java/com/vaadin/data/HasValueTest.java b/server/src/test/java/com/vaadin/data/HasValueTest.java index 5f255454c9..5b3a996740 100644 --- a/server/src/test/java/com/vaadin/data/HasValueTest.java +++ b/server/src/test/java/com/vaadin/data/HasValueTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; + import java.time.LocalDate; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -58,14 +60,13 @@ public class HasValueTest { assert nullable.isEmpty(); assert nullable.getValue() == null; - Assert.assertFalse(nullable.getOptionalValue().isPresent()); + assertFalse(nullable.getOptionalValue().isPresent()); nullable.setValue(LocalDate.now()); assert !nullable.isEmpty(); - Assert.assertSame(nullable.getValue(), - nullable.getOptionalValue().get()); + assertSame(nullable.getValue(), nullable.getOptionalValue().get()); } @Test @@ -77,13 +78,13 @@ public class HasValueTest { assert nonNullable.isEmpty(); assert nonNullable.getValue() != null; - Assert.assertFalse(nonNullable.getOptionalValue().isPresent()); + assertFalse(nonNullable.getOptionalValue().isPresent()); nonNullable.setValue("foo"); assert !nonNullable.isEmpty(); - Assert.assertSame(nonNullable.getValue(), + assertSame(nonNullable.getValue(), nonNullable.getOptionalValue().get()); } } diff --git a/server/src/test/java/com/vaadin/data/Jsr303Test.java b/server/src/test/java/com/vaadin/data/Jsr303Test.java index c907bd2af0..7463e0198a 100644 --- a/server/src/test/java/com/vaadin/data/Jsr303Test.java +++ b/server/src/test/java/com/vaadin/data/Jsr303Test.java @@ -16,6 +16,8 @@ package com.vaadin.data; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; @@ -26,7 +28,6 @@ import java.net.URLClassLoader; import javax.validation.Validation; import org.apache.commons.io.IOUtils; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.util.BeanUtil; @@ -82,7 +83,7 @@ public class Jsr303Test { @Override public void execute() { - Assert.assertFalse(BeanUtil.checkBeanValidationAvailable()); + assertFalse(BeanUtil.checkBeanValidationAvailable()); Binder<BeanToValidate> binder = new Binder<>(BeanToValidate.class); BeanToValidate item = new BeanToValidate(); @@ -102,7 +103,7 @@ public class Jsr303Test { try { BeanValidationBinder<BeanToValidate> beanValidationBinder = new BeanValidationBinder<>( BeanToValidate.class); - Assert.fail(); + fail(); } catch (IllegalStateException ignore) { // an exception has to be thrown } diff --git a/server/src/test/java/com/vaadin/data/NotEmptyTest.java b/server/src/test/java/com/vaadin/data/NotEmptyTest.java index 6b13825455..adda12f71d 100644 --- a/server/src/test/java/com/vaadin/data/NotEmptyTest.java +++ b/server/src/test/java/com/vaadin/data/NotEmptyTest.java @@ -15,6 +15,9 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; @@ -23,7 +26,6 @@ import java.net.URLClassLoader; import org.apache.commons.io.IOUtils; import org.hibernate.validator.constraints.NotEmpty; -import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.data.bean.BeanToValidate; @@ -82,7 +84,7 @@ public class NotEmptyTest { try { Class.forName(NOT_EMPTY); // The NotEmpty class must not be in the classpath - Assert.fail(); + fail(); } catch (ClassNotFoundException e) { } BeanValidationBinder<BeanToValidate> binder = new BeanValidationBinder<>( @@ -96,7 +98,7 @@ public class NotEmptyTest { binder.bind(nameField, "firstname"); binder.setBean(item); - Assert.assertTrue(nameField.isRequiredIndicatorVisible()); + assertTrue(nameField.isRequiredIndicatorVisible()); } } diff --git a/server/src/test/java/com/vaadin/data/ResultTest.java b/server/src/test/java/com/vaadin/data/ResultTest.java index 8f594c1300..69c5a86c04 100644 --- a/server/src/test/java/com/vaadin/data/ResultTest.java +++ b/server/src/test/java/com/vaadin/data/ResultTest.java @@ -15,7 +15,11 @@ */ package com.vaadin.data; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.server.SerializableFunction; @@ -30,28 +34,28 @@ public class ResultTest { public void testOk() { String value = "foo"; Result<String> ok = Result.ok(value); - Assert.assertFalse(ok.isError()); - Assert.assertFalse(ok.getMessage().isPresent()); - ok.ifOk(v -> Assert.assertEquals(value, v)); - ok.ifError(msg -> Assert.fail()); + assertFalse(ok.isError()); + assertFalse(ok.getMessage().isPresent()); + ok.ifOk(v -> assertEquals(value, v)); + ok.ifError(msg -> fail()); } @Test public void testError() { String message = "foo"; Result<String> error = Result.error(message); - Assert.assertTrue(error.isError()); - Assert.assertTrue(error.getMessage().isPresent()); - error.ifOk(v -> Assert.fail()); - error.ifError(msg -> Assert.assertEquals(message, msg)); - Assert.assertEquals(message, error.getMessage().get()); + assertTrue(error.isError()); + assertTrue(error.getMessage().isPresent()); + error.ifOk(v -> fail()); + error.ifError(msg -> assertEquals(message, msg)); + assertEquals(message, error.getMessage().get()); } @Test public void of_noException() { Result<String> result = Result.of(() -> "", exception -> null); - Assert.assertTrue(result instanceof SimpleResult); - Assert.assertFalse(result.isError()); + assertTrue(result instanceof SimpleResult); + assertFalse(result.isError()); } @Test @@ -60,9 +64,9 @@ public class ResultTest { Result<String> result = Result.of(() -> { throw new RuntimeException(); }, exception -> message); - Assert.assertTrue(result instanceof SimpleResult); - Assert.assertTrue(result.isError()); - Assert.assertEquals(message, result.getMessage().get()); + assertTrue(result instanceof SimpleResult); + assertTrue(result.isError()); + assertEquals(message, result.getMessage().get()); } @SuppressWarnings("serial") @@ -77,12 +81,12 @@ public class ResultTest { } }; Result<String> mapResult = result.map(value -> { - Assert.assertEquals("foo", value); + assertEquals("foo", value); return "bar"; }); - Assert.assertTrue(mapResult instanceof SimpleResult); - Assert.assertFalse(mapResult.isError()); - mapResult.ifOk(v -> Assert.assertEquals("bar", v)); + assertTrue(mapResult instanceof SimpleResult); + assertFalse(mapResult.isError()); + mapResult.ifOk(v -> assertEquals("bar", v)); } @SuppressWarnings("serial") @@ -97,11 +101,11 @@ public class ResultTest { } }; Result<String> mapResult = result.map(value -> { - Assert.assertEquals("foo", value); + assertEquals("foo", value); return "somevalue"; }); - Assert.assertTrue(mapResult instanceof SimpleResult); - Assert.assertTrue(mapResult.isError()); - mapResult.ifError(msg -> Assert.assertEquals("bar", msg)); + assertTrue(mapResult instanceof SimpleResult); + assertTrue(mapResult.isError()); + mapResult.ifError(msg -> assertEquals("bar", msg)); } } diff --git a/server/src/test/java/com/vaadin/data/ValidatorTest.java b/server/src/test/java/com/vaadin/data/ValidatorTest.java index 75ac1fcf5a..7d29b6941e 100644 --- a/server/src/test/java/com/vaadin/data/ValidatorTest.java +++ b/server/src/test/java/com/vaadin/data/ValidatorTest.java @@ -15,10 +15,12 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Locale; import java.util.Objects; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.validator.ValidatorTestBase; @@ -33,7 +35,7 @@ public class ValidatorTest extends ValidatorTestBase { public void alwaysPass() { Validator<String> alwaysPass = Validator.alwaysPass(); ValidationResult result = alwaysPass.apply("foo", new ValueContext()); - Assert.assertFalse(result.isError()); + assertFalse(result.isError()); } @Test @@ -41,10 +43,10 @@ public class ValidatorTest extends ValidatorTestBase { Validator<String> validator = Validator.from(Objects::nonNull, "Cannot be null"); ValidationResult result = validator.apply(null, new ValueContext()); - Assert.assertTrue(result.isError()); + assertTrue(result.isError()); result = validator.apply("", new ValueContext()); - Assert.assertFalse(result.isError()); + assertFalse(result.isError()); } @Test diff --git a/server/src/test/java/com/vaadin/data/ValueContextTest.java b/server/src/test/java/com/vaadin/data/ValueContextTest.java index b96f7463cb..9dd0e90b69 100644 --- a/server/src/test/java/com/vaadin/data/ValueContextTest.java +++ b/server/src/test/java/com/vaadin/data/ValueContextTest.java @@ -1,14 +1,15 @@ package com.vaadin.data; +import static org.junit.Assert.assertEquals; + import java.util.Locale; import java.util.Objects; -import com.vaadin.ui.CheckBox; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; import com.vaadin.ui.UI; @@ -24,8 +25,8 @@ public class ValueContextTest extends UI { ValueContext fromComponent = new ValueContext(textField); Locale locale = fromComponent.getLocale().orElse(null); Objects.requireNonNull(locale); - Assert.assertEquals("Unexpected locale from component", - COMPONENT_LOCALE, locale); + assertEquals("Unexpected locale from component", COMPONENT_LOCALE, + locale); } @Test @@ -33,8 +34,7 @@ public class ValueContextTest extends UI { ValueContext fromComponent = new ValueContext(textField); Locale locale = fromComponent.getLocale().orElse(null); Objects.requireNonNull(locale); - Assert.assertEquals("Unexpected locale from component", UI_LOCALE, - locale); + assertEquals("Unexpected locale from component", UI_LOCALE, locale); } @Test @@ -43,30 +43,32 @@ public class ValueContextTest extends UI { ValueContext fromComponent = new ValueContext(textField); Locale locale = fromComponent.getLocale().orElse(null); Objects.requireNonNull(locale); - Assert.assertEquals("Unexpected locale from component", - Locale.getDefault(), locale); + assertEquals("Unexpected locale from component", Locale.getDefault(), + locale); } @Test public void testHasValue1() { setLocale(null); ValueContext fromComponent = new ValueContext(textField); - Assert.assertEquals(textField, fromComponent.getHasValue().get()); + assertEquals(textField, fromComponent.getHasValue().get()); } @Test public void testHasValue2() { setLocale(null); - ValueContext fromComponent = new ValueContext(new CheckBox(), textField); - Assert.assertEquals(textField, fromComponent.getHasValue().get()); + ValueContext fromComponent = new ValueContext(new CheckBox(), + textField); + assertEquals(textField, fromComponent.getHasValue().get()); } @Test public void testHasValue3() { setLocale(null); - ValueContext fromComponent = new ValueContext(new CheckBox(), textField, Locale.CANADA); - Assert.assertEquals(textField, fromComponent.getHasValue().get()); - Assert.assertEquals(Locale.CANADA, fromComponent.getLocale().get()); + ValueContext fromComponent = new ValueContext(new CheckBox(), textField, + Locale.CANADA); + assertEquals(textField, fromComponent.getHasValue().get()); + assertEquals(Locale.CANADA, fromComponent.getLocale().get()); } @Before diff --git a/server/src/test/java/com/vaadin/data/provider/AbstractDataProviderTest.java b/server/src/test/java/com/vaadin/data/provider/AbstractDataProviderTest.java index 3cd368944d..6e94d94b50 100644 --- a/server/src/test/java/com/vaadin/data/provider/AbstractDataProviderTest.java +++ b/server/src/test/java/com/vaadin/data/provider/AbstractDataProviderTest.java @@ -15,10 +15,13 @@ */ package com.vaadin.data.provider; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.Registration; @@ -53,12 +56,12 @@ public class AbstractDataProviderTest { TestDataProvider dataProvider = new TestDataProvider(); AtomicReference<DataChangeEvent<Object>> event = new AtomicReference<>(); dataProvider.addDataProviderListener(ev -> { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(ev); }); dataProvider.refreshAll(); - Assert.assertNotNull(event.get()); - Assert.assertEquals(dataProvider, event.get().getSource()); + assertNotNull(event.get()); + assertEquals(dataProvider, event.get().getSource()); } @Test @@ -69,6 +72,6 @@ public class AbstractDataProviderTest { .addDataProviderListener(ev -> event.set(ev)); registration.remove(); dataProvider.refreshAll(); - Assert.assertNull(event.get()); + assertNull(event.get()); } } diff --git a/server/src/test/java/com/vaadin/data/provider/ConfigurableFilterDataProviderWrapperTest.java b/server/src/test/java/com/vaadin/data/provider/ConfigurableFilterDataProviderWrapperTest.java index b2be27bd8d..5d31dcb150 100644 --- a/server/src/test/java/com/vaadin/data/provider/ConfigurableFilterDataProviderWrapperTest.java +++ b/server/src/test/java/com/vaadin/data/provider/ConfigurableFilterDataProviderWrapperTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.data.provider; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.data.provider.BackendDataProviderTest.StrBeanBackEndDataProvider; @@ -48,12 +49,12 @@ public class ConfigurableFilterDataProviderWrapperTest { public void void_setFilter() { configurableVoid.setFilter(xyzFilter); - Assert.assertEquals("Set filter should be used", 1, + assertEquals("Set filter should be used", 1, configurableVoid.size(new Query<>())); configurableVoid.setFilter(null); - Assert.assertEquals("null filter should return all items", 100, + assertEquals("null filter should return all items", 100, configurableVoid.size(new Query<>())); } @@ -68,21 +69,21 @@ public class ConfigurableFilterDataProviderWrapperTest { public void predicate_setFilter() { configurablePredicate.setFilter(Integer.valueOf(50)); - Assert.assertEquals("Set filter should be used", 49, + assertEquals("Set filter should be used", 49, configurablePredicate.size(new Query<>())); configurablePredicate.setFilter(null); - Assert.assertEquals("null filter should return all items", 100, + assertEquals("null filter should return all items", 100, configurablePredicate.size(new Query<>())); } @Test public void predicate_queryFilter() { - Assert.assertEquals("Query filter should be used", 1, + assertEquals("Query filter should be used", 1, configurablePredicate.size(new Query<>("Xyz"))); - Assert.assertEquals("null query filter should return all items", 100, + assertEquals("null query filter should return all items", 100, configurablePredicate.size(new Query<>())); } @@ -90,12 +91,12 @@ public class ConfigurableFilterDataProviderWrapperTest { public void predicate_combinedFilters() { configurablePredicate.setFilter(Integer.valueOf(50)); - Assert.assertEquals("Both filters should be used", 0, + assertEquals("Both filters should be used", 0, configurablePredicate.size(new Query<>("Xyz"))); configurablePredicate.setFilter(null); - Assert.assertEquals("Only zyz filter should be used", 1, + assertEquals("Only zyz filter should be used", 1, configurablePredicate.size(new Query<>("Xyz"))); } diff --git a/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java b/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java index 53913325a5..d3b4add32b 100644 --- a/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java +++ b/server/src/test/java/com/vaadin/data/provider/DataCommunicatorTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.data.provider; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Collections; import java.util.concurrent.Future; -import elemental.json.Json; -import elemental.json.JsonArray; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -31,10 +32,10 @@ import com.vaadin.server.VaadinSession; import com.vaadin.shared.Registration; import com.vaadin.ui.UI; +import elemental.json.Json; +import elemental.json.JsonArray; import elemental.json.JsonObject; -import static org.junit.Assert.assertFalse; - /** * @author Vaadin Ltd * @@ -134,7 +135,7 @@ public class DataCommunicatorTest { communicator.extend(ui); - Assert.assertTrue(dataProvider.isListenerAdded()); + assertTrue(dataProvider.isListenerAdded()); } @Test @@ -150,7 +151,7 @@ public class DataCommunicatorTest { communicator.extend(ui); - Assert.assertTrue(dataProvider.isListenerAdded()); + assertTrue(dataProvider.isListenerAdded()); communicator.detach(); @@ -174,25 +175,25 @@ public class DataCommunicatorTest { // Generate initial data. communicator.beforeClientResponse(true); - Assert.assertEquals("DataGenerator generate was not called", - TEST_OBJECT, generator.generated); + assertEquals("DataGenerator generate was not called", TEST_OBJECT, + generator.generated); generator.generated = null; // Make sure data does not get re-generated communicator.beforeClientResponse(false); - Assert.assertEquals("DataGenerator generate was called again", null, + assertEquals("DataGenerator generate was called again", null, generator.generated); // Refresh a data object to trigger an update. dataProvider.refreshItem(TEST_OBJECT); - Assert.assertEquals("DataGenerator refresh was not called", TEST_OBJECT, + assertEquals("DataGenerator refresh was not called", TEST_OBJECT, generator.refreshed); // Test refreshed data generation communicator.beforeClientResponse(false); - Assert.assertEquals("DataGenerator generate was not called", - TEST_OBJECT, generator.generated); + assertEquals("DataGenerator generate was not called", TEST_OBJECT, + generator.generated); } @Test @@ -213,7 +214,8 @@ public class DataCommunicatorTest { keys.set(0, key); communicator.onDropRows(keys); // Replace everything - communicator.setDataProvider(new ListDataProvider<>(Collections.singleton(new Object()))); + communicator.setDataProvider( + new ListDataProvider<>(Collections.singleton(new Object()))); // The communicator does not have to throw exceptions during // request finalization communicator.beforeClientResponse(false); diff --git a/server/src/test/java/com/vaadin/data/provider/DataProviderTestBase.java b/server/src/test/java/com/vaadin/data/provider/DataProviderTestBase.java index 2fea57ae80..20513674d9 100644 --- a/server/src/test/java/com/vaadin/data/provider/DataProviderTestBase.java +++ b/server/src/test/java/com/vaadin/data/provider/DataProviderTestBase.java @@ -1,5 +1,7 @@ package com.vaadin.data.provider; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import java.util.Comparator; @@ -7,7 +9,6 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -87,16 +88,15 @@ public abstract class DataProviderTestBase<D extends DataProvider<StrBean, Seria .collect(Collectors.toList()); // First value in data is { Xyz, 10, 100 } which should be last in list - Assert.assertNotEquals("First value should not match", data.get(0), + assertNotEquals("First value should not match", data.get(0), list.get(0)); - Assert.assertEquals("Sorted data and original data sizes don't match", + assertEquals("Sorted data and original data sizes don't match", data.size(), list.size()); data.sort(comp); for (int i = 0; i < data.size(); ++i) { - Assert.assertEquals("Sorting result differed", data.get(i), - list.get(i)); + assertEquals("Sorting result differed", data.get(i), list.get(i)); } } @@ -111,24 +111,23 @@ public abstract class DataProviderTestBase<D extends DataProvider<StrBean, Seria Comparator.comparing(StrBean::getRandomNumber))) .collect(Collectors.toList()); - Assert.assertEquals("Sorted data and original data sizes don't match", + assertEquals("Sorted data and original data sizes don't match", data.size(), list.size()); for (int i = 1; i < list.size(); ++i) { StrBean prev = list.get(i - 1); StrBean cur = list.get(i); // Test specific sort - Assert.assertTrue( + assertTrue( "Failure: " + prev.getRandomNumber() + " > " + cur.getRandomNumber(), prev.getRandomNumber() <= cur.getRandomNumber()); if (prev.getRandomNumber() == cur.getRandomNumber()) { // Test default sort - Assert.assertTrue( - prev.getValue().compareTo(cur.getValue()) <= 0); + assertTrue(prev.getValue().compareTo(cur.getValue()) <= 0); if (prev.getValue().equals(cur.getValue())) { - Assert.assertTrue(prev.getId() > cur.getId()); + assertTrue(prev.getId() > cur.getId()); } } } @@ -142,7 +141,7 @@ public abstract class DataProviderTestBase<D extends DataProvider<StrBean, Seria List<StrBean> list = dataProvider.fetch(new Query<>()) .collect(Collectors.toList()); - Assert.assertEquals("Sorted data and original data sizes don't match", + assertEquals("Sorted data and original data sizes don't match", data.size(), list.size()); for (int i = 1; i < list.size(); ++i) { @@ -150,7 +149,7 @@ public abstract class DataProviderTestBase<D extends DataProvider<StrBean, Seria StrBean cur = list.get(i); // Test default sort - Assert.assertTrue(prev.getValue().compareTo(cur.getValue()) <= 0); + assertTrue(prev.getValue().compareTo(cur.getValue()) <= 0); } } @@ -159,25 +158,24 @@ public abstract class DataProviderTestBase<D extends DataProvider<StrBean, Seria DataProvider<StrBean, String> strFilterDataProvider = dataProvider .withConvertedFilter( text -> strBean -> strBean.getValue().contains(text)); - Assert.assertEquals("Only one item should match 'Xyz'", 1, + assertEquals("Only one item should match 'Xyz'", 1, strFilterDataProvider.size(new Query<>("Xyz"))); - Assert.assertEquals("No item should match 'Zyx'", 0, + assertEquals("No item should match 'Zyx'", 0, strFilterDataProvider.size(new Query<>("Zyx"))); - Assert.assertEquals("Unexpected number of matches for 'Foo'", 36, + assertEquals("Unexpected number of matches for 'Foo'", 36, strFilterDataProvider.size(new Query<>("Foo"))); - Assert.assertEquals("No items should've been filtered out", data.size(), + assertEquals("No items should've been filtered out", data.size(), strFilterDataProvider.size(new Query<>())); } @Test public void filteringListDataProvider_defaultFilterType() { - Assert.assertEquals("Only one item should match 'Xyz'", 1, - dataProvider.size(new Query<>( - strBean -> strBean.getValue().contains("Xyz")))); - Assert.assertEquals("No item should match 'Zyx'", 0, dataProvider.size( + assertEquals("Only one item should match 'Xyz'", 1, dataProvider.size( + new Query<>(strBean -> strBean.getValue().contains("Xyz")))); + assertEquals("No item should match 'Zyx'", 0, dataProvider.size( new Query<>(strBean -> strBean.getValue().contains("Zyx")))); - Assert.assertEquals("Unexpected number of matches for 'Foo'", 36, + assertEquals("Unexpected number of matches for 'Foo'", 36, dataProvider.size(new Query<>(fooFilter))); } @@ -187,8 +185,7 @@ public abstract class DataProviderTestBase<D extends DataProvider<StrBean, Seria protected static <F> void assertSizeWithFilter(int expectedSize, DataProvider<?, F> dataProvider, F filterValue) { - Assert.assertEquals(expectedSize, - dataProvider.size(new Query<>(filterValue))); + assertEquals(expectedSize, dataProvider.size(new Query<>(filterValue))); } } diff --git a/server/src/test/java/com/vaadin/data/provider/ListDataProviderTest.java b/server/src/test/java/com/vaadin/data/provider/ListDataProviderTest.java index 1ffa444f50..8b1792689a 100644 --- a/server/src/test/java/com/vaadin/data/provider/ListDataProviderTest.java +++ b/server/src/test/java/com/vaadin/data/provider/ListDataProviderTest.java @@ -1,11 +1,14 @@ package com.vaadin.data.provider; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.SerializableComparator; @@ -28,7 +31,7 @@ public class ListDataProviderTest int[] threeFirstIds = dataProvider.fetch(new Query<>()) .mapToInt(StrBean::getId).limit(3).toArray(); - Assert.assertArrayEquals(new int[] { 0, 1, 2 }, threeFirstIds); + assertArrayEquals(new int[] { 0, 1, 2 }, threeFirstIds); } @Test @@ -40,7 +43,7 @@ public class ListDataProviderTest int[] threeFirstIds = dataProvider.fetch(new Query<>()) .mapToInt(StrBean::getId).limit(3).toArray(); - Assert.assertArrayEquals(new int[] { 98, 97, 96 }, threeFirstIds); + assertArrayEquals(new int[] { 98, 97, 96 }, threeFirstIds); } @Test @@ -54,54 +57,51 @@ public class ListDataProviderTest .limit(3).collect(Collectors.toList()); // First one is Xyz - Assert.assertEquals(new StrBean("Xyz", 10, 100), - threeFirstItems.get(0)); + assertEquals(new StrBean("Xyz", 10, 100), threeFirstItems.get(0)); // The following are Foos ordered by id - Assert.assertEquals(new StrBean("Foo", 93, 2), threeFirstItems.get(1)); - Assert.assertEquals(new StrBean("Foo", 91, 2), threeFirstItems.get(2)); + assertEquals(new StrBean("Foo", 93, 2), threeFirstItems.get(1)); + assertEquals(new StrBean("Foo", 91, 2), threeFirstItems.get(2)); } @Test public void setFilter() { dataProvider.setFilter(item -> item.getValue().equals("Foo")); - Assert.assertEquals(36, sizeWithUnfilteredQuery()); + assertEquals(36, sizeWithUnfilteredQuery()); dataProvider.setFilter(item -> !item.getValue().equals("Foo")); - Assert.assertEquals( - "Previous filter should be reset when setting a new one", 64, - sizeWithUnfilteredQuery()); + assertEquals("Previous filter should be reset when setting a new one", + 64, sizeWithUnfilteredQuery()); dataProvider.setFilter(null); - Assert.assertEquals("Setting filter to null should remove all filters", - 100, sizeWithUnfilteredQuery()); + assertEquals("Setting filter to null should remove all filters", 100, + sizeWithUnfilteredQuery()); } @Test public void setFilter_valueProvider() { dataProvider.setFilter(StrBean::getValue, "Foo"::equals); - Assert.assertEquals(36, sizeWithUnfilteredQuery()); + assertEquals(36, sizeWithUnfilteredQuery()); dataProvider.setFilter(StrBean::getValue, value -> !value.equals("Foo")); - Assert.assertEquals( - "Previous filter should be reset when setting a new one", 64, - sizeWithUnfilteredQuery()); + assertEquals("Previous filter should be reset when setting a new one", + 64, sizeWithUnfilteredQuery()); } @Test public void setFilterEquals() { dataProvider.setFilterByValue(StrBean::getValue, "Foo"); - Assert.assertEquals(36, sizeWithUnfilteredQuery()); + assertEquals(36, sizeWithUnfilteredQuery()); dataProvider.setFilterByValue(StrBean::getValue, "Bar"); - Assert.assertEquals(23, sizeWithUnfilteredQuery()); + assertEquals(23, sizeWithUnfilteredQuery()); } @Test @@ -110,7 +110,7 @@ public class ListDataProviderTest dataProvider.addFilter(item -> item.getId() > 50); - Assert.assertEquals("Both filters should be used", 17, + assertEquals("Both filters should be used", 17, sizeWithUnfilteredQuery()); } @@ -118,7 +118,7 @@ public class ListDataProviderTest public void addFilter_noPreviousFilter() { dataProvider.addFilter(item -> item.getId() > 50); - Assert.assertEquals(48, sizeWithUnfilteredQuery()); + assertEquals(48, sizeWithUnfilteredQuery()); } @Test @@ -127,7 +127,7 @@ public class ListDataProviderTest dataProvider.addFilter(StrBean::getValue, "Foo"::equals); - Assert.assertEquals("Both filters should be used", 17, + assertEquals("Both filters should be used", 17, sizeWithUnfilteredQuery()); } @@ -137,7 +137,7 @@ public class ListDataProviderTest dataProvider.addFilterByValue(StrBean::getValue, "Foo"); - Assert.assertEquals("Both filters should be used", 17, + assertEquals("Both filters should be used", 17, sizeWithUnfilteredQuery()); } @@ -145,11 +145,11 @@ public class ListDataProviderTest public void addFilter_firstAddedUsedFirst() { dataProvider.addFilter(item -> false); dataProvider.addFilter(item -> { - Assert.fail("This filter should never be invoked"); + fail("This filter should never be invoked"); return true; }); - Assert.assertEquals(0, sizeWithUnfilteredQuery()); + assertEquals(0, sizeWithUnfilteredQuery()); } @Test @@ -158,7 +158,7 @@ public class ListDataProviderTest int size = dataProvider.size(new Query<>(item -> item.getId() > 50)); - Assert.assertEquals("Both filters should be used", 17, size); + assertEquals("Both filters should be used", 17, size); } @Test @@ -166,11 +166,11 @@ public class ListDataProviderTest dataProvider.setFilter(item -> false); int size = dataProvider.size(new Query<>(item -> { - Assert.fail("This filter should never be invoked"); + fail("This filter should never be invoked"); return true; })); - Assert.assertEquals(0, size); + assertEquals(0, size); } @Test diff --git a/server/src/test/java/com/vaadin/data/provider/ReplaceListDataProviderTest.java b/server/src/test/java/com/vaadin/data/provider/ReplaceListDataProviderTest.java index 5c7448d17e..d2181fdb34 100644 --- a/server/src/test/java/com/vaadin/data/provider/ReplaceListDataProviderTest.java +++ b/server/src/test/java/com/vaadin/data/provider/ReplaceListDataProviderTest.java @@ -1,9 +1,13 @@ package com.vaadin.data.provider; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; -import org.junit.Assert; import org.junit.Test; /** @@ -21,13 +25,13 @@ public class ReplaceListDataProviderTest { public void testGetIdOfItem() { Object id = dataProvider.fetch(new Query<>()).findFirst() .map(dataProvider::getId).get(); - Assert.assertEquals("DataProvider not using correct identifier getter", + assertEquals("DataProvider not using correct identifier getter", TEST_OBJECT.getId(), id); } @Test public void testGetIdOfReplacementItem() { - Assert.assertFalse("Test object was stale before making any changes.", + assertFalse("Test object was stale before making any changes.", dataProvider.isStale(TEST_OBJECT)); dataProvider.refreshItem(new StrBean("Replacement TestObject", 10, -2)); @@ -36,13 +40,13 @@ public class ReplaceListDataProviderTest { .get(); Object id = dataProvider.getId(fromDataProvider); - Assert.assertNotEquals("DataProvider did not return the replacement", + assertNotEquals("DataProvider did not return the replacement", TEST_OBJECT, fromDataProvider); - Assert.assertEquals("DataProvider not using correct identifier getter", + assertEquals("DataProvider not using correct identifier getter", TEST_OBJECT.getId(), id); - Assert.assertTrue("Old test object should be stale", + assertTrue("Old test object should be stale", dataProvider.isStale(TEST_OBJECT)); } } diff --git a/server/src/test/java/com/vaadin/data/provider/SortOrderBuildersTest.java b/server/src/test/java/com/vaadin/data/provider/SortOrderBuildersTest.java index e289686040..7939217969 100644 --- a/server/src/test/java/com/vaadin/data/provider/SortOrderBuildersTest.java +++ b/server/src/test/java/com/vaadin/data/provider/SortOrderBuildersTest.java @@ -1,10 +1,11 @@ package com.vaadin.data.provider; +import static org.junit.Assert.assertEquals; + import java.time.LocalDate; import java.util.Arrays; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.data.sort.SortDirection; @@ -55,12 +56,11 @@ public class SortOrderBuildersTest { private <T extends SortOrder<?>> void verifySortOrders(List<T> order1, List<T> order2) { - Assert.assertEquals(order1.size(), order2.size()); + assertEquals(order1.size(), order2.size()); for (int i = 0; i < order1.size(); i++) { - Assert.assertEquals(order1.get(i).getDirection(), + assertEquals(order1.get(i).getDirection(), order2.get(i).getDirection()); - Assert.assertEquals(order1.get(i).getSorted(), - order1.get(i).getSorted()); + assertEquals(order1.get(i).getSorted(), order1.get(i).getSorted()); } } } diff --git a/server/src/test/java/com/vaadin/data/provider/TreeDataProviderTest.java b/server/src/test/java/com/vaadin/data/provider/TreeDataProviderTest.java index 87b3ec0715..7d5f1c0909 100644 --- a/server/src/test/java/com/vaadin/data/provider/TreeDataProviderTest.java +++ b/server/src/test/java/com/vaadin/data/provider/TreeDataProviderTest.java @@ -1,5 +1,10 @@ package com.vaadin.data.provider; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -7,7 +12,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.TreeData; @@ -64,78 +68,78 @@ public class TreeDataProviderTest @Test public void treeData_remove_root_item() { data.removeItem(null); - Assert.assertTrue(data.getChildren(null).isEmpty()); + assertTrue(data.getChildren(null).isEmpty()); } @Test public void treeData_clear() { data.clear(); - Assert.assertTrue(data.getChildren(null).isEmpty()); + assertTrue(data.getChildren(null).isEmpty()); } @Test public void treeData_re_add_removed_item() { StrBean item = rootData.get(0); data.removeItem(item).addItem(null, item); - Assert.assertTrue(data.getChildren(null).contains(item)); + assertTrue(data.getChildren(null).contains(item)); } @Test public void treeData_get_parent() { StrBean root = rootData.get(0); StrBean firstChild = data.getChildren(root).get(0); - Assert.assertNull(data.getParent(root)); - Assert.assertEquals(root, data.getParent(firstChild)); + assertNull(data.getParent(root)); + assertEquals(root, data.getParent(firstChild)); } @Test public void treeData_set_parent() { StrBean item1 = rootData.get(0); StrBean item2 = rootData.get(1); - Assert.assertEquals(0, data.getChildren(item2).size()); - Assert.assertEquals(10, data.getRootItems().size()); + assertEquals(0, data.getChildren(item2).size()); + assertEquals(10, data.getRootItems().size()); // Move item1 as item2's child data.setParent(item1, item2); - Assert.assertEquals(1, data.getChildren(item2).size()); - Assert.assertEquals(9, data.getRootItems().size()); - Assert.assertEquals(item1, data.getChildren(item2).get(0)); + assertEquals(1, data.getChildren(item2).size()); + assertEquals(9, data.getRootItems().size()); + assertEquals(item1, data.getChildren(item2).get(0)); // Move back to root data.setParent(item1, null); - Assert.assertEquals(0, data.getChildren(item2).size()); - Assert.assertEquals(10, data.getRootItems().size()); + assertEquals(0, data.getChildren(item2).size()); + assertEquals(10, data.getRootItems().size()); } @Test public void treeData_move_after_sibling() { StrBean root0 = rootData.get(0); StrBean root9 = rootData.get(9); - Assert.assertEquals(root0, data.getRootItems().get(0)); - Assert.assertEquals(root9, data.getRootItems().get(9)); + assertEquals(root0, data.getRootItems().get(0)); + assertEquals(root9, data.getRootItems().get(9)); // Move to last position data.moveAfterSibling(root0, root9); - Assert.assertEquals(root0, data.getRootItems().get(9)); - Assert.assertEquals(root9, data.getRootItems().get(8)); + assertEquals(root0, data.getRootItems().get(9)); + assertEquals(root9, data.getRootItems().get(8)); // Move back to first position data.moveAfterSibling(root0, null); - Assert.assertEquals(root0, data.getRootItems().get(0)); - Assert.assertEquals(root9, data.getRootItems().get(9)); + assertEquals(root0, data.getRootItems().get(0)); + assertEquals(root9, data.getRootItems().get(9)); StrBean child0 = data.getChildren(root0).get(0); StrBean child2 = data.getChildren(root0).get(2); // Move first child to different position data.moveAfterSibling(child0, child2); - Assert.assertEquals(2, data.getChildren(root0).indexOf(child0)); - Assert.assertEquals(1, data.getChildren(root0).indexOf(child2)); + assertEquals(2, data.getChildren(root0).indexOf(child0)); + assertEquals(1, data.getChildren(root0).indexOf(child2)); // Move child back to first position data.moveAfterSibling(child0, null); - Assert.assertEquals(0, data.getChildren(root0).indexOf(child0)); - Assert.assertEquals(2, data.getChildren(root0).indexOf(child2)); + assertEquals(0, data.getChildren(root0).indexOf(child0)); + assertEquals(2, data.getChildren(root0).indexOf(child2)); } @Test(expected = IllegalArgumentException.class) @@ -158,9 +162,9 @@ public class TreeDataProviderTest dataCollection.addRootItems(Arrays.asList("a", "b", "c")); dataStream.addRootItems(Arrays.asList("a", "b", "c").stream()); - Assert.assertEquals(data.getRootItems(), dataVarargs.getRootItems()); - Assert.assertEquals(data.getRootItems(), dataCollection.getRootItems()); - Assert.assertEquals(data.getRootItems(), dataStream.getRootItems()); + assertEquals(data.getRootItems(), dataVarargs.getRootItems()); + assertEquals(data.getRootItems(), dataCollection.getRootItems()); + assertEquals(data.getRootItems(), dataStream.getRootItems()); } @Test @@ -173,12 +177,12 @@ public class TreeDataProviderTest } return Arrays.asList(item + "/a", item + "/b", item + "/c"); }); - Assert.assertEquals(stringData.getChildren("a"), + assertEquals(stringData.getChildren("a"), Arrays.asList("a/a", "a/b", "a/c")); - Assert.assertEquals(stringData.getChildren("b"), + assertEquals(stringData.getChildren("b"), Arrays.asList("b/a", "b/b", "b/c")); - Assert.assertEquals(stringData.getChildren("c"), Arrays.asList()); - Assert.assertEquals(stringData.getChildren("a/b"), Arrays.asList()); + assertEquals(stringData.getChildren("c"), Arrays.asList()); + assertEquals(stringData.getChildren("a/b"), Arrays.asList()); } @Test @@ -191,12 +195,12 @@ public class TreeDataProviderTest } return Stream.of(item + "/a", item + "/b", item + "/c"); }); - Assert.assertEquals(stringData.getChildren("a"), + assertEquals(stringData.getChildren("a"), Arrays.asList("a/a", "a/b", "a/c")); - Assert.assertEquals(stringData.getChildren("b"), + assertEquals(stringData.getChildren("b"), Arrays.asList("b/a", "b/b", "b/c")); - Assert.assertEquals(stringData.getChildren("c"), Arrays.asList()); - Assert.assertEquals(stringData.getChildren("a/b"), Arrays.asList()); + assertEquals(stringData.getChildren("c"), Arrays.asList()); + assertEquals(stringData.getChildren("a/b"), Arrays.asList()); } @Test @@ -204,26 +208,26 @@ public class TreeDataProviderTest getDataProvider().setFilter(item -> item.getValue().equals("Xyz") || item.getValue().equals("Baz")); - Assert.assertEquals(10, sizeWithUnfilteredQuery()); + assertEquals(10, sizeWithUnfilteredQuery()); getDataProvider().setFilter(item -> !item.getValue().equals("Foo") && !item.getValue().equals("Xyz")); - Assert.assertEquals( + assertEquals( "Previous filter should be replaced when setting a new one", 6, sizeWithUnfilteredQuery()); getDataProvider().setFilter(null); - Assert.assertEquals("Setting filter to null should remove all filters", - 20, sizeWithUnfilteredQuery()); + assertEquals("Setting filter to null should remove all filters", 20, + sizeWithUnfilteredQuery()); } @Test public void addFilter() { getDataProvider().addFilter(item -> item.getId() <= 10); getDataProvider().addFilter(item -> item.getId() >= 5); - Assert.assertEquals(5, sizeWithUnfilteredQuery()); + assertEquals(5, sizeWithUnfilteredQuery()); } @Override @@ -231,29 +235,28 @@ public class TreeDataProviderTest DataProvider<StrBean, String> strFilterDataProvider = getDataProvider() .withConvertedFilter( text -> strBean -> strBean.getValue().contains(text)); - Assert.assertEquals("Only one item should match 'Xyz'", 1, + assertEquals("Only one item should match 'Xyz'", 1, strFilterDataProvider .size(new HierarchicalQuery<>("Xyz", null))); - Assert.assertEquals("No item should match 'Zyx'", 0, - strFilterDataProvider - .size(new HierarchicalQuery<>("Zyx", null))); - Assert.assertEquals("Unexpected number of matches for 'Foo'", 3, + assertEquals("No item should match 'Zyx'", 0, strFilterDataProvider + .size(new HierarchicalQuery<>("Zyx", null))); + assertEquals("Unexpected number of matches for 'Foo'", 3, strFilterDataProvider .size(new HierarchicalQuery<>("Foo", null))); - Assert.assertEquals("No items should've been filtered out", - rootData.size(), strFilterDataProvider + assertEquals("No items should've been filtered out", rootData.size(), + strFilterDataProvider .size(new HierarchicalQuery<>(null, null))); } @Override public void filteringListDataProvider_defaultFilterType() { - Assert.assertEquals("Only one item should match 'Xyz'", 1, + assertEquals("Only one item should match 'Xyz'", 1, getDataProvider().size(new HierarchicalQuery<>( strBean -> strBean.getValue().contains("Xyz"), null))); - Assert.assertEquals("No item should match 'Zyx'", 0, + assertEquals("No item should match 'Zyx'", 0, dataProvider.size(new HierarchicalQuery<>( strBean -> strBean.getValue().contains("Zyx"), null))); - Assert.assertEquals("Unexpected number of matches for 'Foo'", 3, + assertEquals("Unexpected number of matches for 'Foo'", 3, getDataProvider() .size(new HierarchicalQuery<>(fooFilter, null))); } @@ -270,7 +273,7 @@ public class TreeDataProviderTest null)) .collect(Collectors.toList()); - Assert.assertEquals("Sorted data and original data sizes don't match", + assertEquals("Sorted data and original data sizes don't match", getDataProvider().fetch(new HierarchicalQuery<>(null, null)) .count(), list.size()); @@ -279,17 +282,16 @@ public class TreeDataProviderTest StrBean prev = list.get(i - 1); StrBean cur = list.get(i); // Test specific sort - Assert.assertTrue( + assertTrue( "Failure: " + prev.getRandomNumber() + " > " + cur.getRandomNumber(), prev.getRandomNumber() <= cur.getRandomNumber()); if (prev.getRandomNumber() == cur.getRandomNumber()) { // Test default sort - Assert.assertTrue( - prev.getValue().compareTo(cur.getValue()) <= 0); + assertTrue(prev.getValue().compareTo(cur.getValue()) <= 0); if (prev.getValue().equals(cur.getValue())) { - Assert.assertTrue(prev.getId() > cur.getId()); + assertTrue(prev.getId() > cur.getId()); } } } @@ -304,7 +306,7 @@ public class TreeDataProviderTest .fetch(new HierarchicalQuery<>(null, null)) .collect(Collectors.toList()); - Assert.assertEquals("Sorted data and original data sizes don't match", + assertEquals("Sorted data and original data sizes don't match", rootData.size(), list.size()); for (int i = 1; i < list.size(); ++i) { @@ -312,7 +314,7 @@ public class TreeDataProviderTest StrBean cur = list.get(i); // Test default sort - Assert.assertTrue(prev.getValue().compareTo(cur.getValue()) <= 0); + assertTrue(prev.getValue().compareTo(cur.getValue()) <= 0); } } @@ -332,15 +334,15 @@ public class TreeDataProviderTest .thenAsc("id").build(), comp, null, null)) .collect(Collectors.toList()); - Assert.assertNotEquals("First value should not match", rootData.get(0), + assertNotEquals("First value should not match", rootData.get(0), list.get(0)); - Assert.assertEquals("Sorted data and original data sizes don't match", + assertEquals("Sorted data and original data sizes don't match", rootData.size(), list.size()); rootData.sort(comp); for (int i = 0; i < rootData.size(); ++i) { - Assert.assertEquals("Sorting result differed", rootData.get(i), + assertEquals("Sorting result differed", rootData.get(i), list.get(i)); } } @@ -362,9 +364,8 @@ public class TreeDataProviderTest } private void assertHierarchyCorrect() { - Assert.assertEquals(flattenedData, - getFlattenedData(new ArrayList<>(), null)); - Assert.assertEquals(flattenedData, + assertEquals(flattenedData, getFlattenedData(new ArrayList<>(), null)); + assertEquals(flattenedData, getFlattenedDataFromProvider(new ArrayList<>(), null)); } diff --git a/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithDataTest.java b/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithDataTest.java index 4cfc8a8598..80d6a70cfd 100644 --- a/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithDataTest.java +++ b/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithDataTest.java @@ -1,5 +1,8 @@ package com.vaadin.data.provider.hierarchical; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -7,7 +10,6 @@ import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -50,58 +52,57 @@ public class HierarchyMapperWithDataTest { @Test public void expandRootNode() { - Assert.assertEquals("Map size should be equal to root node count", - ROOT_COUNT, mapper.getTreeSize()); + assertEquals("Map size should be equal to root node count", ROOT_COUNT, + mapper.getTreeSize()); expand(testData.get(0)); - Assert.assertEquals("Should be root count + once parent count", + assertEquals("Should be root count + once parent count", ROOT_COUNT + PARENT_COUNT, mapper.getTreeSize()); checkMapSize(); } @Test public void expandAndCollapseLastRootNode() { - Assert.assertEquals("Map size should be equal to root node count", - ROOT_COUNT, mapper.getTreeSize()); + assertEquals("Map size should be equal to root node count", ROOT_COUNT, + mapper.getTreeSize()); expand(roots.get(roots.size() - 1)); - Assert.assertEquals("Should be root count + once parent count", + assertEquals("Should be root count + once parent count", ROOT_COUNT + PARENT_COUNT, mapper.getTreeSize()); checkMapSize(); collapse(roots.get(roots.size() - 1)); - Assert.assertEquals("Map size should be equal to root node count again", + assertEquals("Map size should be equal to root node count again", ROOT_COUNT, mapper.getTreeSize()); checkMapSize(); } @Test public void expandHiddenNode() { - Assert.assertEquals("Map size should be equal to root node count", - ROOT_COUNT, mapper.getTreeSize()); + assertEquals("Map size should be equal to root node count", ROOT_COUNT, + mapper.getTreeSize()); expand(testData.get(1)); - Assert.assertEquals( - "Map size should not change when expanding a hidden node", + assertEquals("Map size should not change when expanding a hidden node", ROOT_COUNT, mapper.getTreeSize()); checkMapSize(); expand(roots.get(0)); - Assert.assertEquals("Hidden node should now be expanded as well", + assertEquals("Hidden node should now be expanded as well", ROOT_COUNT + PARENT_COUNT + LEAF_COUNT, mapper.getTreeSize()); checkMapSize(); collapse(roots.get(0)); - Assert.assertEquals("Map size should be equal to root node count", - ROOT_COUNT, mapper.getTreeSize()); + assertEquals("Map size should be equal to root node count", ROOT_COUNT, + mapper.getTreeSize()); checkMapSize(); } @Test public void expandLeafNode() { - Assert.assertEquals("Map size should be equal to root node count", - ROOT_COUNT, mapper.getTreeSize()); + assertEquals("Map size should be equal to root node count", ROOT_COUNT, + mapper.getTreeSize()); expand(testData.get(0)); expand(testData.get(1)); - Assert.assertEquals("Root and parent node expanded", + assertEquals("Root and parent node expanded", ROOT_COUNT + PARENT_COUNT + LEAF_COUNT, mapper.getTreeSize()); checkMapSize(); expand(testData.get(2)); - Assert.assertEquals("Expanding a leaf node should have no effect", + assertEquals("Expanding a leaf node should have no effect", ROOT_COUNT + PARENT_COUNT + LEAF_COUNT, mapper.getTreeSize()); checkMapSize(); } @@ -109,12 +110,12 @@ public class HierarchyMapperWithDataTest { @Test public void findParentIndexOfLeaf() { expand(testData.get(0)); - Assert.assertEquals("Could not find the root node of a parent", + assertEquals("Could not find the root node of a parent", Integer.valueOf(0), mapper.getParentIndex(testData.get(1))); expand(testData.get(1)); - Assert.assertEquals("Could not find the parent of a leaf", - Integer.valueOf(1), mapper.getParentIndex(testData.get(2))); + assertEquals("Could not find the parent of a leaf", Integer.valueOf(1), + mapper.getParentIndex(testData.get(2))); } @Test @@ -219,12 +220,13 @@ public class HierarchyMapperWithDataTest { List<Node> collect = mapper.fetchItems(range) .collect(Collectors.toList()); for (int i = 0; i < range.length(); ++i) { - Assert.assertEquals("Unexpected fetch results.", + assertEquals("Unexpected fetch results.", expectedResult.get(i + range.getStart()), collect.get(i)); } } - static List<Node> generateTestData(int rootCount, int parentCount, int leafCount) { + static List<Node> generateTestData(int rootCount, int parentCount, + int leafCount) { List<Node> nodes = new ArrayList<>(); for (int i = 0; i < rootCount; ++i) { Node root = new Node(); @@ -241,20 +243,20 @@ public class HierarchyMapperWithDataTest { } private void checkMapSize() { - Assert.assertEquals("Map size not properly updated", - mapper.getTreeSize(), mapSize); + assertEquals("Map size not properly updated", mapper.getTreeSize(), + mapSize); } public void removeRows(Range range) { - Assert.assertTrue("Index not in range", + assertTrue("Index not in range", 0 <= range.getStart() && range.getStart() < mapSize); - Assert.assertTrue("Removing more items than in map", + assertTrue("Removing more items than in map", range.getEnd() <= mapSize); mapSize -= range.length(); } public void insertRows(Range range) { - Assert.assertTrue("Index not in range", + assertTrue("Index not in range", 0 <= range.getStart() && range.getStart() <= mapSize); mapSize += range.length(); } diff --git a/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithNumerousDataTest.java b/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithNumerousDataTest.java index 611d15a2ac..6c0091f8bf 100644 --- a/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithNumerousDataTest.java +++ b/server/src/test/java/com/vaadin/data/provider/hierarchical/HierarchyMapperWithNumerousDataTest.java @@ -1,10 +1,12 @@ package com.vaadin.data.provider.hierarchical; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -29,7 +31,8 @@ public class HierarchyMapperWithNumerousDataTest { @BeforeClass public static void setupData() { - testData = HierarchyMapperWithDataTest.generateTestData(ROOT_COUNT, PARENT_COUNT, 0); + testData = HierarchyMapperWithDataTest.generateTestData(ROOT_COUNT, + PARENT_COUNT, 0); roots = testData.stream().filter(item -> item.getParent() == null) .collect(Collectors.toList()); data.addItems(roots, @@ -45,16 +48,16 @@ public class HierarchyMapperWithNumerousDataTest { } /** - * Test for non-logarithmic {@code getParentOfItem} implementations - * 100000 entries and 1 second should be enought to make it run even - * on slow machines and weed out linear solutions + * Test for non-logarithmic {@code getParentOfItem} implementations 100000 + * entries and 1 second should be enought to make it run even on slow + * machines and weed out linear solutions */ @Test(timeout = 1000) public void expandRootNode() { - Assert.assertEquals("Map size should be equal to root node count", - ROOT_COUNT, mapper.getTreeSize()); + assertEquals("Map size should be equal to root node count", ROOT_COUNT, + mapper.getTreeSize()); expand(testData.get(0)); - Assert.assertEquals("Should be root count + once parent count", + assertEquals("Should be root count + once parent count", ROOT_COUNT + PARENT_COUNT, mapper.getTreeSize()); checkMapSize(); } @@ -64,13 +67,13 @@ public class HierarchyMapperWithNumerousDataTest { } public void insertRows(Range range) { - Assert.assertTrue("Index not in range", + assertTrue("Index not in range", 0 <= range.getStart() && range.getStart() <= mapSize); mapSize += range.length(); } private void checkMapSize() { - Assert.assertEquals("Map size not properly updated", - mapper.getTreeSize(), mapSize); + assertEquals("Map size not properly updated", mapper.getTreeSize(), + mapSize); } } diff --git a/server/src/test/java/com/vaadin/data/validator/NotEmptyValidatorTest.java b/server/src/test/java/com/vaadin/data/validator/NotEmptyValidatorTest.java index edd500a8a1..f238f67f11 100644 --- a/server/src/test/java/com/vaadin/data/validator/NotEmptyValidatorTest.java +++ b/server/src/test/java/com/vaadin/data/validator/NotEmptyValidatorTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.data.validator; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.ValidationResult; @@ -31,16 +34,16 @@ public class NotEmptyValidatorTest { public void nullValueIsDisallowed() { NotEmptyValidator<String> validator = new NotEmptyValidator<>("foo"); ValidationResult result = validator.apply(null, new ValueContext()); - Assert.assertTrue(result.isError()); - Assert.assertEquals("foo", result.getErrorMessage()); + assertTrue(result.isError()); + assertEquals("foo", result.getErrorMessage()); } @Test public void emptyValueIsDisallowed() { NotEmptyValidator<String> validator = new NotEmptyValidator<>("foo"); ValidationResult result = validator.apply("", new ValueContext()); - Assert.assertTrue(result.isError()); - Assert.assertEquals("foo", result.getErrorMessage()); + assertTrue(result.isError()); + assertEquals("foo", result.getErrorMessage()); } @Test @@ -48,7 +51,7 @@ public class NotEmptyValidatorTest { NotEmptyValidator<Object> validator = new NotEmptyValidator<>("foo"); Object value = new Object(); ValidationResult result = validator.apply(value, new ValueContext()); - Assert.assertFalse(result.isError()); - Assert.assertFalse(result.isError()); + assertFalse(result.isError()); + assertFalse(result.isError()); } } diff --git a/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java b/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java index a0bdd2964b..80ed1b26f1 100644 --- a/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java +++ b/server/src/test/java/com/vaadin/data/validator/ValidatorTestBase.java @@ -1,8 +1,11 @@ package com.vaadin.data.validator; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Locale; -import org.junit.Assert; import org.junit.Before; import com.vaadin.data.ValidationResult; @@ -23,7 +26,7 @@ public class ValidatorTestBase { protected <T> void assertPasses(T value, Validator<? super T> validator) { ValidationResult result = validator.apply(value, new ValueContext()); if (result.isError()) { - Assert.fail(value + " should pass " + validator + " but got " + fail(value + " should pass " + validator + " but got " + result.getErrorMessage()); } } @@ -32,8 +35,8 @@ public class ValidatorTestBase { Validator<? super T> validator) { ValidationResult result = validator.apply(value, new ValueContext(localeContext)); - Assert.assertTrue(result.isError()); - Assert.assertEquals(errorMessage, result.getErrorMessage()); + assertTrue(result.isError()); + assertEquals(errorMessage, result.getErrorMessage()); } protected <T> void assertFails(T value, AbstractValidator<? super T> v) { diff --git a/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java b/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java index 5328ae9336..8418121c92 100644 --- a/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java +++ b/server/src/test/java/com/vaadin/event/selection/SelectionEventTest.java @@ -15,12 +15,14 @@ */ package com.vaadin.event.selection; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Optional; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -42,10 +44,10 @@ public class SelectionEventTest { Optional<?> selected = event.getFirstSelectedItem(); Mockito.verify(event).getValue(); - Assert.assertEquals("foo", selected.get()); + assertEquals("foo", selected.get()); Mockito.when(event.getValue()).thenReturn(Collections.emptySet()); - Assert.assertFalse(event.getFirstSelectedItem().isPresent()); + assertFalse(event.getFirstSelectedItem().isPresent()); } @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -59,10 +61,10 @@ public class SelectionEventTest { Optional<?> selected = event.getSelectedItem(); Mockito.verify(event).getSelectedItem(); - Assert.assertEquals("foo", selected.get()); + assertEquals("foo", selected.get()); Mockito.when(event.getSelectedItem()).thenReturn(Optional.empty()); - Assert.assertFalse(event.getFirstSelectedItem().isPresent()); + assertFalse(event.getFirstSelectedItem().isPresent()); } } diff --git a/server/src/test/java/com/vaadin/server/AbstractClientConnectorProxyHandlingTest.java b/server/src/test/java/com/vaadin/server/AbstractClientConnectorProxyHandlingTest.java index b3eb006e0d..e952c01340 100644 --- a/server/src/test/java/com/vaadin/server/AbstractClientConnectorProxyHandlingTest.java +++ b/server/src/test/java/com/vaadin/server/AbstractClientConnectorProxyHandlingTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.server; +import static org.junit.Assert.fail; + import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import org.junit.Assert; import org.junit.Test; /** @@ -38,13 +39,12 @@ public class AbstractClientConnectorProxyHandlingTest { int modifiers = method.getModifiers(); if (Modifier.isFinal(modifiers) || !Modifier.isProtected(modifiers) || Modifier.isStatic(modifiers)) { - Assert.fail( - "isThis has invalid modifiers, CDI proxies will not work."); + fail("isThis has invalid modifiers, CDI proxies will not work."); } } catch (SecurityException e) { // Ignore, no can do } catch (NoSuchMethodException e) { - Assert.fail("isThis is missing, CDI proxies will not work."); + fail("isThis is missing, CDI proxies will not work."); } } diff --git a/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java b/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java index 4a6a2f5647..b4e4f95194 100644 --- a/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java +++ b/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java @@ -15,6 +15,11 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -27,7 +32,6 @@ import java.net.URL; import java.util.Map; import org.apache.commons.io.IOUtils; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -51,9 +55,9 @@ public class AbstractClientConnectorTest { Mockito.doCallRealMethod().when(mock).registerRpc(implementation); try { mock.registerRpc(implementation); - Assert.fail("expected exception"); + fail("expected exception"); } catch (Exception expected) { - Assert.assertEquals( + assertEquals( "Use registerRpc(T implementation, Class<T> rpcInterfaceType) " + "if the Rpc implementation implements more than one interface", expected.getMessage()); @@ -93,7 +97,7 @@ public class AbstractClientConnectorTest { "com.vaadin.server.AbstractClientConnector"); stateTypeCache.put(classRef.get(), null); int size = stateTypeCache.size(); - Assert.assertNotNull("Class should not yet be garbage collected", + assertNotNull("Class should not yet be garbage collected", classRef.get()); for (int i = 0; i < 100; ++i) { @@ -103,8 +107,8 @@ public class AbstractClientConnectorTest { } Thread.sleep(100); } - Assert.assertTrue(stateTypeCache.size() < size); - Assert.assertNull("Class should be garbage collected", classRef.get()); + assertTrue(stateTypeCache.size() < size); + assertNull("Class should be garbage collected", classRef.get()); } private WeakReference<Class<?>> loadClass(String name) @@ -161,8 +165,7 @@ public class AbstractClientConnectorTest { if (!name.startsWith("com.vaadin.")) { return super.loadClass(name); } - String path = name.replace('.', '/') - .concat(".class"); + String path = name.replace('.', '/').concat(".class"); URL resource = Thread.currentThread().getContextClassLoader() .getResource(path); try (InputStream stream = resource.openStream()) { diff --git a/server/src/test/java/com/vaadin/server/AbstractDeploymentConfigurationTest.java b/server/src/test/java/com/vaadin/server/AbstractDeploymentConfigurationTest.java index 2d4e7fad0a..97918d27dc 100644 --- a/server/src/test/java/com/vaadin/server/AbstractDeploymentConfigurationTest.java +++ b/server/src/test/java/com/vaadin/server/AbstractDeploymentConfigurationTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; + import java.util.Properties; import java.util.UUID; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.communication.PushMode; @@ -35,8 +36,8 @@ public class AbstractDeploymentConfigurationTest { String ui = UUID.randomUUID().toString(); DeploymentConfiguration config = getConfig(VaadinSession.UI_PARAMETER, ui); - Assert.assertEquals("Unexpected UI class configuration option value", - ui, config.getUIClassName()); + assertEquals("Unexpected UI class configuration option value", ui, + config.getUIClassName()); } @Test @@ -44,8 +45,7 @@ public class AbstractDeploymentConfigurationTest { String uiProvider = UUID.randomUUID().toString(); DeploymentConfiguration config = getConfig( Constants.SERVLET_PARAMETER_UI_PROVIDER, uiProvider); - Assert.assertEquals( - "Unexpected UI providerclass configuration option value", + assertEquals("Unexpected UI providerclass configuration option value", uiProvider, config.getUIProviderClassName()); } @@ -54,7 +54,7 @@ public class AbstractDeploymentConfigurationTest { String widgetset = UUID.randomUUID().toString(); DeploymentConfiguration config = getConfig( Constants.PARAMETER_WIDGETSET, widgetset); - Assert.assertEquals("Unexpected widgetset configuration option value", + assertEquals("Unexpected widgetset configuration option value", widgetset, config.getWidgetset(null)); } @@ -62,7 +62,7 @@ public class AbstractDeploymentConfigurationTest { public void getWidgetset_noWidgetsetPropertyValue_returnsProvidedDefaultValue() { DeploymentConfiguration config = getConfig(null, null); String widgetset = UUID.randomUUID().toString(); - Assert.assertEquals("Unexpected widgetset configuration option value", + assertEquals("Unexpected widgetset configuration option value", widgetset, config.getWidgetset(widgetset)); } @@ -71,8 +71,7 @@ public class AbstractDeploymentConfigurationTest { String resources = UUID.randomUUID().toString(); DeploymentConfiguration config = getConfig( Constants.PARAMETER_VAADIN_RESOURCES, resources); - Assert.assertEquals( - "Unexpected resources path configuration option value", + assertEquals("Unexpected resources path configuration option value", resources, config.getResourcesPath()); } @@ -80,7 +79,7 @@ public class AbstractDeploymentConfigurationTest { public void getClassLoader_returnsClassloaderPropertyValue() { String classLoader = UUID.randomUUID().toString(); DeploymentConfiguration config = getConfig("ClassLoader", classLoader); - Assert.assertEquals("Unexpected classLoader configuration option value", + assertEquals("Unexpected classLoader configuration option value", classLoader, config.getClassLoaderName()); } diff --git a/server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java b/server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java index 3530d105a3..2f96fad56f 100644 --- a/server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java +++ b/server/src/test/java/com/vaadin/server/BootstrapHandlerTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; + import java.util.Properties; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -105,7 +106,6 @@ public class BootstrapHandlerTest { Mockito.when(session.getBrowser()).thenReturn(browser); Mockito.when(session.getConfiguration()).thenReturn(configuration); - Assert.assertEquals(expectedUrl, - resolver.resolveVaadinUri(frontendUrl)); + assertEquals(expectedUrl, resolver.resolveVaadinUri(frontendUrl)); } } diff --git a/server/src/test/java/com/vaadin/server/BrowserWindowOpenerTest.java b/server/src/test/java/com/vaadin/server/BrowserWindowOpenerTest.java index 726f4ea549..ef8420655f 100644 --- a/server/src/test/java/com/vaadin/server/BrowserWindowOpenerTest.java +++ b/server/src/test/java/com/vaadin/server/BrowserWindowOpenerTest.java @@ -16,9 +16,11 @@ package com.vaadin.server; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.communication.URLReference; @@ -39,14 +41,14 @@ public class BrowserWindowOpenerTest { assertEquals("Unexpected resource is got on getResource() method", resource, opener.getResource()); - Assert.assertNull("Unexpected resource is got on getUrl() method", + assertNull("Unexpected resource is got on getUrl() method", opener.getUrl()); URLReference ref = opener.getState(false).resources .get(BrowserWindowOpenerState.locationResource); - Assert.assertTrue("Url reference in the state is not ResourceReference", + assertTrue("Url reference in the state is not ResourceReference", ref instanceof ResourceReference); - Assert.assertEquals("Unexpected resource saved in state", resource, + assertEquals("Unexpected resource saved in state", resource, ((ResourceReference) ref).getResource()); } @@ -59,18 +61,17 @@ public class BrowserWindowOpenerTest { assertEquals("Unexpected URL is got on getURL() method", url, opener.getUrl()); - Assert.assertNotNull( - "Unexpected resource is got on getResource() method", + assertNotNull("Unexpected resource is got on getResource() method", opener.getResource()); URLReference ref = opener.getState(false).resources .get(BrowserWindowOpenerState.locationResource); - Assert.assertTrue("Url reference in the state is not ResourceReference", + assertTrue("Url reference in the state is not ResourceReference", ref instanceof ResourceReference); Resource resource = ((ResourceReference) ref).getResource(); - Assert.assertTrue("Resource reference is not ExternalResource", + assertTrue("Resource reference is not ExternalResource", resource instanceof ExternalResource); - Assert.assertEquals("Unexpected URL in resource saved in state", url, + assertEquals("Unexpected URL in resource saved in state", url, ((ExternalResource) resource).getURL()); } diff --git a/server/src/test/java/com/vaadin/server/ConnectorResourceHandlerTest.java b/server/src/test/java/com/vaadin/server/ConnectorResourceHandlerTest.java index 57b8ed8ff4..72eb5ec26e 100644 --- a/server/src/test/java/com/vaadin/server/ConnectorResourceHandlerTest.java +++ b/server/src/test/java/com/vaadin/server/ConnectorResourceHandlerTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import org.easymock.EasyMock; import org.easymock.IMocksControl; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -95,7 +96,7 @@ public class ConnectorResourceHandlerTest { } ConnectorResourceHandler handler = new ConnectorResourceHandler(); - Assert.assertTrue(handler.handleRequest(session, request, response)); + assertTrue(handler.handleRequest(session, request, response)); EasyMock.verify(errorHandler); } diff --git a/server/src/test/java/com/vaadin/server/DedicatedStateTest.java b/server/src/test/java/com/vaadin/server/DedicatedStateTest.java index 3a21d136f7..009682ae88 100644 --- a/server/src/test/java/com/vaadin/server/DedicatedStateTest.java +++ b/server/src/test/java/com/vaadin/server/DedicatedStateTest.java @@ -15,11 +15,14 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; + import java.lang.reflect.Method; import java.util.HashSet; import java.util.Set; -import org.junit.Assert; import org.junit.Test; import com.vaadin.navigator.Navigator; @@ -58,7 +61,7 @@ public class DedicatedStateTest { Class<?> superclass = clazz.getSuperclass(); if (!clazz.equals(AbstractClientConnector.class) && !superclass.equals(AbstractExtension.class)) { - Assert.assertNotEquals( + assertNotEquals( "Class " + clazz + " has the same state type as its super class " + clazz.getSuperclass(), @@ -67,9 +70,9 @@ public class DedicatedStateTest { try { Method getStateOneArg = clazz.getDeclaredMethod("getState", boolean.class); - Assert.assertEquals(stateType, getStateOneArg.getReturnType()); + assertEquals(stateType, getStateOneArg.getReturnType()); } catch (NoSuchMethodException e) { - Assert.fail("Class " + clazz + fail("Class " + clazz + " doesn't have its own getState(boolean) method"); } catch (SecurityException e) { throw new RuntimeException(e); @@ -80,8 +83,7 @@ public class DedicatedStateTest { try { return clazz.getDeclaredMethod("getState"); } catch (NoSuchMethodException e) { - Assert.fail("Class " + clazz - + " doesn't have its own getState() method"); + fail("Class " + clazz + " doesn't have its own getState() method"); return null; } catch (SecurityException e) { throw new RuntimeException(e); diff --git a/server/src/test/java/com/vaadin/server/DefaultDeploymentConfigurationTest.java b/server/src/test/java/com/vaadin/server/DefaultDeploymentConfigurationTest.java index 41fc4f0077..4bbf165770 100644 --- a/server/src/test/java/com/vaadin/server/DefaultDeploymentConfigurationTest.java +++ b/server/src/test/java/com/vaadin/server/DefaultDeploymentConfigurationTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; + import java.util.Properties; -import org.junit.Assert; import org.junit.Test; /** @@ -37,7 +38,7 @@ public class DefaultDeploymentConfigurationTest { System.setProperty(prop, value); DefaultDeploymentConfiguration config = new DefaultDeploymentConfiguration( clazz, new Properties()); - Assert.assertEquals(value, config.getSystemProperty(prop)); + assertEquals(value, config.getSystemProperty(prop)); } @Test @@ -50,6 +51,6 @@ public class DefaultDeploymentConfigurationTest { value); DefaultDeploymentConfiguration config = new DefaultDeploymentConfiguration( DefaultDeploymentConfigurationTest.class, new Properties()); - Assert.assertEquals(value, config.getSystemProperty(prop)); + assertEquals(value, config.getSystemProperty(prop)); } } diff --git a/server/src/test/java/com/vaadin/server/DragAndDropServiceTest.java b/server/src/test/java/com/vaadin/server/DragAndDropServiceTest.java index 71e3782fcd..370bb490aa 100644 --- a/server/src/test/java/com/vaadin/server/DragAndDropServiceTest.java +++ b/server/src/test/java/com/vaadin/server/DragAndDropServiceTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,7 +27,6 @@ import java.util.logging.Logger; import java.util.logging.StreamHandler; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.event.dd.DropHandler; @@ -64,9 +65,9 @@ public class DragAndDropServiceTest { EasyMock.createMock(VaadinSession.class)); service.changeVariables(null, variables); - Assert.assertTrue("isConnectorEnabled() method is not called", + assertTrue("isConnectorEnabled() method is not called", isConnectorEnabledCalled[0]); - Assert.assertTrue("No warning on drop from disabled source", + assertTrue("No warning on drop from disabled source", levels.contains(Level.WARNING)); } @@ -89,9 +90,9 @@ public class DragAndDropServiceTest { EasyMock.createMock(VaadinSession.class)); service.changeVariables(null, variables); - Assert.assertTrue("isConnectorEnabled() method is not called", + assertTrue("isConnectorEnabled() method is not called", target.isConnectorEnabledCalled()); - Assert.assertTrue("No warning on drop to disabled target", + assertTrue("No warning on drop to disabled target", levels.contains(Level.WARNING)); } diff --git a/server/src/test/java/com/vaadin/server/JSONSerializerTest.java b/server/src/test/java/com/vaadin/server/JSONSerializerTest.java index 250d6831f4..406b798193 100644 --- a/server/src/test/java/com/vaadin/server/JSONSerializerTest.java +++ b/server/src/test/java/com/vaadin/server/JSONSerializerTest.java @@ -15,12 +15,14 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Type; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.JsonCodec.BeanProperty; @@ -90,7 +92,7 @@ public class JSONSerializerTest { inputArray.set(1, Json.createNull()); UidlValue decodedObject = (UidlValue) JsonCodec .decodeInternalType(UidlValue.class, true, inputArray, null); - Assert.assertNull(decodedObject.getValue()); + assertNull(decodedObject.getValue()); } @Test(expected = JsonException.class) @@ -106,8 +108,7 @@ public class JSONSerializerTest { Type type) throws Exception { Object serverSideDecoded = JsonCodec.decodeInternalOrCustomType(type, encoded, null); - Assert.assertTrue("Server decoded", - equals(original, serverSideDecoded)); + assertTrue("Server decoded", equals(original, serverSideDecoded)); } diff --git a/server/src/test/java/com/vaadin/server/JsonEqualsTest.java b/server/src/test/java/com/vaadin/server/JsonEqualsTest.java index e92254921f..833c20e496 100644 --- a/server/src/test/java/com/vaadin/server/JsonEqualsTest.java +++ b/server/src/test/java/com/vaadin/server/JsonEqualsTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.server; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import elemental.json.Json; @@ -29,7 +31,7 @@ public class JsonEqualsTest { public void differentTypes_notEqual() { boolean equals = JsonCodec.jsonEquals(Json.create(5), Json.create("5")); - Assert.assertFalse("Different types should not be equal", equals); + assertFalse("Different types should not be equal", equals); } @Test @@ -37,7 +39,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(Json.createNull(), Json.createNull()); - Assert.assertTrue("Null and null should be equal", equals); + assertTrue("Null and null should be equal", equals); } @Test @@ -45,7 +47,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(Json.create(true), Json.create(false)); - Assert.assertFalse("Different booleans should not be equal", equals); + assertFalse("Different booleans should not be equal", equals); } @Test @@ -53,14 +55,14 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(Json.create(false), Json.create(false)); - Assert.assertTrue("Same booleans should be equal", equals); + assertTrue("Same booleans should be equal", equals); } @Test public void differentNumbers_notEqual() { boolean equals = JsonCodec.jsonEquals(Json.create(2), Json.create(5.6)); - Assert.assertFalse("Different numbers should not be equal", equals); + assertFalse("Different numbers should not be equal", equals); } @Test @@ -68,7 +70,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(Json.create(3.14), Json.create(3.14)); - Assert.assertTrue("Same numbers should be equal", equals); + assertTrue("Same numbers should be equal", equals); } @Test @@ -76,7 +78,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(Json.create("abc"), Json.create("def")); - Assert.assertFalse("Different strings should not be equal", equals); + assertFalse("Different strings should not be equal", equals); } @Test @@ -84,7 +86,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(Json.create("abc"), Json.create("abc")); - Assert.assertTrue("Same strings should be equal", equals); + assertTrue("Same strings should be equal", equals); } @Test @@ -96,8 +98,8 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(o1, o2); - Assert.assertFalse( - "Object with different key counts should not be equal", equals); + assertFalse("Object with different key counts should not be equal", + equals); } @Test @@ -110,8 +112,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(o1, o2); - Assert.assertFalse("Object with different keys should not be equal", - equals); + assertFalse("Object with different keys should not be equal", equals); } @Test @@ -124,8 +125,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(o1, o2); - Assert.assertFalse( - "Object with different child values should not be equal", + assertFalse("Object with different child values should not be equal", equals); } @@ -136,7 +136,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(o1, o2); - Assert.assertTrue("Empty objects should be equal", equals); + assertTrue("Empty objects should be equal", equals); } @Test @@ -149,7 +149,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(o1, o2); - Assert.assertTrue("Same objects should be equal", equals); + assertTrue("Same objects should be equal", equals); } @Test @@ -162,7 +162,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(o1, o2); - Assert.assertTrue("Same objects should be equal", equals); + assertTrue("Same objects should be equal", equals); } @Test @@ -174,8 +174,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(a1, a2); - Assert.assertFalse("Arrays with different sizes should not be equal", - equals); + assertFalse("Arrays with different sizes should not be equal", equals); } @Test @@ -188,7 +187,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(a1, a2); - Assert.assertFalse("Arrays with different content should not be equal", + assertFalse("Arrays with different content should not be equal", equals); } @@ -204,8 +203,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(a1, a2); - Assert.assertFalse("Arrays with different order should not be equal", - equals); + assertFalse("Arrays with different order should not be equal", equals); } @Test @@ -215,7 +213,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(a1, a2); - Assert.assertTrue("Empty arrays should be equal", equals); + assertTrue("Empty arrays should be equal", equals); } @Test @@ -230,7 +228,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(a1, a2); - Assert.assertTrue("Same arrays should be equal", equals); + assertTrue("Same arrays should be equal", equals); } @Test @@ -243,7 +241,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(a1, a2); - Assert.assertTrue("Same arrays should be equal", equals); + assertTrue("Same arrays should be equal", equals); } @Test @@ -251,7 +249,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(createDeeplyNestedValue(1), createDeeplyNestedValue(2)); - Assert.assertFalse("Values should not be equal", equals); + assertFalse("Values should not be equal", equals); } @Test @@ -259,7 +257,7 @@ public class JsonEqualsTest { boolean equals = JsonCodec.jsonEquals(createDeeplyNestedValue(1), createDeeplyNestedValue(1)); - Assert.assertTrue("Values should be equal", equals); + assertTrue("Values should be equal", equals); } private static JsonValue createDeeplyNestedValue(int leafValue) { diff --git a/server/src/test/java/com/vaadin/server/LocaleServiceTest.java b/server/src/test/java/com/vaadin/server/LocaleServiceTest.java index 7742c2ae30..ec028aa5cd 100644 --- a/server/src/test/java/com/vaadin/server/LocaleServiceTest.java +++ b/server/src/test/java/com/vaadin/server/LocaleServiceTest.java @@ -1,12 +1,13 @@ package com.vaadin.server; +import static org.junit.Assert.assertEquals; + import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Set; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -956,16 +957,16 @@ public class LocaleServiceTest { @Test public void localeDateTimeFormat() { for (Locale l : expectedLocaleData.keySet()) { - Assert.assertEquals("Error verifying locale " + l, + assertEquals("Error verifying locale " + l, expectedLocaleData.get(l).dateFormat, localeService.createLocaleData(l).dateFormat); - Assert.assertEquals("Error verifying locale " + l, + assertEquals("Error verifying locale " + l, expectedLocaleData.get(l).twelveHourClock, localeService.createLocaleData(l).twelveHourClock); - Assert.assertEquals("Error verifying locale " + l, + assertEquals("Error verifying locale " + l, expectedLocaleData.get(l).am, localeService.createLocaleData(l).am); - Assert.assertEquals("Error verifying locale " + l, + assertEquals("Error verifying locale " + l, expectedLocaleData.get(l).pm, localeService.createLocaleData(l).pm); } @@ -1023,4 +1024,4 @@ public class LocaleServiceTest { + id.replaceAll("_", "\",\"") + "\"), " + field + ");"); } -}
\ No newline at end of file +} diff --git a/server/src/test/java/com/vaadin/server/PageTest.java b/server/src/test/java/com/vaadin/server/PageTest.java index 3a8c5a0ba1..42ab59dc51 100644 --- a/server/src/test/java/com/vaadin/server/PageTest.java +++ b/server/src/test/java/com/vaadin/server/PageTest.java @@ -15,8 +15,9 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertFalse; + import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.Page.BrowserWindowResizeEvent; @@ -43,8 +44,7 @@ public class PageTest { page.updateBrowserWindowSize(0, 0, true); - Assert.assertFalse("Listener is called after removal", - listener.isCalled()); + assertFalse("Listener is called after removal", listener.isCalled()); } @Test @@ -56,8 +56,7 @@ public class PageTest { .createMock(BrowserWindowResizeListener.class); page.removeBrowserWindowResizeListener(listener); - Assert.assertFalse( - "Page state 'hasResizeListeners' property has wrong value", + assertFalse("Page state 'hasResizeListeners' property has wrong value", page.getState(false).hasResizeListeners); } diff --git a/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java b/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java index d597ab3539..0e7426232d 100644 --- a/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java +++ b/server/src/test/java/com/vaadin/server/RemoveListenersDeprecatedTest.java @@ -1,5 +1,9 @@ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -7,7 +11,6 @@ import java.util.List; import java.util.function.Predicate; import java.util.regex.Pattern; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.provider.AbstractDataProvider; @@ -47,11 +50,10 @@ public class RemoveListenersDeprecatedTest { if (addPattern.matcher(method.getName()).matches() && method.getAnnotation(Deprecated.class) == null) { Class<?> returnType = method.getReturnType(); - Assert.assertEquals( - "Method " + method.getName() - + " is not deprectated in class " - + serverClass.getName() - + " and doesn't return a Registration object", + assertEquals("Method " + method.getName() + + " is not deprectated in class " + + serverClass.getName() + + " and doesn't return a Registration object", Registration.class, returnType); } if (ALLOW_REMOVE_LISTENER.stream() @@ -60,7 +62,7 @@ public class RemoveListenersDeprecatedTest { } if (removePattern.matcher(method.getName()).matches()) { - Assert.assertNotNull( + assertNotNull( "Method " + method.getName() + " in class " + serverClass.getName() + " has not been marked as deprecated.", @@ -68,7 +70,7 @@ public class RemoveListenersDeprecatedTest { } } } - Assert.assertTrue(count > 0); + assertTrue(count > 0); } private static boolean acceptMethodEventSource(Method method) { diff --git a/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java b/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java index 3017bc3e37..08ad5a9bac 100644 --- a/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java +++ b/server/src/test/java/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java @@ -3,13 +3,13 @@ package com.vaadin.server; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; +import static org.junit.Assert.assertEquals; import java.net.MalformedURLException; import java.net.URL; import javax.servlet.http.HttpServletRequest; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -34,30 +34,30 @@ public class TestAbstractApplicationServletStaticFilesLocation { // should return . (relative url resolving to /contextpath) location = testLocation("http://dummy.host:8080", "/contextpath", "/servlet", ""); - Assert.assertEquals(".", location); + assertEquals(".", location); // http://dummy.host:8080/contextpath/servlet/ // should return ./.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host:8080", "/contextpath", "/servlet", "/"); - Assert.assertEquals("./..", location); + assertEquals("./..", location); // http://dummy.host:8080/servlet // should return "." location = testLocation("http://dummy.host:8080", "", "/servlet", ""); - Assert.assertEquals(".", location); + assertEquals(".", location); // http://dummy.host/contextpath/servlet/extra/stuff // should return ./../.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host", "/contextpath", "/servlet", "/extra/stuff"); - Assert.assertEquals("./../..", location); + assertEquals("./../..", location); // http://dummy.host/context/path/servlet/extra/stuff // should return ./../.. (relative url resolving to /context/path) location = testLocation("http://dummy.host", "/context/path", "/servlet", "/extra/stuff"); - Assert.assertEquals("./../..", location); + assertEquals("./../..", location); /* Include requests */ // Include request support dropped with support for portlet1 diff --git a/server/src/test/java/com/vaadin/server/UIProviderTest.java b/server/src/test/java/com/vaadin/server/UIProviderTest.java index f55e489c0a..92b37fed2f 100644 --- a/server/src/test/java/com/vaadin/server/UIProviderTest.java +++ b/server/src/test/java/com/vaadin/server/UIProviderTest.java @@ -15,12 +15,14 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.Assert; import org.junit.Test; import com.vaadin.annotations.Theme; @@ -35,43 +37,40 @@ public class UIProviderTest { @Test public void getAnnotationFor_widgetsetAnnotationForSubclass_annotationFound() { - Assert.assertNotNull("Widgetset annotation is not found for subclass", + assertNotNull("Widgetset annotation is not found for subclass", UIProvider.getAnnotationFor(TestClass.class, Widgetset.class)); } @Test public void getAnnotationFor_themeAnnotationForSubclass_annotationFound() { - Assert.assertNotNull("Theme annotation is not found for subclass", + assertNotNull("Theme annotation is not found for subclass", UIProvider.getAnnotationFor(TestClass.class, Theme.class)); } @Test public void getAnnotationFor_themeAnnotationForSubclass_annotationOverridden() { - Assert.assertEquals( - "Theme annotation is not overridden correctly in subclass", "c", - UIProvider.getAnnotationFor(TestClass.class, Theme.class) + assertEquals("Theme annotation is not overridden correctly in subclass", + "c", UIProvider.getAnnotationFor(TestClass.class, Theme.class) .value()); } @Test public void getAnnotationFor_notInheritedAnnotationForSubclass_annotationFound() { - Assert.assertNotNull( - "TestAnnotation annotation is not found for subclass", + assertNotNull("TestAnnotation annotation is not found for subclass", UIProvider.getAnnotationFor(TestClass.class, TestAnnotation.class)); } @Test public void getAnnotationFor_directAnnotationForSubclass_annotationFound() { - Assert.assertNotNull( - "TestAnnotation1 annotation is not found for subclass", + assertNotNull("TestAnnotation1 annotation is not found for subclass", UIProvider.getAnnotationFor(TestClass.class, TestAnnotation1.class)); } @Test public void getAnnotationFor_annotationInheritedFromInterface_annotationFound() { - Assert.assertNotNull("Theme annotation is not inherited from interface", + assertNotNull("Theme annotation is not inherited from interface", UIProvider.getAnnotationFor(ClassImplementingInterface.class, Theme.class)); } diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java index c109a62a79..ccd6aba6e5 100644 --- a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java @@ -17,12 +17,13 @@ package com.vaadin.server; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.concurrent.locks.ReentrantLock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -211,9 +212,9 @@ public class VaadinPortletServiceTest { .thenReturn(emptyWrappedSession); UI ui = sut.findUI(requestWithUIIDSet); - Assert.assertNull("Unset session did not return null", ui); + assertNull("Unset session did not return null", ui); } catch (NullPointerException e) { - Assert.fail("findUI threw a NullPointerException"); + fail("findUI threw a NullPointerException"); } } } diff --git a/server/src/test/java/com/vaadin/server/VaadinServiceTest.java b/server/src/test/java/com/vaadin/server/VaadinServiceTest.java index 7d6cc70146..6219be0a29 100644 --- a/server/src/test/java/com/vaadin/server/VaadinServiceTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinServiceTest.java @@ -17,13 +17,13 @@ package com.vaadin.server; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpSessionBindingEvent; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.Registration; @@ -72,20 +72,20 @@ public class VaadinServiceTest { MockVaadinSession vaadinSession = new MockVaadinSession(service); service.fireSessionDestroy(vaadinSession); - Assert.assertEquals( + assertEquals( "'fireSessionDestroy' method doesn't call 'close' for the session", 1, vaadinSession.getCloseCount()); vaadinSession.valueUnbound( EasyMock.createMock(HttpSessionBindingEvent.class)); - Assert.assertEquals( + assertEquals( "'fireSessionDestroy' method may not call 'close' " + "method for closing session", 1, vaadinSession.getCloseCount()); - Assert.assertEquals("SessionDestroyListeners not called exactly once", - 1, listener.callCount); + assertEquals("SessionDestroyListeners not called exactly once", 1, + listener.callCount); } @Test @@ -164,7 +164,7 @@ public class VaadinServiceTest { CurrentInstance.set(String.class, "Original value"); service.runPendingAccessTasks(session); - Assert.assertEquals( + assertEquals( "Original CurrentInstance should be set after the task has been run", "Original value", CurrentInstance.get(String.class)); } @@ -190,13 +190,13 @@ public class VaadinServiceTest { Registration remover2 = service.addServiceDestroyListener(listener2); service.destroy(); - Assert.assertEquals(1, listener.callCount); - Assert.assertEquals(1, listener2.callCount); + assertEquals(1, listener.callCount); + assertEquals(1, listener2.callCount); service.removeServiceDestroyListener(listener); remover2.remove(); service.destroy(); - Assert.assertEquals(1, listener.callCount); - Assert.assertEquals(1, listener2.callCount); + assertEquals(1, listener.callCount); + assertEquals(1, listener2.callCount); } } diff --git a/server/src/test/java/com/vaadin/server/VaadinServletConfigurationTest.java b/server/src/test/java/com/vaadin/server/VaadinServletConfigurationTest.java index bc13afa4fd..5e6176df53 100644 --- a/server/src/test/java/com/vaadin/server/VaadinServletConfigurationTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinServletConfigurationTest.java @@ -19,13 +19,16 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Properties; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.annotations.VaadinServletConfiguration; @@ -43,7 +46,7 @@ public class VaadinServletConfigurationTest { .getUIClass(new UIClassSelectionEvent(new VaadinServletRequest( EasyMock.createMock(HttpServletRequest.class), servlet.getService()))); - Assert.assertEquals(MockUIContainingServlet.class, uiClass); + assertEquals(MockUIContainingServlet.class, uiClass); } @Test @@ -53,16 +56,16 @@ public class VaadinServletConfigurationTest { DeploymentConfiguration configuration = servlet.getService() .getDeploymentConfiguration(); - Assert.assertTrue(configuration.isProductionMode()); - Assert.assertTrue(configuration.isCloseIdleSessions()); - Assert.assertEquals(1234, configuration.getHeartbeatInterval()); - Assert.assertEquals(4321, configuration.getResourceCacheTime()); + assertTrue(configuration.isProductionMode()); + assertTrue(configuration.isCloseIdleSessions()); + assertEquals(1234, configuration.getHeartbeatInterval()); + assertEquals(4321, configuration.getResourceCacheTime()); Class<? extends UI> uiClass = new DefaultUIProvider() .getUIClass(new UIClassSelectionEvent(new VaadinServletRequest( EasyMock.createMock(HttpServletRequest.class), servlet.getService()))); - Assert.assertEquals(MockUIContainingServlet.class, uiClass); + assertEquals(MockUIContainingServlet.class, uiClass); } @Test @@ -77,18 +80,18 @@ public class VaadinServletConfigurationTest { .getDeploymentConfiguration(); // Values from servlet init params take precedence - Assert.assertEquals(1111, configuration.getHeartbeatInterval()); - Assert.assertFalse(configuration.isProductionMode()); + assertEquals(1111, configuration.getHeartbeatInterval()); + assertFalse(configuration.isProductionMode()); // Other params are as defined in the annotation - Assert.assertTrue(configuration.isCloseIdleSessions()); - Assert.assertEquals(4321, configuration.getResourceCacheTime()); + assertTrue(configuration.isCloseIdleSessions()); + assertEquals(4321, configuration.getResourceCacheTime()); Class<? extends UI> uiClass = new DefaultUIProvider() .getUIClass(new UIClassSelectionEvent(new VaadinServletRequest( EasyMock.createMock(HttpServletRequest.class), servlet.getService()))); - Assert.assertEquals(MockUIContainingServlet.class, uiClass); + assertEquals(MockUIContainingServlet.class, uiClass); } } diff --git a/server/src/test/java/com/vaadin/server/VaadinServletServiceTest.java b/server/src/test/java/com/vaadin/server/VaadinServletServiceTest.java index 24bb800a12..1630d3b968 100644 --- a/server/src/test/java/com/vaadin/server/VaadinServletServiceTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinServletServiceTest.java @@ -3,6 +3,7 @@ package com.vaadin.server; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; +import static org.junit.Assert.assertEquals; import java.net.MalformedURLException; import java.net.URL; @@ -10,7 +11,6 @@ import java.net.URL; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -32,36 +32,36 @@ public class VaadinServletServiceTest { // should return . (relative url resolving to /contextpath) location = testLocation("http://dummy.host:8080", "/contextpath", "/servlet", ""); - Assert.assertEquals(".", location); + assertEquals(".", location); // http://dummy.host:8080/contextpath/servlet/ // should return ./.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host:8080", "/contextpath", "/servlet", "/"); - Assert.assertEquals("./..", location); + assertEquals("./..", location); // http://dummy.host:8080/servlet // should return "." location = testLocation("http://dummy.host:8080", "", "/servlet", ""); - Assert.assertEquals(".", location); + assertEquals(".", location); // http://dummy.host/contextpath/servlet/extra/stuff // should return ./../.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host", "/contextpath", "/servlet", "/extra/stuff"); - Assert.assertEquals("./../..", location); + assertEquals("./../..", location); // http://dummy.host/contextpath/servlet/extra/stuff/ // should return ./../.. (relative url resolving to /contextpath) location = testLocation("http://dummy.host", "/contextpath", "/servlet", "/extra/stuff/"); - Assert.assertEquals("./../../..", location); + assertEquals("./../../..", location); // http://dummy.host/context/path/servlet/extra/stuff // should return ./../.. (relative url resolving to /context/path) location = testLocation("http://dummy.host", "/context/path", "/servlet", "/extra/stuff"); - Assert.assertEquals("./../..", location); + assertEquals("./../..", location); } diff --git a/server/src/test/java/com/vaadin/server/VaadinServletTest.java b/server/src/test/java/com/vaadin/server/VaadinServletTest.java index 296d4e8c40..13bde9699c 100644 --- a/server/src/test/java/com/vaadin/server/VaadinServletTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinServletTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import javax.servlet.http.HttpServletRequest; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -25,39 +27,39 @@ public class VaadinServletTest { @Test public void testGetLastPathParameter() { - Assert.assertEquals("", + assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com")); - Assert.assertEquals(";a", + assertEquals(";a", VaadinServlet.getLastPathParameter("http://myhost.com;a")); - Assert.assertEquals("", + assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/hello")); - Assert.assertEquals(";b=c", VaadinServlet + assertEquals(";b=c", VaadinServlet .getLastPathParameter("http://myhost.com/hello;b=c")); - Assert.assertEquals("", + assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/hello/")); - Assert.assertEquals("", VaadinServlet + assertEquals("", VaadinServlet .getLastPathParameter("http://myhost.com/hello;a/")); - Assert.assertEquals("", VaadinServlet + assertEquals("", VaadinServlet .getLastPathParameter("http://myhost.com/hello;a=1/")); - Assert.assertEquals(";b", VaadinServlet + assertEquals(";b", VaadinServlet .getLastPathParameter("http://myhost.com/hello/;b")); - Assert.assertEquals(";b=1", VaadinServlet + assertEquals(";b=1", VaadinServlet .getLastPathParameter("http://myhost.com/hello/;b=1")); - Assert.assertEquals(";b=1,c=2", VaadinServlet + assertEquals(";b=1,c=2", VaadinServlet .getLastPathParameter("http://myhost.com/hello/;b=1,c=2")); - Assert.assertEquals("", VaadinServlet + assertEquals("", VaadinServlet .getLastPathParameter("http://myhost.com/hello/;b=1,c=2/")); - Assert.assertEquals("", VaadinServlet + assertEquals("", VaadinServlet .getLastPathParameter("http://myhost.com/a;hello/;a/")); - Assert.assertEquals("", VaadinServlet + assertEquals("", VaadinServlet .getLastPathParameter("http://myhost.com/a;hello/;a=1/")); - Assert.assertEquals(";b", VaadinServlet + assertEquals(";b", VaadinServlet .getLastPathParameter("http://myhost.com/a;hello/;b")); - Assert.assertEquals(";b=1", VaadinServlet + assertEquals(";b=1", VaadinServlet .getLastPathParameter("http://myhost.com/a;hello/;b=1")); - Assert.assertEquals(";b=1,c=2", VaadinServlet + assertEquals(";b=1,c=2", VaadinServlet .getLastPathParameter("http://myhost.com/a;hello/;b=1,c=2")); - Assert.assertEquals("", VaadinServlet + assertEquals("", VaadinServlet .getLastPathParameter("http://myhost.com/a;hello/;b=1,c=2/")); } @@ -67,61 +69,59 @@ public class VaadinServletTest { // Mapping: /VAADIN/* // /VAADIN - Assert.assertNull(servlet + assertNull(servlet .getStaticFilePath(createServletRequest("/VAADIN", null))); // /VAADIN/ - not really sensible but still interpreted as a resource // request - Assert.assertEquals("/VAADIN/", servlet + assertEquals("/VAADIN/", servlet .getStaticFilePath(createServletRequest("/VAADIN", "/"))); // /VAADIN/vaadinBootstrap.js - Assert.assertEquals("/VAADIN/vaadinBootstrap.js", - servlet.getStaticFilePath(createServletRequest("/VAADIN", - "/vaadinBootstrap.js"))); + assertEquals("/VAADIN/vaadinBootstrap.js", servlet.getStaticFilePath( + createServletRequest("/VAADIN", "/vaadinBootstrap.js"))); // /VAADIN/foo bar.js - Assert.assertEquals("/VAADIN/foo bar.js", servlet.getStaticFilePath( + assertEquals("/VAADIN/foo bar.js", servlet.getStaticFilePath( createServletRequest("/VAADIN", "/foo bar.js"))); // /VAADIN/.. - not normalized and disallowed in this method - Assert.assertEquals("/VAADIN/..", servlet + assertEquals("/VAADIN/..", servlet .getStaticFilePath(createServletRequest("/VAADIN", "/.."))); // Mapping: /* // / - Assert.assertNull( - servlet.getStaticFilePath(createServletRequest("", null))); + assertNull(servlet.getStaticFilePath(createServletRequest("", null))); // /VAADIN - Assert.assertNull( + assertNull( servlet.getStaticFilePath(createServletRequest("", "/VAADIN"))); // /VAADIN/ - Assert.assertEquals("/VAADIN/", servlet + assertEquals("/VAADIN/", servlet .getStaticFilePath(createServletRequest("", "/VAADIN/"))); // /VAADIN/foo bar.js - Assert.assertEquals("/VAADIN/foo bar.js", servlet.getStaticFilePath( + assertEquals("/VAADIN/foo bar.js", servlet.getStaticFilePath( createServletRequest("", "/VAADIN/foo bar.js"))); // /VAADIN/.. - not normalized and disallowed in this method - Assert.assertEquals("/VAADIN/..", servlet + assertEquals("/VAADIN/..", servlet .getStaticFilePath(createServletRequest("", "/VAADIN/.."))); // /BAADIN/foo.js - Assert.assertNull(servlet + assertNull(servlet .getStaticFilePath(createServletRequest("", "/BAADIN/foo.js"))); // Mapping: /myservlet/* // /myservlet - Assert.assertNull(servlet + assertNull(servlet .getStaticFilePath(createServletRequest("/myservlet", null))); // /myservlet/VAADIN - Assert.assertNull(servlet.getStaticFilePath( + assertNull(servlet.getStaticFilePath( createServletRequest("/myservlet", "/VAADIN"))); // /myservlet/VAADIN/ - Assert.assertEquals("/VAADIN/", servlet.getStaticFilePath( + assertEquals("/VAADIN/", servlet.getStaticFilePath( createServletRequest("/myservlet", "/VAADIN/"))); // /myservlet/VAADIN/foo bar.js - Assert.assertEquals("/VAADIN/foo bar.js", servlet.getStaticFilePath( + assertEquals("/VAADIN/foo bar.js", servlet.getStaticFilePath( createServletRequest("/myservlet", "/VAADIN/foo bar.js"))); // /myservlet/VAADIN/.. - not normalized and disallowed in this method - Assert.assertEquals("/VAADIN/..", servlet.getStaticFilePath( + assertEquals("/VAADIN/..", servlet.getStaticFilePath( createServletRequest("/myservlet", "/VAADIN/.."))); // /myservlet/BAADIN/foo.js - Assert.assertNull(servlet.getStaticFilePath( + assertNull(servlet.getStaticFilePath( createServletRequest("/myservlet", "/BAADIN/foo.js"))); } diff --git a/server/src/test/java/com/vaadin/server/VaadinSessionTest.java b/server/src/test/java/com/vaadin/server/VaadinSessionTest.java index a3d0746149..ccd610269c 100644 --- a/server/src/test/java/com/vaadin/server/VaadinSessionTest.java +++ b/server/src/test/java/com/vaadin/server/VaadinSessionTest.java @@ -15,6 +15,12 @@ */ package com.vaadin.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -33,7 +39,6 @@ import javax.servlet.http.HttpSessionBindingEvent; import org.easymock.EasyMock; import org.easymock.IMocksControl; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -196,11 +201,11 @@ public class VaadinSessionTest implements Serializable { final AtomicBoolean detachCalled = new AtomicBoolean(false); ui.addDetachListener((DetachEvent event) -> { detachCalled.set(true); - Assert.assertEquals(ui, UI.getCurrent()); - Assert.assertEquals(ui.getPage(), Page.getCurrent()); - Assert.assertEquals(session, VaadinSession.getCurrent()); - Assert.assertEquals(mockService, VaadinService.getCurrent()); - Assert.assertEquals(mockServlet, VaadinServlet.getCurrent()); + assertEquals(ui, UI.getCurrent()); + assertEquals(ui.getPage(), Page.getCurrent()); + assertEquals(session, VaadinSession.getCurrent()); + assertEquals(mockService, VaadinService.getCurrent()); + assertEquals(mockServlet, VaadinServlet.getCurrent()); }); session.valueUnbound( @@ -211,7 +216,7 @@ public class VaadinSessionTest implements Serializable { // VaadinService.fireSessionDestroy, // we need to run the // pending task ourselves - Assert.assertTrue(detachCalled.get()); + assertTrue(detachCalled.get()); } @Test @@ -219,11 +224,11 @@ public class VaadinSessionTest implements Serializable { final AtomicBoolean detachCalled = new AtomicBoolean(false); ui.addDetachListener((DetachEvent event) -> { detachCalled.set(true); - Assert.assertEquals(ui, UI.getCurrent()); - Assert.assertEquals(ui.getPage(), Page.getCurrent()); - Assert.assertEquals(session, VaadinSession.getCurrent()); - Assert.assertEquals(mockService, VaadinService.getCurrent()); - Assert.assertEquals(mockServlet, VaadinServlet.getCurrent()); + assertEquals(ui, UI.getCurrent()); + assertEquals(ui.getPage(), Page.getCurrent()); + assertEquals(session, VaadinSession.getCurrent()); + assertEquals(mockService, VaadinService.getCurrent()); + assertEquals(mockServlet, VaadinServlet.getCurrent()); }); CurrentInstance.clearAll(); session.close(); @@ -234,7 +239,7 @@ public class VaadinSessionTest implements Serializable { // VaadinService.fireSessionDestroy, // we need to run the // pending task ourselves - Assert.assertTrue(detachCalled.get()); + assertTrue(detachCalled.get()); } @Test @@ -287,8 +292,8 @@ public class VaadinSessionTest implements Serializable { VaadinSession.setCurrent(session); session.lock(); SerializationTestLabel label = new SerializationTestLabel(); - Assert.assertEquals("Session should be set when instance is created", - session, label.session); + assertEquals("Session should be set when instance is created", session, + label.session); ui.setContent(label); int uiId = ui.getUIId(); @@ -307,11 +312,10 @@ public class VaadinSessionTest implements Serializable { VaadinSession deserializedSession = (VaadinSession) in.readObject(); - Assert.assertNull("Current session shouldn't leak from deserialisation", + assertNull("Current session shouldn't leak from deserialisation", VaadinSession.getCurrent()); - Assert.assertNotSame("Should get a new session", session, - deserializedSession); + assertNotSame("Should get a new session", session, deserializedSession); // Restore http session and service instance so the session can be // locked @@ -322,7 +326,7 @@ public class VaadinSessionTest implements Serializable { SerializationTestLabel deserializedLabel = (SerializationTestLabel) deserializedUi .getContent(); - Assert.assertEquals( + assertEquals( "Current session should be available in SerializationTestLabel.readObject", deserializedSession, deserializedLabel.session); deserializedSession.unlock(); @@ -335,20 +339,20 @@ public class VaadinSessionTest implements Serializable { ui.setContent(new Label() { private void writeObject(ObjectOutputStream out) throws IOException { - Assert.assertTrue(session.hasLock()); + assertTrue(session.hasLock()); lockChecked.set(true); out.defaultWriteObject(); } }); session.unlock(); - Assert.assertFalse(session.hasLock()); + assertFalse(session.hasLock()); ObjectOutputStream out = new ObjectOutputStream( new ByteArrayOutputStream()); out.writeObject(session); - Assert.assertFalse(session.hasLock()); - Assert.assertTrue(lockChecked.get()); + assertFalse(session.hasLock()); + assertTrue(lockChecked.get()); } } diff --git a/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java b/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java index d377496e19..49e32ebeec 100644 --- a/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java +++ b/server/src/test/java/com/vaadin/server/communication/AtmospherePushConnectionTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.server.communication; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -22,7 +24,6 @@ import java.io.ObjectOutputStream; import org.atmosphere.cpr.AtmosphereResource; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.communication.AtmospherePushConnection.State; @@ -39,7 +40,7 @@ public class AtmospherePushConnectionTest { AtmospherePushConnection connection = new AtmospherePushConnection(ui); connection.connect(resource); - Assert.assertEquals(State.CONNECTED, connection.getState()); + assertEquals(State.CONNECTED, connection.getState()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -48,6 +49,6 @@ public class AtmospherePushConnectionTest { connection = (AtmospherePushConnection) new ObjectInputStream( new ByteArrayInputStream(baos.toByteArray())).readObject(); - Assert.assertEquals(State.DISCONNECTED, connection.getState()); + assertEquals(State.DISCONNECTED, connection.getState()); } } diff --git a/server/src/test/java/com/vaadin/server/communication/MetadataWriterTest.java b/server/src/test/java/com/vaadin/server/communication/MetadataWriterTest.java index 679598de91..04d85e80b7 100644 --- a/server/src/test/java/com/vaadin/server/communication/MetadataWriterTest.java +++ b/server/src/test/java/com/vaadin/server/communication/MetadataWriterTest.java @@ -15,13 +15,13 @@ */ package com.vaadin.server.communication; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; import java.io.StringWriter; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -56,20 +56,19 @@ public class MetadataWriterTest { @Test public void writeAsyncTag() throws Exception { new MetadataWriter().write(ui, writer, false, true, messages); - Assert.assertEquals("{\"async\":true}", writer.getBuffer().toString()); + assertEquals("{\"async\":true}", writer.getBuffer().toString()); } @Test public void writeRepaintTag() throws Exception { new MetadataWriter().write(ui, writer, true, false, messages); - Assert.assertEquals("{\"repaintAll\":true}", - writer.getBuffer().toString()); + assertEquals("{\"repaintAll\":true}", writer.getBuffer().toString()); } @Test public void writeRepaintAndAsyncTag() throws Exception { new MetadataWriter().write(ui, writer, true, true, messages); - Assert.assertEquals("{\"repaintAll\":true, \"async\":true}", + assertEquals("{\"repaintAll\":true, \"async\":true}", writer.getBuffer().toString()); } @@ -78,7 +77,7 @@ public class MetadataWriterTest { disableSessionExpirationMessages(messages); new MetadataWriter().write(ui, writer, false, false, messages); - Assert.assertEquals("{}", writer.getBuffer().toString()); + assertEquals("{}", writer.getBuffer().toString()); } @Test @@ -89,8 +88,7 @@ public class MetadataWriterTest { disableSessionExpirationMessages(messages); new MetadataWriter().write(ui, writer, false, false, messages); - Assert.assertEquals( - "{\"timedRedirect\":{\"interval\":15,\"url\":\"\"}}", + assertEquals("{\"timedRedirect\":{\"interval\":15,\"url\":\"\"}}", writer.getBuffer().toString()); } @@ -102,7 +100,7 @@ public class MetadataWriterTest { disableSessionExpirationMessages(messages); new MetadataWriter().write(ui, writer, false, true, messages); - Assert.assertEquals( + assertEquals( "{\"async\":true,\"timedRedirect\":{\"interval\":15,\"url\":\"\"}}", writer.getBuffer().toString()); } diff --git a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java index 6c61922307..6ded996687 100644 --- a/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java +++ b/server/src/test/java/com/vaadin/server/communication/ServletUIInitHandlerTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.server.communication; +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; @@ -24,7 +26,6 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -145,9 +146,9 @@ public class ServletUIInitHandlerTest { } }); - Assert.assertEquals(1, pre.getAndIncrement()); - Assert.assertEquals(1, errorHandlerCalls.getAndIncrement()); - Assert.assertEquals(mock.session, ui.getSession()); + assertEquals(1, pre.getAndIncrement()); + assertEquals(1, errorHandlerCalls.getAndIncrement()); + assertEquals(mock.session, ui.getSession()); } @Test @@ -180,9 +181,9 @@ public class ServletUIInitHandlerTest { } }); - Assert.assertEquals(1, pre.getAndIncrement()); + assertEquals(1, pre.getAndIncrement()); // Default error handler only logs the exception - Assert.assertEquals(mock.session, ui.getSession()); + assertEquals(mock.session, ui.getSession()); } } diff --git a/server/src/test/java/com/vaadin/tests/components/TreeTest.java b/server/src/test/java/com/vaadin/tests/components/TreeTest.java index 8fc5fc28b6..10094dc8f0 100644 --- a/server/src/test/java/com/vaadin/tests/components/TreeTest.java +++ b/server/src/test/java/com/vaadin/tests/components/TreeTest.java @@ -36,7 +36,7 @@ public class TreeTest { public void itemCollapse(CollapseEvent<String> event) { assertEquals("Source component was incorrect", tree, event.getComponent()); - Assert.assertFalse("Multiple collapse events", collapsed); + assertFalse("Multiple collapse events", collapsed); collapsed = true; } @@ -44,7 +44,7 @@ public class TreeTest { public void itemExpand(ExpandEvent<String> event) { assertEquals("Source component was incorrect", tree, event.getComponent()); - Assert.assertFalse("Multiple expand events", expanded); + assertFalse("Multiple expand events", expanded); expanded = true; } @@ -71,13 +71,13 @@ public class TreeTest { tree.addExpandListener(listener); tree.addCollapseListener(listener); - Assert.assertFalse(listener.isExpanded()); + assertFalse(listener.isExpanded()); tree.expand("Foo"); assertTrue("Item not expanded", tree.isExpanded("Foo")); assertTrue("Expand event not fired", listener.isExpanded()); - Assert.assertFalse(listener.isCollapsed()); + assertFalse(listener.isCollapsed()); tree.collapse("Foo"); - Assert.assertFalse("Item not collapsed", tree.isExpanded("Foo")); + assertFalse("Item not collapsed", tree.isExpanded("Foo")); assertTrue("Collapse event not fired", listener.isCollapsed()); } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java index d0b2b11dca..e8cfc63ec5 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java @@ -1,10 +1,12 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.util.ArrayList; import java.util.List; import java.util.concurrent.Future; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -55,7 +57,7 @@ public class GridComponentRendererTest { generateDataForClient(true); dataProvider.refreshItem(PERSON); generateDataForClient(false); - Assert.assertNotNull("Old component should exist.", oldComponent); + assertNotNull("Old component should exist.", oldComponent); } @Test @@ -63,26 +65,25 @@ public class GridComponentRendererTest { generateDataForClient(true); grid.select(PERSON); generateDataForClient(false); - Assert.assertNotNull("Old component should exist.", oldComponent); + assertNotNull("Old component should exist.", oldComponent); } @Test public void testComponentChangeOnDataProviderChange() { generateDataForClient(true); grid.setItems(PERSON); - Assert.assertEquals( - "Test component was not detached on DataProvider change.", null, - testComponent.getParent()); + assertEquals("Test component was not detached on DataProvider change.", + null, testComponent.getParent()); } private void generateDataForClient(boolean initial) { grid.getDataCommunicator().beforeClientResponse(initial); if (testComponent != null) { - Assert.assertEquals("New component was not attached.", grid, + assertEquals("New component was not attached.", grid, testComponent.getParent()); } if (oldComponent != null) { - Assert.assertEquals("Old component was not detached.", null, + assertEquals("Old component was not detached.", null, oldComponent.getParent()); } } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java index 3b107d6c9b..f6696155c2 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java @@ -3,6 +3,7 @@ package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.util.ArrayList; @@ -19,7 +20,6 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.IntStream; import org.easymock.Capture; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -169,11 +169,11 @@ public class GridMultiSelectionModelTest { customGrid.getDataCommunicator().beforeClientResponse(true); - Assert.assertFalse("Item should have been updated as selected", + assertFalse("Item should have been updated as selected", customModel.generatedData.get("Foo")); - Assert.assertFalse("Item should have been updated as NOT selected", + assertFalse("Item should have been updated as NOT selected", customModel.generatedData.get("Bar")); - Assert.assertFalse("Item should have been updated as NOT selected", + assertFalse("Item should have been updated as NOT selected", customModel.generatedData.get("Baz")); customModel.generatedData.clear(); @@ -181,11 +181,11 @@ public class GridMultiSelectionModelTest { customGrid.getSelectionModel().select("Foo"); customGrid.getDataCommunicator().beforeClientResponse(false); - Assert.assertTrue("Item should have been updated as selected", + assertTrue("Item should have been updated as selected", customModel.generatedData.get("Foo")); - Assert.assertFalse("Item should have NOT been updated", + assertFalse("Item should have NOT been updated", customModel.generatedData.containsKey("Bar")); - Assert.assertFalse("Item should have NOT been updated", + assertFalse("Item should have NOT been updated", customModel.generatedData.containsKey("Baz")); customModel.generatedData.clear(); @@ -193,11 +193,11 @@ public class GridMultiSelectionModelTest { customModel.updateSelection(asSet("Bar"), asSet("Foo")); customGrid.getDataCommunicator().beforeClientResponse(false); - Assert.assertFalse("Item should have been updated as NOT selected", + assertFalse("Item should have been updated as NOT selected", customModel.generatedData.get("Foo")); - Assert.assertTrue("Item should have been updated as selected", + assertTrue("Item should have been updated as selected", customModel.generatedData.get("Bar")); - Assert.assertFalse("Item should have NOT been updated", + assertFalse("Item should have NOT been updated", customModel.generatedData.containsKey("Baz")); // switch to single to cause event @@ -207,7 +207,7 @@ public class GridMultiSelectionModelTest { // changing selection model should trigger row updates, but the old // selection model is not triggered as it has been removed - Assert.assertTrue(customModel.generatedData.isEmpty()); // not triggered + assertTrue(customModel.generatedData.isEmpty()); // not triggered } @Test @@ -217,22 +217,22 @@ public class GridMultiSelectionModelTest { gridWithStrings.setItems("Foo", "Bar", "Baz"); GridSelectionModel<String> model = gridWithStrings.getSelectionModel(); - Assert.assertFalse(model.isSelected("Foo")); + assertFalse(model.isSelected("Foo")); model.select("Foo"); - Assert.assertTrue(model.isSelected("Foo")); - Assert.assertEquals(Optional.of("Foo"), model.getFirstSelectedItem()); + assertTrue(model.isSelected("Foo")); + assertEquals(Optional.of("Foo"), model.getFirstSelectedItem()); model.select("Bar"); - Assert.assertTrue(model.isSelected("Foo")); - Assert.assertTrue(model.isSelected("Bar")); - Assert.assertEquals(Arrays.asList("Foo", "Bar"), + assertTrue(model.isSelected("Foo")); + assertTrue(model.isSelected("Bar")); + assertEquals(Arrays.asList("Foo", "Bar"), new ArrayList<>(model.getSelectedItems())); model.deselect("Bar"); - Assert.assertFalse(model.isSelected("Bar")); - Assert.assertTrue(model.getFirstSelectedItem().isPresent()); - Assert.assertEquals(Arrays.asList("Foo"), + assertFalse(model.isSelected("Bar")); + assertTrue(model.getFirstSelectedItem().isPresent()); + assertEquals(Arrays.asList("Foo"), new ArrayList<>(model.getSelectedItems())); } @@ -598,18 +598,18 @@ public class GridMultiSelectionModelTest { AtomicReference<MultiSelectionEvent<String>> event = new AtomicReference<>(); Registration actualRegistration = model .addMultiSelectionListener(evt -> { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(evt); }); - Assert.assertSame(registration, actualRegistration); + assertSame(registration, actualRegistration); selectionListener.get().selectionChange(new MultiSelectionEvent<>(grid, model.asMultiSelect(), Collections.emptySet(), true)); - Assert.assertEquals(grid, event.get().getComponent()); - Assert.assertEquals(new LinkedHashSet<>(Arrays.asList(value)), + assertEquals(grid, event.get().getComponent()); + assertEquals(new LinkedHashSet<>(Arrays.asList(value)), event.get().getValue()); - Assert.assertTrue(event.get().isUserOriginated()); + assertTrue(event.get().isUserOriginated()); } @Test @@ -622,32 +622,32 @@ public class GridMultiSelectionModelTest { ui.setContent(grid); // no items yet, default data provider is empty not in memory one - Assert.assertFalse(model.isSelectAllCheckBoxVisible()); - Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT, + assertFalse(model.isSelectAllCheckBoxVisible()); + assertEquals(SelectAllCheckBoxVisibility.DEFAULT, model.getSelectAllCheckBoxVisibility()); grid.setItems("Foo", "Bar", "Baz"); // in-memory container keeps default - Assert.assertTrue(model.isSelectAllCheckBoxVisible()); - Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT, + assertTrue(model.isSelectAllCheckBoxVisible()); + assertEquals(SelectAllCheckBoxVisibility.DEFAULT, model.getSelectAllCheckBoxVisibility()); // change to explicit NO model.setSelectAllCheckBoxVisibility( SelectAllCheckBoxVisibility.HIDDEN); - Assert.assertEquals(SelectAllCheckBoxVisibility.HIDDEN, + assertEquals(SelectAllCheckBoxVisibility.HIDDEN, model.getSelectAllCheckBoxVisibility()); - Assert.assertFalse(model.isSelectAllCheckBoxVisible()); + assertFalse(model.isSelectAllCheckBoxVisible()); // change to explicit YES model.setSelectAllCheckBoxVisibility( SelectAllCheckBoxVisibility.VISIBLE); - Assert.assertEquals(SelectAllCheckBoxVisibility.VISIBLE, + assertEquals(SelectAllCheckBoxVisibility.VISIBLE, model.getSelectAllCheckBoxVisibility()); - Assert.assertTrue(model.isSelectAllCheckBoxVisible()); + assertTrue(model.isSelectAllCheckBoxVisible()); } @Test @@ -660,8 +660,8 @@ public class GridMultiSelectionModelTest { .setSelectionMode(SelectionMode.MULTI); // no items yet, default data provider is empty not in memory one - Assert.assertFalse(model.isSelectAllCheckBoxVisible()); - Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT, + assertFalse(model.isSelectAllCheckBoxVisible()); + assertEquals(SelectAllCheckBoxVisibility.DEFAULT, model.getSelectAllCheckBoxVisibility()); grid.setDataProvider( @@ -676,32 +676,32 @@ public class GridMultiSelectionModelTest { query -> 1000)); // not in-memory -> checkbox is hidden - Assert.assertFalse(model.isSelectAllCheckBoxVisible()); - Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT, + assertFalse(model.isSelectAllCheckBoxVisible()); + assertEquals(SelectAllCheckBoxVisibility.DEFAULT, model.getSelectAllCheckBoxVisibility()); // change to explicit YES model.setSelectAllCheckBoxVisibility( SelectAllCheckBoxVisibility.VISIBLE); - Assert.assertEquals(SelectAllCheckBoxVisibility.VISIBLE, + assertEquals(SelectAllCheckBoxVisibility.VISIBLE, model.getSelectAllCheckBoxVisibility()); - Assert.assertTrue(model.isSelectAllCheckBoxVisible()); + assertTrue(model.isSelectAllCheckBoxVisible()); // change to explicit NO model.setSelectAllCheckBoxVisibility( SelectAllCheckBoxVisibility.HIDDEN); - Assert.assertEquals(SelectAllCheckBoxVisibility.HIDDEN, + assertEquals(SelectAllCheckBoxVisibility.HIDDEN, model.getSelectAllCheckBoxVisibility()); - Assert.assertFalse(model.isSelectAllCheckBoxVisible()); + assertFalse(model.isSelectAllCheckBoxVisible()); // change back to depends on data provider model.setSelectAllCheckBoxVisibility( SelectAllCheckBoxVisibility.DEFAULT); - Assert.assertFalse(model.isSelectAllCheckBoxVisible()); - Assert.assertEquals(SelectAllCheckBoxVisibility.DEFAULT, + assertFalse(model.isSelectAllCheckBoxVisible()); + assertEquals(SelectAllCheckBoxVisibility.DEFAULT, model.getSelectAllCheckBoxVisibility()); } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridNoSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridNoSelectionModelTest.java index 4222b20d15..a33387e256 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridNoSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridNoSelectionModelTest.java @@ -1,10 +1,12 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Optional; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -34,15 +36,15 @@ public class GridNoSelectionModelTest { public void select() { model.select(PERSON_A); - Assert.assertFalse(model.isSelected(PERSON_A)); - Assert.assertEquals(0, model.getSelectedItems().size()); - Assert.assertEquals(Optional.empty(), model.getFirstSelectedItem()); + assertFalse(model.isSelected(PERSON_A)); + assertEquals(0, model.getSelectedItems().size()); + assertEquals(Optional.empty(), model.getFirstSelectedItem()); model.select(PERSON_B); - Assert.assertFalse(model.isSelected(PERSON_B)); - Assert.assertEquals(0, model.getSelectedItems().size()); - Assert.assertEquals(Optional.empty(), model.getFirstSelectedItem()); + assertFalse(model.isSelected(PERSON_B)); + assertEquals(0, model.getSelectedItems().size()); + assertEquals(Optional.empty(), model.getFirstSelectedItem()); } @Test @@ -50,7 +52,7 @@ public class GridNoSelectionModelTest { grid.setSelectionMode(SelectionMode.SINGLE); grid.getSelectionModel().select(PERSON_B); - Assert.assertEquals(PERSON_B, + assertEquals(PERSON_B, grid.getSelectionModel().getFirstSelectedItem().get()); } @@ -59,7 +61,7 @@ public class GridNoSelectionModelTest { grid.setSelectionMode(SelectionMode.MULTI); grid.getSelectionModel().select(PERSON_B); - Assert.assertEquals(new LinkedHashSet<>(Arrays.asList(PERSON_B)), + assertEquals(new LinkedHashSet<>(Arrays.asList(PERSON_B)), grid.getSelectionModel().getSelectedItems()); } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridNullValueSort.java b/server/src/test/java/com/vaadin/tests/components/grid/GridNullValueSort.java index c68cb2901c..b3040f8725 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridNullValueSort.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridNullValueSort.java @@ -1,10 +1,11 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -148,7 +149,7 @@ public class GridNullValueSort { .createSortingComparator(); List<Integer> data = new ArrayList<>(source); data.sort(sortingComparator); - Assert.assertEquals(expected, data); + assertEquals(expected, data); } } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionModeTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionModeTest.java index e9515be789..c8ca4cf791 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionModeTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridSelectionModeTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -22,22 +23,22 @@ public class GridSelectionModeTest { @Test public void testSelectionModes() { - Assert.assertEquals(SingleSelectionModelImpl.class, + assertEquals(SingleSelectionModelImpl.class, grid.getSelectionModel().getClass()); - Assert.assertEquals(MultiSelectionModelImpl.class, + assertEquals(MultiSelectionModelImpl.class, grid.setSelectionMode(SelectionMode.MULTI).getClass()); - Assert.assertEquals(MultiSelectionModelImpl.class, + assertEquals(MultiSelectionModelImpl.class, grid.getSelectionModel().getClass()); - Assert.assertEquals(NoSelectionModel.class, + assertEquals(NoSelectionModel.class, grid.setSelectionMode(SelectionMode.NONE).getClass()); - Assert.assertEquals(NoSelectionModel.class, + assertEquals(NoSelectionModel.class, grid.getSelectionModel().getClass()); - Assert.assertEquals(SingleSelectionModelImpl.class, + assertEquals(SingleSelectionModelImpl.class, grid.setSelectionMode(SelectionMode.SINGLE).getClass()); - Assert.assertEquals(SingleSelectionModelImpl.class, + assertEquals(SingleSelectionModelImpl.class, grid.getSelectionModel().getClass()); } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java index ce4da636d0..5791e2bc9d 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java @@ -2,6 +2,8 @@ package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.util.ArrayList; @@ -12,7 +14,6 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -127,11 +128,11 @@ public class GridSingleSelectionModelTest { customGrid.getDataCommunicator().beforeClientResponse(true); - Assert.assertFalse("Item should have been updated as selected", + assertFalse("Item should have been updated as selected", customModel.generatedData.get("Foo")); - Assert.assertFalse("Item should have been updated as NOT selected", + assertFalse("Item should have been updated as NOT selected", customModel.generatedData.get("Bar")); - Assert.assertFalse("Item should have been updated as NOT selected", + assertFalse("Item should have been updated as NOT selected", customModel.generatedData.get("Baz")); customModel.generatedData.clear(); @@ -139,11 +140,11 @@ public class GridSingleSelectionModelTest { customGrid.getSelectionModel().select("Foo"); customGrid.getDataCommunicator().beforeClientResponse(false); - Assert.assertTrue("Item should have been updated as selected", + assertTrue("Item should have been updated as selected", customModel.generatedData.get("Foo")); - Assert.assertFalse("Item should have NOT been updated", + assertFalse("Item should have NOT been updated", customModel.generatedData.containsKey("Bar")); - Assert.assertFalse("Item should have NOT been updated", + assertFalse("Item should have NOT been updated", customModel.generatedData.containsKey("Baz")); // switch to another selection model to cause event @@ -154,11 +155,11 @@ public class GridSingleSelectionModelTest { // since the selection model has been removed, it is no longer a data // generator for the data communicator, would need to verify somehow // that row is not marked as selected anymore ? (done in UI tests) - Assert.assertTrue(customModel.generatedData.isEmpty()); // at least - // removed - // selection - // model is not - // triggered + assertTrue(customModel.generatedData.isEmpty()); // at least + // removed + // selection + // model is not + // triggered } @Test @@ -167,19 +168,19 @@ public class GridSingleSelectionModelTest { gridWithStrings.setItems("Foo", "Bar", "Baz"); GridSelectionModel<String> model = gridWithStrings.getSelectionModel(); - Assert.assertFalse(model.isSelected("Foo")); + assertFalse(model.isSelected("Foo")); model.select("Foo"); - Assert.assertTrue(model.isSelected("Foo")); - Assert.assertEquals(Optional.of("Foo"), model.getFirstSelectedItem()); + assertTrue(model.isSelected("Foo")); + assertEquals(Optional.of("Foo"), model.getFirstSelectedItem()); model.select("Bar"); - Assert.assertFalse(model.isSelected("Foo")); - Assert.assertTrue(model.isSelected("Bar")); + assertFalse(model.isSelected("Foo")); + assertTrue(model.isSelected("Bar")); model.deselect("Bar"); - Assert.assertFalse(model.isSelected("Bar")); - Assert.assertFalse(model.getFirstSelectedItem().isPresent()); + assertFalse(model.isSelected("Bar")); + assertFalse(model.getFirstSelectedItem().isPresent()); } @Test @@ -271,21 +272,21 @@ public class GridSingleSelectionModelTest { public void getSelectedItem() { selectionModel.setSelectedItem(PERSON_B); - Assert.assertEquals(PERSON_B, selectionModel.getSelectedItem().get()); + assertEquals(PERSON_B, selectionModel.getSelectedItem().get()); selectionModel.deselect(PERSON_B); - Assert.assertFalse(selectionModel.getSelectedItem().isPresent()); + assertFalse(selectionModel.getSelectedItem().isPresent()); } @Test public void select_deselect_getSelectedItem() { selectionModel.select(PERSON_C); - Assert.assertEquals(PERSON_C, selectionModel.getSelectedItem().get()); + assertEquals(PERSON_C, selectionModel.getSelectedItem().get()); selectionModel.deselect(PERSON_C); - Assert.assertFalse(selectionModel.getSelectedItem().isPresent()); + assertFalse(selectionModel.getSelectedItem().isPresent()); } @SuppressWarnings({ "serial" }) @@ -313,18 +314,18 @@ public class GridSingleSelectionModelTest { AtomicReference<ValueChangeEvent<?>> event = new AtomicReference<>(); Registration actualRegistration = select .addSingleSelectionListener(evt -> { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(evt); }); - Assert.assertSame(registration, actualRegistration); + assertSame(registration, actualRegistration); selectionListener.get().selectionChange(new SingleSelectionEvent<>(grid, select.asSingleSelect(), null, true)); - Assert.assertEquals(grid, event.get().getComponent()); - Assert.assertEquals(value, event.get().getValue()); - Assert.assertEquals(null, event.get().getOldValue()); - Assert.assertTrue(event.get().isUserOriginated()); + assertEquals(grid, event.get().getComponent()); + assertEquals(value, event.get().getValue()); + assertEquals(null, event.get().getOldValue()); + assertTrue(event.get().isUserOriginated()); } } diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridValueProvider.java b/server/src/test/java/com/vaadin/tests/components/grid/GridValueProvider.java index 27ba971127..6b3d85900d 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridValueProvider.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridValueProvider.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import java.util.List; import java.util.Locale; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.provider.DataProvider; @@ -39,7 +41,7 @@ public class GridValueProvider { person -> person.getFirstName() + " " + person.getLastName()); Person person = new Person("first", "last", "email", 123, Sex.UNKNOWN, null); - Assert.assertEquals("first last", col.getValueProvider().apply(person)); + assertEquals("first last", col.getValueProvider().apply(person)); } @Test @@ -49,7 +51,7 @@ public class GridValueProvider { .getColumn("email"); Person person = new Person("first", "last", "eeemaaail", 123, Sex.UNKNOWN, null); - Assert.assertEquals("eeemaaail", col.getValueProvider().apply(person)); + assertEquals("eeemaaail", col.getValueProvider().apply(person)); } @@ -71,7 +73,7 @@ public class GridValueProvider { List<Person> queryPersons = persons.fetch(new Query<>()) .collect(Collectors.toList()); - Assert.assertEquals(1, queryPersons.size()); - Assert.assertSame(upperCasePerson, queryPersons.get(0)); + assertEquals(1, queryPersons.size()); + assertSame(upperCasePerson, queryPersons.get(0)); } } diff --git a/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java index e0706d9575..5a67d2bcce 100644 --- a/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java @@ -15,10 +15,12 @@ */ package com.vaadin.tests.components.menubar; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.ExternalResource; @@ -140,8 +142,8 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase<MenuBar> { List<MenuItem> expectedMenuItems = expected.getItems(); List<MenuItem> actualMenuItems = result.getItems(); - Assert.assertEquals("Different amount of menu items", - expectedMenuItems.size(), actualMenuItems.size()); + assertEquals("Different amount of menu items", expectedMenuItems.size(), + actualMenuItems.size()); for (int i = 0; i < expectedMenuItems.size(); ++i) { compareMenus(expectedMenuItems.get(i), actualMenuItems.get(i)); @@ -153,38 +155,37 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase<MenuBar> { private void compareMenus(MenuItem expected, MenuItem actual) { String baseError = "Error Comparing MenuItem " + expected.getText() + ": "; - Assert.assertEquals(baseError + "Visibile", expected.isVisible(), + assertEquals(baseError + "Visibile", expected.isVisible(), actual.isVisible()); - Assert.assertEquals(baseError + "Checkable", expected.isCheckable(), + assertEquals(baseError + "Checkable", expected.isCheckable(), actual.isCheckable()); - Assert.assertEquals(baseError + "Checked", expected.isChecked(), + assertEquals(baseError + "Checked", expected.isChecked(), actual.isChecked()); - Assert.assertEquals(baseError + "Separator", expected.isSeparator(), + assertEquals(baseError + "Separator", expected.isSeparator(), actual.isSeparator()); - Assert.assertEquals(baseError + "Enabled", expected.isEnabled(), + assertEquals(baseError + "Enabled", expected.isEnabled(), actual.isEnabled()); - Assert.assertEquals(baseError + "Text", expected.getText(), - actual.getText()); - Assert.assertEquals(baseError + "Description", - expected.getDescription(), actual.getDescription()); - Assert.assertEquals(baseError + "Style Name", expected.getStyleName(), + assertEquals(baseError + "Text", expected.getText(), actual.getText()); + assertEquals(baseError + "Description", expected.getDescription(), + actual.getDescription()); + assertEquals(baseError + "Style Name", expected.getStyleName(), actual.getStyleName()); if (expected.getIcon() != null) { - Assert.assertNotNull(baseError + "Icon was null", actual.getIcon()); + assertNotNull(baseError + "Icon was null", actual.getIcon()); } else { if (actual.getIcon() != null) { - Assert.fail(baseError + "Icon should've been null"); + fail(baseError + "Icon should've been null"); } } - Assert.assertEquals(baseError + "Has Children", expected.hasChildren(), + assertEquals(baseError + "Has Children", expected.hasChildren(), actual.hasChildren()); if (expected.hasChildren()) { List<MenuItem> children = expected.getChildren(); List<MenuItem> actualChildren = actual.getChildren(); - Assert.assertEquals(baseError + "Child count", children.size(), + assertEquals(baseError + "Child count", children.size(), actualChildren.size()); for (int i = 0; i < children.size(); ++i) { compareMenus(children.get(i), actualChildren.get(i)); diff --git a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java index 1876d8de35..d7abcd7301 100644 --- a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java +++ b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.components.treegrid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.TreeData; @@ -35,16 +38,16 @@ public class TreeGridTest { treeGrid.addCollapseListener(e -> collapseEventFired = true); // Test expand event - Assert.assertFalse(expandEventFired); + assertFalse(expandEventFired); treeGrid.expand("Foo"); - Assert.assertTrue("Item not expanded", treeGrid.isExpanded("Foo")); - Assert.assertTrue("Expand event not fired", expandEventFired); + assertTrue("Item not expanded", treeGrid.isExpanded("Foo")); + assertTrue("Expand event not fired", expandEventFired); // Test collapse event - Assert.assertFalse(collapseEventFired); + assertFalse(collapseEventFired); treeGrid.collapse("Foo"); - Assert.assertFalse("Item not collapsed", treeGrid.isExpanded("Foo")); - Assert.assertTrue("Collapse event not fired", collapseEventFired); + assertFalse("Item not collapsed", treeGrid.isExpanded("Foo")); + assertTrue("Collapse event not fired", collapseEventFired); } @Test @@ -52,8 +55,8 @@ public class TreeGridTest { Column<String, String> column = treeGrid.addColumn(Object::toString) .setId("foo"); treeGrid.setHierarchyColumn("foo"); - Assert.assertEquals("Hierarchy column was not correctly returned", - column, treeGrid.getHierarchyColumn()); + assertEquals("Hierarchy column was not correctly returned", column, + treeGrid.getHierarchyColumn()); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/AbstractConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/AbstractConverterTest.java index ead81250bf..797a4bc96f 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/AbstractConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/AbstractConverterTest.java @@ -1,6 +1,10 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.Converter; @@ -23,17 +27,17 @@ public abstract class AbstractConverterTest { protected <T> void assertValue(String assertMessage, T expectedValue, Result<?> result) { - Assert.assertNotNull("Result should never be null", result); - Assert.assertFalse("Result is not ok", result.isError()); - Assert.assertEquals(expectedValue, + assertNotNull("Result should never be null", result); + assertFalse("Result is not ok", result.isError()); + assertEquals(expectedValue, result.getOrThrow(message -> new AssertionError( assertMessage != null ? assertMessage : message))); } protected void assertError(String expectedResultMessage, Result<?> result) { - Assert.assertNotNull("Result should never be null", result); - Assert.assertTrue("Result should be an error", result.isError()); - Assert.assertEquals(expectedResultMessage, result.getMessage().get()); + assertNotNull("Result should never be null", result); + assertTrue("Result should be an error", result.isError()); + assertEquals(expectedResultMessage, result.getMessage().get()); } protected String getErrorMessage() { diff --git a/server/src/test/java/com/vaadin/tests/data/converter/AbstractStringConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/AbstractStringConverterTest.java index 123ef80de2..459702beaf 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/AbstractStringConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/AbstractStringConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.Converter; @@ -23,8 +25,8 @@ public abstract class AbstractStringConverterTest public void testErrorMessage() { Result<?> result = getConverter().convertToModel("abc", new ValueContext()); - Assert.assertTrue(result.isError()); - Assert.assertEquals(getErrorMessage(), result.getMessage().get()); + assertTrue(result.isError()); + assertEquals(getErrorMessage(), result.getMessage().get()); } @Override diff --git a/server/src/test/java/com/vaadin/tests/data/converter/ConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/ConverterTest.java index 3ba3c28882..3c31fddd7e 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/ConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/ConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.data.Converter; @@ -26,9 +27,9 @@ public class ConverterTest { @Test public void basicConversion() { - Assert.assertEquals("presentation-123", + assertEquals("presentation-123", converter.convertToPresentation("123", new ValueContext())); - Assert.assertEquals("123", + assertEquals("123", converter.convertToModel("presentation-123", new ValueContext()) .getOrThrow(msg -> new AssertionError(msg))); } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/LocalDateTimeToDateConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/LocalDateTimeToDateConverterTest.java index fdad1391f5..eaa66fd526 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/LocalDateTimeToDateConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/LocalDateTimeToDateConverterTest.java @@ -15,13 +15,14 @@ */ package com.vaadin.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.Binder; @@ -56,7 +57,7 @@ public class LocalDateTimeToDateConverterTest extends AbstractConverterTest { @Test public void testToPresentation() { - Assert.assertEquals(LOCAL_DATE, + assertEquals(LOCAL_DATE, getConverter().convertToPresentation(DATE, new ValueContext())); } @@ -73,7 +74,7 @@ public class LocalDateTimeToDateConverterTest extends AbstractConverterTest { BeanWithDate bean = new BeanWithDate(); binder.writeBean(bean); - Assert.assertEquals(DATE, bean.getDate()); + assertEquals(DATE, bean.getDate()); } public static class BeanWithDate { diff --git a/server/src/test/java/com/vaadin/tests/data/converter/LocalDateToDateConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/LocalDateToDateConverterTest.java index 9517ad783b..c1466ab94c 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/LocalDateToDateConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/LocalDateToDateConverterTest.java @@ -15,13 +15,14 @@ */ package com.vaadin.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.time.LocalDate; import java.time.ZoneId; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.Binder; @@ -57,7 +58,7 @@ public class LocalDateToDateConverterTest extends AbstractConverterTest { @Test public void testToPresentation() { - Assert.assertEquals(LOCAL_DATE, + assertEquals(LOCAL_DATE, getConverter().convertToPresentation(DATE, new ValueContext())); } @@ -74,7 +75,7 @@ public class LocalDateToDateConverterTest extends AbstractConverterTest { BeanWithDate bean = new BeanWithDate(); binder.writeBean(bean); - Assert.assertEquals(DATE, bean.getDate()); + assertEquals(DATE, bean.getDate()); } public static class BeanWithDate { diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java index 60dad91e61..54363e768f 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigDecimalConverterTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.Result; @@ -48,7 +49,7 @@ public class StringToBigDecimalConverterTest String converted = getConverter().convertToPresentation(bd, new ValueContext(Locale.GERMAN)); - Assert.assertEquals(expected, converted); + assertEquals(expected, converted); } @Test @@ -58,7 +59,7 @@ public class StringToBigDecimalConverterTest assertValue(BigDecimal.ZERO, converter.convertToModel("", new ValueContext())); - Assert.assertEquals("0", converter - .convertToPresentation(BigDecimal.ZERO, new ValueContext())); + assertEquals("0", converter.convertToPresentation(BigDecimal.ZERO, + new ValueContext())); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java index 28abe19224..132feee20d 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToBigIntegerConverterTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.math.BigInteger; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.Result; @@ -50,8 +51,7 @@ public class StringToBigIntegerConverterTest String converted = getConverter().convertToPresentation(bd, new ValueContext(Locale.GERMAN)); - Assert.assertEquals( - "Value with specific locale was converted incorrectly", + assertEquals("Value with specific locale was converted incorrectly", expected, converted); } @@ -62,8 +62,8 @@ public class StringToBigIntegerConverterTest assertValue(BigInteger.ZERO, converter.convertToModel("", new ValueContext())); - Assert.assertEquals("0", converter - .convertToPresentation(BigInteger.ZERO, new ValueContext())); + assertEquals("0", converter.convertToPresentation(BigInteger.ZERO, + new ValueContext())); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java index 5c265fe31c..f1ab5f19f6 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToBooleanConverterTest.java @@ -1,10 +1,11 @@ package com.vaadin.tests.data.converter; +import static org.junit.Assert.assertEquals; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.ValueContext; @@ -57,9 +58,9 @@ public class StringToBooleanConverterTest extends AbstractStringConverterTest { assertValue(false, yesNoConverter.convertToModel("no", new ValueContext())); - Assert.assertEquals("yes", + assertEquals("yes", yesNoConverter.convertToPresentation(true, new ValueContext())); - Assert.assertEquals("no", yesNoConverter.convertToPresentation(false, + assertEquals("no", yesNoConverter.convertToPresentation(false, new ValueContext())); } @@ -70,23 +71,22 @@ public class StringToBooleanConverterTest extends AbstractStringConverterTest { assertValue(false, emptyTrueConverter.convertToModel("ABSENT", new ValueContext())); - Assert.assertEquals("", emptyTrueConverter.convertToPresentation(true, + assertEquals("", emptyTrueConverter.convertToPresentation(true, + new ValueContext())); + assertEquals("ABSENT", emptyTrueConverter.convertToPresentation(false, new ValueContext())); - Assert.assertEquals("ABSENT", emptyTrueConverter - .convertToPresentation(false, new ValueContext())); } @Test public void testLocale() { - Assert.assertEquals("May 18, 2033", localeConverter - .convertToPresentation(true, new ValueContext(Locale.US))); - Assert.assertEquals("January 24, 2065", localeConverter + assertEquals("May 18, 2033", localeConverter.convertToPresentation(true, + new ValueContext(Locale.US))); + assertEquals("January 24, 2065", localeConverter .convertToPresentation(false, new ValueContext(Locale.US))); - Assert.assertEquals("18. Mai 2033", localeConverter - .convertToPresentation(true, new ValueContext(Locale.GERMANY))); - Assert.assertEquals("24. Januar 2065", - localeConverter.convertToPresentation(false, - new ValueContext(Locale.GERMANY))); + assertEquals("18. Mai 2033", localeConverter.convertToPresentation(true, + new ValueContext(Locale.GERMANY))); + assertEquals("24. Januar 2065", localeConverter.convertToPresentation( + false, new ValueContext(Locale.GERMANY))); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java index 2dda3d7dbf..43dab81203 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToDoubleConverterTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.Result; @@ -31,8 +33,8 @@ public class StringToDoubleConverterTest extends AbstractConverterTest { public void testErrorMessage() { Result<Double> result = getConverter().convertToModel("abc", new ValueContext()); - Assert.assertTrue(result.isError()); - Assert.assertEquals("Failed", result.getMessage().get()); + assertTrue(result.isError()); + assertEquals("Failed", result.getMessage().get()); } @Test @@ -41,7 +43,7 @@ public class StringToDoubleConverterTest extends AbstractConverterTest { getErrorMessage()); assertValue(0.0, converter.convertToModel("", new ValueContext())); - Assert.assertEquals("0", + assertEquals("0", converter.convertToPresentation(0.0, new ValueContext())); } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java index 2601ae2cd4..6cac48df97 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToFloatConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.data.ValueContext; @@ -40,7 +41,7 @@ public class StringToFloatConverterTest extends AbstractStringConverterTest { assertValue((float) 0.0, converter.convertToModel("", new ValueContext())); - Assert.assertEquals("0", converter.convertToPresentation((float) 0.0, + assertEquals("0", converter.convertToPresentation((float) 0.0, new ValueContext())); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java index 8ea4e7a558..db050233cf 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToIntegerConverterTest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.Result; @@ -22,9 +25,8 @@ public class StringToIntegerConverterTest extends AbstractConverterTest { @Test public void testValueOutOfRange() { - Double[] values = { Integer.MAX_VALUE * 2.0, - Integer.MIN_VALUE * 2.0, Long.MAX_VALUE * 2.0, - Long.MIN_VALUE * 2.0 }; + Double[] values = { Integer.MAX_VALUE * 2.0, Integer.MIN_VALUE * 2.0, + Long.MAX_VALUE * 2.0, Long.MIN_VALUE * 2.0 }; boolean accepted = false; for (Number value : values) { @@ -35,7 +37,7 @@ public class StringToIntegerConverterTest extends AbstractConverterTest { accepted = true; } } - Assert.assertFalse("Accepted value outside range of int", accepted); + assertFalse("Accepted value outside range of int", accepted); } @Test @@ -48,8 +50,8 @@ public class StringToIntegerConverterTest extends AbstractConverterTest { public void testErrorMessage() { Result<Integer> result = getConverter().convertToModel("abc", new ValueContext()); - Assert.assertTrue(result.isError()); - Assert.assertEquals("Failed", result.getMessage().get()); + assertTrue(result.isError()); + assertEquals("Failed", result.getMessage().get()); } @Test @@ -58,7 +60,7 @@ public class StringToIntegerConverterTest extends AbstractConverterTest { getErrorMessage()); assertValue(0, converter.convertToModel("", new ValueContext())); - Assert.assertEquals("0", + assertEquals("0", converter.convertToPresentation(0, new ValueContext())); } } diff --git a/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java b/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java index fb8ab07d80..ed70763823 100644 --- a/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/data/converter/StringToLongConverterTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.data.converter; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.data.Result; @@ -56,7 +57,7 @@ public class StringToLongConverterTest extends AbstractStringConverterTest { getErrorMessage()); assertValue((long) 0, converter.convertToModel("", new ValueContext())); - Assert.assertEquals("0", + assertEquals("0", converter.convertToPresentation((long) 0, new ValueContext())); } } diff --git a/server/src/test/java/com/vaadin/tests/data/selection/AbstractStaleSelectionTest.java b/server/src/test/java/com/vaadin/tests/data/selection/AbstractStaleSelectionTest.java index 45e25cc867..1a8529302e 100644 --- a/server/src/test/java/com/vaadin/tests/data/selection/AbstractStaleSelectionTest.java +++ b/server/src/test/java/com/vaadin/tests/data/selection/AbstractStaleSelectionTest.java @@ -1,9 +1,11 @@ package com.vaadin.tests.data.selection; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; import java.util.concurrent.Future; -import org.junit.Assert; import org.junit.Before; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -56,13 +58,12 @@ public abstract class AbstractStaleSelectionTest<S extends AbstractListing<StrBe } protected final void assertIsStale(StrBean bean) { - Assert.assertTrue("Bean with id " + bean.getId() + " should be stale.", + assertTrue("Bean with id " + bean.getId() + " should be stale.", dataProvider.isStale(bean)); } protected final void assertNotStale(StrBean bean) { - Assert.assertFalse( - "Bean with id " + bean.getId() + " should not be stale.", + assertFalse("Bean with id " + bean.getId() + " should not be stale.", dataProvider.isStale(bean)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/selection/GridStaleElementTest.java b/server/src/test/java/com/vaadin/tests/data/selection/GridStaleElementTest.java index 64b7ecbc35..16ed3df97c 100644 --- a/server/src/test/java/com/vaadin/tests/data/selection/GridStaleElementTest.java +++ b/server/src/test/java/com/vaadin/tests/data/selection/GridStaleElementTest.java @@ -1,9 +1,11 @@ package com.vaadin.tests.data.selection; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; import java.util.concurrent.Future; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -64,15 +66,15 @@ public class GridStaleElementTest { assertStale(toReplace); model.getSelectedItems() - .forEach(item -> Assert.assertFalse( + .forEach(item -> assertFalse( "Selection should not contain stale values", dataProvider.isStale(item))); Object oldId = dataProvider.getId(toReplace); - Assert.assertTrue("Selection did not contain an item with matching Id.", + assertTrue("Selection did not contain an item with matching Id.", model.getSelectedItems().stream().map(dataProvider::getId) .anyMatch(oldId::equals)); - Assert.assertTrue("Stale element is not considered selected.", + assertTrue("Stale element is not considered selected.", model.isSelected(toReplace)); } @@ -91,26 +93,25 @@ public class GridStaleElementTest { assertStale(toReplace); model.getSelectedItems() - .forEach(i -> Assert.assertFalse( + .forEach(i -> assertFalse( "Selection should not contain stale values", dataProvider.isStale(i))); - Assert.assertTrue("Selection did not contain an item with matching Id.", + assertTrue("Selection did not contain an item with matching Id.", model.getSelectedItems().stream().map(dataProvider::getId) .filter(i -> dataProvider.getId(toReplace).equals(i)) .findFirst().isPresent()); - Assert.assertTrue("Stale element is not considered selected.", + assertTrue("Stale element is not considered selected.", model.isSelected(toReplace)); } private void assertNotStale(StrBean bean) { - Assert.assertFalse( - "Bean with id " + bean.getId() + " should not be stale.", + assertFalse("Bean with id " + bean.getId() + " should not be stale.", dataProvider.isStale(bean)); } private void assertStale(StrBean bean) { - Assert.assertTrue("Bean with id " + bean.getId() + " should be stale.", + assertTrue("Bean with id " + bean.getId() + " should be stale.", dataProvider.isStale(bean)); } } diff --git a/server/src/test/java/com/vaadin/tests/data/selection/StaleMultiSelectionTest.java b/server/src/test/java/com/vaadin/tests/data/selection/StaleMultiSelectionTest.java index 9769ec3997..11918df0d6 100644 --- a/server/src/test/java/com/vaadin/tests/data/selection/StaleMultiSelectionTest.java +++ b/server/src/test/java/com/vaadin/tests/data/selection/StaleMultiSelectionTest.java @@ -1,10 +1,12 @@ package com.vaadin.tests.data.selection; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Collection; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import org.junit.runners.Parameterized.Parameters; @@ -30,15 +32,15 @@ public class StaleMultiSelectionTest assertIsStale(toReplace); select.getSelectedItems() - .forEach(item -> Assert.assertFalse( + .forEach(item -> assertFalse( "Selection should not contain stale values", dataProvider.isStale(item))); Object oldId = dataProvider.getId(toReplace); - Assert.assertTrue("Selection did not contain an item with matching Id.", + assertTrue("Selection did not contain an item with matching Id.", select.getSelectedItems().stream().map(dataProvider::getId) .anyMatch(oldId::equals)); - Assert.assertTrue("Stale element is not considered selected.", + assertTrue("Stale element is not considered selected.", select.isSelected(toReplace)); } diff --git a/server/src/test/java/com/vaadin/tests/data/selection/StaleSingleSelectionTest.java b/server/src/test/java/com/vaadin/tests/data/selection/StaleSingleSelectionTest.java index e8b354de9e..bdcdb46b18 100644 --- a/server/src/test/java/com/vaadin/tests/data/selection/StaleSingleSelectionTest.java +++ b/server/src/test/java/com/vaadin/tests/data/selection/StaleSingleSelectionTest.java @@ -1,10 +1,12 @@ package com.vaadin.tests.data.selection; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.Collection; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import org.junit.runners.Parameterized.Parameters; @@ -29,10 +31,10 @@ public class StaleSingleSelectionTest dataProvider.refreshItem(replacement); assertIsStale(toReplace); - Assert.assertFalse("Selection should not contain stale values", + assertFalse("Selection should not contain stale values", dataProvider.isStale(select.getValue())); - Assert.assertEquals("Selected item id did not match original.", + assertEquals("Selected item id did not match original.", toReplace.getId(), dataProvider.getId(select.getValue())); } diff --git a/server/src/test/java/com/vaadin/tests/design/ComponentFactoryTest.java b/server/src/test/java/com/vaadin/tests/design/ComponentFactoryTest.java index 813ff361f3..41be5aa6ab 100644 --- a/server/src/test/java/com/vaadin/tests/design/ComponentFactoryTest.java +++ b/server/src/test/java/com/vaadin/tests/design/ComponentFactoryTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.tests.design; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.List; import org.junit.After; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.AbstractComponent; @@ -69,9 +70,8 @@ public class ComponentFactoryTest { Design.read(new ByteArrayInputStream("<vaadin-label />".getBytes())); - Assert.assertEquals("There should be one message logged", 1, - messages.size()); - Assert.assertEquals("Requested class " + Label.class.getCanonicalName(), + assertEquals("There should be one message logged", 1, messages.size()); + assertEquals("Requested class " + Label.class.getCanonicalName(), messages.get(0)); } @@ -109,10 +109,8 @@ public class ComponentFactoryTest { DesignContext designContext = new DesignContext(); designContext.getDefaultInstance(new DefaultInstanceTestComponent()); - Assert.assertEquals("There should be one class requests", 1, - classes.size()); - Assert.assertEquals( - "First class should be DefaultInstanceTestComponent", + assertEquals("There should be one class requests", 1, classes.size()); + assertEquals("First class should be DefaultInstanceTestComponent", DefaultInstanceTestComponent.class.getName(), classes.get(0)); } diff --git a/server/src/test/java/com/vaadin/tests/design/ComponentMapperTest.java b/server/src/test/java/com/vaadin/tests/design/ComponentMapperTest.java index 25062f76f4..e9eefa3e6b 100644 --- a/server/src/test/java/com/vaadin/tests/design/ComponentMapperTest.java +++ b/server/src/test/java/com/vaadin/tests/design/ComponentMapperTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.design; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Component; @@ -100,11 +102,11 @@ public class ComponentMapperTest { Component component = Design .read(new ByteArrayInputStream("<custom-foobar />".getBytes())); - Assert.assertTrue( + assertTrue( "<custom-foobar> should resolve " + ComponentWithCustomTagName.class.getSimpleName(), component instanceof ComponentWithCustomTagName); - Assert.assertEquals("custom-foobar", + assertEquals("custom-foobar", ((ComponentWithCustomTagName) component).tagName); } @@ -119,7 +121,7 @@ public class ComponentMapperTest { Design.write(component, bos); String writtenDesign = new String(bos.toByteArray()); - Assert.assertTrue( + assertTrue( "Written design should contain \"<custom-special\", but instead got " + writtenDesign, writtenDesign.contains("<custom-special")); diff --git a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java index a3b6fbeeeb..f3e7c237a8 100644 --- a/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java +++ b/server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java @@ -16,6 +16,7 @@ package com.vaadin.tests.design; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertNull; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -95,11 +96,11 @@ public abstract class DeclarativeTestBaseBase<T extends Component> { protected void assertEquals(String message, Object o1, Object o2) { if (o1 == null) { - Assert.assertNull(message, o2); + assertNull(message, o2); return; } if (o2 == null) { - Assert.assertNull(message, o1); + assertNull(message, o1); return; } diff --git a/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java b/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java index f448f5c2b2..9f6253067a 100644 --- a/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java +++ b/server/src/test/java/com/vaadin/tests/design/DesignFormatterTest.java @@ -16,7 +16,9 @@ package com.vaadin.tests.design; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.File; import java.math.BigDecimal; @@ -25,7 +27,6 @@ import java.util.Date; import java.util.HashSet; import java.util.TimeZone; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -80,15 +81,15 @@ public class DesignFormatterTest { assertEquals("", formatter.format(true)); assertEquals("false", formatter.format(false)); - Assert.assertTrue(formatter.parse("true", boolean.class)); - Assert.assertTrue(formatter.parse("foobar", boolean.class)); - Assert.assertTrue(formatter.parse("", boolean.class)); - Assert.assertFalse(formatter.parse("false", boolean.class)); + assertTrue(formatter.parse("true", boolean.class)); + assertTrue(formatter.parse("foobar", boolean.class)); + assertTrue(formatter.parse("", boolean.class)); + assertFalse(formatter.parse("false", boolean.class)); - Assert.assertTrue(formatter.parse("true", Boolean.class)); - Assert.assertTrue(formatter.parse("foobar", Boolean.class)); - Assert.assertTrue(formatter.parse("", Boolean.class)); - Assert.assertFalse(formatter.parse("false", Boolean.class)); + assertTrue(formatter.parse("true", Boolean.class)); + assertTrue(formatter.parse("foobar", Boolean.class)); + assertTrue(formatter.parse("", Boolean.class)); + assertFalse(formatter.parse("false", Boolean.class)); } @Test @@ -236,7 +237,7 @@ public class DesignFormatterTest { protected void assertInvalidShortcut(String shortcut) { try { formatter.parse(shortcut, ShortcutAction.class); - Assert.fail("Invalid shortcut '" + shortcut + "' should throw"); + fail("Invalid shortcut '" + shortcut + "' should throw"); } catch (IllegalArgumentException e) { // expected } diff --git a/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java b/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java index b870e55f13..f97842b0cf 100644 --- a/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java +++ b/server/src/test/java/com/vaadin/tests/design/DesignReadInConstructorTest.java @@ -16,6 +16,7 @@ package com.vaadin.tests.design; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,7 +27,6 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Attribute; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -37,7 +37,7 @@ public class DesignReadInConstructorTest { @Test public void useDesignReadInConstructor() { DesignReadInConstructor dric = new DesignReadInConstructor(); - Assert.assertEquals(3, dric.getComponentCount()); + assertEquals(3, dric.getComponentCount()); } @Test @@ -55,7 +55,7 @@ public class DesignReadInConstructorTest { } private void assertJsoupTreeEquals(Element expected, Element actual) { - Assert.assertEquals(expected.tagName(), actual.tagName()); + assertEquals(expected.tagName(), actual.tagName()); Set<String> keys = new HashSet<>(); @@ -66,12 +66,11 @@ public class DesignReadInConstructorTest { keys.add(attr.getKey()); } for (String attributeKey : keys) { - Assert.assertEquals(expected.attr(attributeKey), + assertEquals(expected.attr(attributeKey), actual.attr(attributeKey)); } - Assert.assertEquals(expected.children().size(), - actual.children().size()); + assertEquals(expected.children().size(), actual.children().size()); for (int i = 0; i < expected.children().size(); i++) { assertJsoupTreeEquals(expected.child(i), actual.child(i)); } diff --git a/server/src/test/java/com/vaadin/tests/design/DesignTest.java b/server/src/test/java/com/vaadin/tests/design/DesignTest.java index 95749aed68..115dde4934 100644 --- a/server/src/test/java/com/vaadin/tests/design/DesignTest.java +++ b/server/src/test/java/com/vaadin/tests/design/DesignTest.java @@ -15,13 +15,14 @@ */ package com.vaadin.tests.design; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Iterator; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -43,13 +44,11 @@ public class DesignTest { Component root = Design.read(getClass() .getResourceAsStream("verticallayout-two-children.html")); VerticalLayout rootLayout = (VerticalLayout) root; - Assert.assertEquals(VerticalLayout.class, root.getClass()); + assertEquals(VerticalLayout.class, root.getClass()); - Assert.assertEquals(2, rootLayout.getComponentCount()); - Assert.assertEquals(TextField.class, - rootLayout.getComponent(0).getClass()); - Assert.assertEquals(Button.class, - rootLayout.getComponent(1).getClass()); + assertEquals(2, rootLayout.getComponentCount()); + assertEquals(TextField.class, rootLayout.getComponent(0).getClass()); + assertEquals(Button.class, rootLayout.getComponent(1).getClass()); } @Test(expected = DesignException.class) diff --git a/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java b/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java index 91e7e89627..0b70006965 100644 --- a/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java +++ b/server/src/test/java/com/vaadin/tests/design/FieldNameWhichConflictsWithGettersTest.java @@ -16,6 +16,8 @@ package com.vaadin.tests.design; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -23,7 +25,6 @@ import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Test; import com.vaadin.annotations.DesignRoot; @@ -48,8 +49,8 @@ public class FieldNameWhichConflictsWithGettersTest { @Test public void readWithConflictingFields() { MyVerticalLayout v = new MyVerticalLayout(); - Assert.assertNotNull(v.caption); - Assert.assertNotNull(v.description); + assertNotNull(v.caption); + assertNotNull(v.description); } @Test @@ -72,13 +73,13 @@ public class FieldNameWhichConflictsWithGettersTest { Document doc = Jsoup.parse(str); Element body = doc.body(); Element captionElement = body.getElementById("caption"); - Assert.assertNotNull(captionElement); - Assert.assertEquals("vaadin-label", captionElement.tagName()); + assertNotNull(captionElement); + assertEquals("vaadin-label", captionElement.tagName()); Element descriptionElement = captionElement.nextElementSibling(); - Assert.assertNotNull(descriptionElement); - Assert.assertEquals("vaadin-text-field", descriptionElement.tagName()); - Assert.assertEquals("description", descriptionElement.attr("_id")); + assertNotNull(descriptionElement); + assertEquals("vaadin-text-field", descriptionElement.tagName()); + assertEquals("description", descriptionElement.attr("_id")); } } diff --git a/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java index 98ca82d646..229e4d69ac 100644 --- a/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java +++ b/server/src/test/java/com/vaadin/tests/design/InvalidTagNamesTest.java @@ -16,10 +16,11 @@ package com.vaadin.tests.design; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Button; @@ -38,7 +39,7 @@ public class InvalidTagNamesTest { public void emptyTag() { // JSoup parses empty tags into text nodes Component c = readDesign("<>foo</>"); - Assert.assertNull(c); + assertNull(c); } @Test(expected = DesignException.class) @@ -51,7 +52,7 @@ public class InvalidTagNamesTest { // JSoup will refuse to parse tags starting with - and convert them into // text nodes instead Component c = readDesign("<-v>foo</-v>"); - Assert.assertNull(c); + assertNull(c); } @Test(expected = DesignException.class) @@ -69,7 +70,7 @@ public class InvalidTagNamesTest { // parsed currently as <vaadin-button> (this should not be considered API) public void tagEndsInDash() { Component c = readDesign("<vaadin-button-></vaadin-button->"); - Assert.assertTrue(c.getClass() == Button.class); + assertTrue(c.getClass() == Button.class); } // @Test(expected = DesignException.class) @@ -77,7 +78,7 @@ public class InvalidTagNamesTest { // parsed currently as <vaadin-button> (this should not be considered API) public void tagEndsInTwoDashes() { Component c = readDesign("<vaadin-button--></vaadin-button-->"); - Assert.assertTrue(c.getClass() == Button.class); + assertTrue(c.getClass() == Button.class); } // @Test(expected = DesignException.class) @@ -85,7 +86,7 @@ public class InvalidTagNamesTest { // parsed currently as <vaadin-button> (this should not be considered API) public void tagWithTwoDashes() { Component c = readDesign("<vaadin--button></vaadin--button>"); - Assert.assertTrue(c.getClass() == Button.class); + assertTrue(c.getClass() == Button.class); } @Test(expected = DesignException.class) diff --git a/server/src/test/java/com/vaadin/tests/design/designroot/CompositeDesignRootTest.java b/server/src/test/java/com/vaadin/tests/design/designroot/CompositeDesignRootTest.java index fbe0b029f2..e18ef0b409 100644 --- a/server/src/test/java/com/vaadin/tests/design/designroot/CompositeDesignRootTest.java +++ b/server/src/test/java/com/vaadin/tests/design/designroot/CompositeDesignRootTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.junit.Test; import com.vaadin.tests.server.component.composite.MyPrefilledComposite; @@ -29,11 +31,11 @@ public class CompositeDesignRootTest { CompositeDesignRootForVerticalLayout r = new CompositeDesignRootForVerticalLayout(); // Composition root, should be VerticalLayout Component compositionRoot = r.iterator().next(); - Assert.assertNotNull(compositionRoot); - Assert.assertEquals(VerticalLayout.class, compositionRoot.getClass()); - Assert.assertNotNull(r.ok); - Assert.assertNotNull(r.cancel); - Assert.assertEquals("original", r.preInitializedField.getValue()); + assertNotNull(compositionRoot); + assertEquals(VerticalLayout.class, compositionRoot.getClass()); + assertNotNull(r.ok); + assertNotNull(r.cancel); + assertEquals("original", r.preInitializedField.getValue()); } @Test @@ -41,9 +43,8 @@ public class CompositeDesignRootTest { CompositeDesignRootForMyComposite r = new CompositeDesignRootForMyComposite(); // Composition root, should be MyPrefilledcomposite Component compositionRoot = r.iterator().next(); - Assert.assertNotNull(compositionRoot); - Assert.assertEquals(MyPrefilledComposite.class, - compositionRoot.getClass()); + assertNotNull(compositionRoot); + assertEquals(MyPrefilledComposite.class, compositionRoot.getClass()); } diff --git a/server/src/test/java/com/vaadin/tests/design/designroot/CustomComponentDesignRootTest.java b/server/src/test/java/com/vaadin/tests/design/designroot/CustomComponentDesignRootTest.java index 5331fdba4b..bab95d9e19 100644 --- a/server/src/test/java/com/vaadin/tests/design/designroot/CustomComponentDesignRootTest.java +++ b/server/src/test/java/com/vaadin/tests/design/designroot/CustomComponentDesignRootTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.junit.Test; import com.vaadin.tests.server.component.customcomponent.MyPrefilledCustomComponent; @@ -29,11 +31,11 @@ public class CustomComponentDesignRootTest { CustomComponentDesignRootForVerticalLayout r = new CustomComponentDesignRootForVerticalLayout(); // Composition root, should be VerticalLayout Component compositionRoot = r.iterator().next(); - Assert.assertNotNull(compositionRoot); - Assert.assertEquals(VerticalLayout.class, compositionRoot.getClass()); - Assert.assertNotNull(r.ok); - Assert.assertNotNull(r.cancel); - Assert.assertEquals("original", r.preInitializedField.getValue()); + assertNotNull(compositionRoot); + assertEquals(VerticalLayout.class, compositionRoot.getClass()); + assertNotNull(r.ok); + assertNotNull(r.cancel); + assertEquals("original", r.preInitializedField.getValue()); } @Test @@ -41,8 +43,8 @@ public class CustomComponentDesignRootTest { CustomComponentDesignRootForMyCustomComponent r = new CustomComponentDesignRootForMyCustomComponent(); // Composition root, should be MyPrefilledCustomComponent Component compositionRoot = r.iterator().next(); - Assert.assertNotNull(compositionRoot); - Assert.assertEquals(MyPrefilledCustomComponent.class, + assertNotNull(compositionRoot); + assertEquals(MyPrefilledCustomComponent.class, compositionRoot.getClass()); } diff --git a/server/src/test/java/com/vaadin/tests/design/designroot/DesignRootTest.java b/server/src/test/java/com/vaadin/tests/design/designroot/DesignRootTest.java index 3f35c7602d..fb1e216800 100644 --- a/server/src/test/java/com/vaadin/tests/design/designroot/DesignRootTest.java +++ b/server/src/test/java/com/vaadin/tests/design/designroot/DesignRootTest.java @@ -15,40 +15,42 @@ */ package com.vaadin.tests.design.designroot; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import org.junit.Test; public class DesignRootTest { @Test public void designAnnotationWithoutFilename() { DesignWithEmptyAnnotation d = new DesignWithEmptyAnnotation(); - Assert.assertNotNull(d.ok); - Assert.assertNotNull(d.CaNCEL); - Assert.assertEquals("original", d.preInitializedField.getValue()); + assertNotNull(d.ok); + assertNotNull(d.CaNCEL); + assertEquals("original", d.preInitializedField.getValue()); } @Test public void designAnnotationWithFilename() { DesignWithAnnotation d = new DesignWithAnnotation(); - Assert.assertNotNull(d.ok); - Assert.assertNotNull(d.cancel); - Assert.assertEquals("original", d.preInitializedField.getValue()); + assertNotNull(d.ok); + assertNotNull(d.cancel); + assertEquals("original", d.preInitializedField.getValue()); } @Test public void extendedDesignAnnotationWithoutFilename() { DesignWithEmptyAnnotation d = new ExtendedDesignWithEmptyAnnotation(); - Assert.assertNotNull(d.ok); - Assert.assertNotNull(d.CaNCEL); - Assert.assertEquals("original", d.preInitializedField.getValue()); + assertNotNull(d.ok); + assertNotNull(d.CaNCEL); + assertEquals("original", d.preInitializedField.getValue()); } @Test public void extendedDesignAnnotationWithFilename() { DesignWithAnnotation d = new ExtendedDesignWithAnnotation(); - Assert.assertNotNull(d.ok); - Assert.assertNotNull(d.cancel); - Assert.assertEquals("original", d.preInitializedField.getValue()); + assertNotNull(d.ok); + assertNotNull(d.cancel); + assertEquals("original", d.preInitializedField.getValue()); } } diff --git a/server/src/test/java/com/vaadin/tests/event/EventRouterTest.java b/server/src/test/java/com/vaadin/tests/event/EventRouterTest.java index a290d43ea3..013c8b8f58 100644 --- a/server/src/test/java/com/vaadin/tests/event/EventRouterTest.java +++ b/server/src/test/java/com/vaadin/tests/event/EventRouterTest.java @@ -15,10 +15,12 @@ */ package com.vaadin.tests.event; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.lang.reflect.Method; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,10 +72,10 @@ public class EventRouterTest { EasyMock.replay(component, listener); try { router.fireEvent(new Component.Event(component)); - Assert.fail("Did not receive expected exception from listener"); + fail("Did not receive expected exception from listener"); } catch (RuntimeException e) { // e is a ListenerMethod@MethodException - Assert.assertEquals("listener failed", e.getCause().getMessage()); + assertEquals("listener failed", e.getCause().getMessage()); } EasyMock.verify(listener); } diff --git a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java index aa37e860d7..d85c23b5f8 100644 --- a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java +++ b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -26,7 +28,6 @@ import java.util.jar.JarFile; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Component; @@ -213,7 +214,7 @@ public class ClassesSerializableTest { field.getDeclaringClass().getName(), field.getName())) .collect(Collectors.joining(", ")); - Assert.fail("Fields with functional types that are not serializable: " + fail("Fields with functional types that are not serializable: " + nonSerializableString); } @@ -233,9 +234,8 @@ public class ClassesSerializableTest { nonSerializableString += ")"; } } - Assert.fail( - "Serializable not implemented by the following classes and interfaces: " - + nonSerializableString); + fail("Serializable not implemented by the following classes and interfaces: " + + nonSerializableString); } diff --git a/server/src/test/java/com/vaadin/tests/server/CsrfTokenMissingTest.java b/server/src/test/java/com/vaadin/tests/server/CsrfTokenMissingTest.java index 2f4ba832d3..da1edeff59 100644 --- a/server/src/test/java/com/vaadin/tests/server/CsrfTokenMissingTest.java +++ b/server/src/test/java/com/vaadin/tests/server/CsrfTokenMissingTest.java @@ -15,6 +15,9 @@ */ package com.vaadin.tests.server; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; @@ -23,7 +26,6 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -149,7 +151,7 @@ public class CsrfTokenMissingTest { } catch (JsonException e) { LOGGER.log(Level.SEVERE, "", e); - Assert.assertTrue(false); + assertTrue(false); return null; } } @@ -196,8 +198,8 @@ public class CsrfTokenMissingTest { RpcRequest rpcRequest = createRequest(); - Assert.assertTrue(isDefaultToken(rpcRequest)); - Assert.assertFalse(isRequestValid(rpcRequest)); + assertTrue(isDefaultToken(rpcRequest)); + assertFalse(isRequestValid(rpcRequest)); } @Test @@ -206,8 +208,8 @@ public class CsrfTokenMissingTest { RpcRequest rpcRequest = createRequest(); - Assert.assertTrue(isDefaultToken(rpcRequest)); - Assert.assertTrue(isRequestValid(rpcRequest)); + assertTrue(isDefaultToken(rpcRequest)); + assertTrue(isRequestValid(rpcRequest)); } @Test @@ -216,8 +218,8 @@ public class CsrfTokenMissingTest { RpcRequest rpcRequest = createRequest(); - Assert.assertTrue(isInvalidToken(rpcRequest)); - Assert.assertFalse(isRequestValid(rpcRequest)); + assertTrue(isInvalidToken(rpcRequest)); + assertFalse(isRequestValid(rpcRequest)); } @Test @@ -226,8 +228,8 @@ public class CsrfTokenMissingTest { RpcRequest rpcRequest = createRequest(); - Assert.assertTrue(isInvalidToken(rpcRequest)); - Assert.assertTrue(isRequestValid(rpcRequest)); + assertTrue(isInvalidToken(rpcRequest)); + assertTrue(isRequestValid(rpcRequest)); } @Test @@ -236,8 +238,8 @@ public class CsrfTokenMissingTest { RpcRequest rpcRequest = createRequest(); - Assert.assertTrue(isValidToken(rpcRequest)); - Assert.assertTrue(isRequestValid(rpcRequest)); + assertTrue(isValidToken(rpcRequest)); + assertTrue(isRequestValid(rpcRequest)); } @Test @@ -246,8 +248,8 @@ public class CsrfTokenMissingTest { RpcRequest rpcRequest = createRequest(); - Assert.assertTrue(isValidToken(rpcRequest)); - Assert.assertTrue(isRequestValid(rpcRequest)); + assertTrue(isValidToken(rpcRequest)); + assertTrue(isRequestValid(rpcRequest)); } } diff --git a/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java b/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java index 7f6e17d8f8..438bf31925 100644 --- a/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java +++ b/server/src/test/java/com/vaadin/tests/server/StreamResourceTest.java @@ -15,8 +15,10 @@ */ package com.vaadin.tests.server; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.StreamResource; @@ -33,7 +35,7 @@ public class StreamResourceTest { StreamResource resource1 = new StreamResource(null, null); StreamResource resource2 = new StreamResource(null, null); - Assert.assertEquals(resource1, resource2); + assertEquals(resource1, resource2); } @Test @@ -42,7 +44,7 @@ public class StreamResourceTest { StreamResource resource2 = new StreamResource( EasyMock.createMock(StreamSource.class), ""); - Assert.assertNotEquals(resource1, resource2); + assertNotEquals(resource1, resource2); } @Test diff --git a/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index 2203635430..8a31b8cf98 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java +++ b/server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -1,5 +1,8 @@ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; @@ -7,7 +10,6 @@ import java.util.HashSet; import java.util.Set; import org.easymock.EasyMock; -import org.junit.Assert; import com.vaadin.shared.Registration; import com.vaadin.tests.VaadinClasses; @@ -54,13 +56,11 @@ public abstract class AbstractListenerMethodsTestBase { .getName() + ";"); System.out.println("import " + c.getName() + ";"); - System.out - .println( - "public class " + c.getSimpleName() - + "Listeners extends " - + AbstractListenerMethodsTestBase.class - .getSimpleName() - + " {"); + System.out.println("public class " + c.getSimpleName() + + "Listeners extends " + + AbstractListenerMethodsTestBase.class + .getSimpleName() + + " {"); } String listenerClassName = m.getParameterTypes()[0] @@ -163,11 +163,10 @@ public abstract class AbstractListenerMethodsTestBase { SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Collection<?> registeredListeners = getListeners(c, eventClass); - Assert.assertEquals("Number of listeners", expectedListeners.length, + assertEquals("Number of listeners", expectedListeners.length, registeredListeners.size()); - Assert.assertArrayEquals(expectedListeners, - registeredListeners.toArray()); + assertArrayEquals(expectedListeners, registeredListeners.toArray()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java b/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java index c0de675414..6403f9f956 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/ComponentSizeParseTest.java @@ -16,7 +16,8 @@ package com.vaadin.tests.server.component; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.server.Sizeable.Unit; @@ -49,13 +50,13 @@ public class ComponentSizeParseTest { LabelWithPublicState label = new LabelWithPublicState(); label.setHeight(string); - Assert.assertEquals(amout, label.getHeight(), 0); - Assert.assertEquals(unit, label.getHeightUnits()); + assertEquals(amout, label.getHeight(), 0); + assertEquals(unit, label.getHeightUnits()); label = new LabelWithPublicState(); label.setHeight(10, unit); label.beforeClientResponse(true); - Assert.assertEquals(string, label.getState().height); + assertEquals(string, label.getState().height); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java index 66f6076f7b..f90b69bf1c 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java +++ b/server/src/test/java/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.server.component; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.tests.design.DeclarativeTestBase; @@ -34,7 +35,7 @@ public abstract class DeclarativeMarginTestBase<L extends Layout & MarginHandler } design += " />"; L layout = read(design); - Assert.assertTrue(layout.isSpacing()); + assertTrue(layout.isSpacing()); testWrite(design, layout); // Spacing off @@ -44,7 +45,7 @@ public abstract class DeclarativeMarginTestBase<L extends Layout & MarginHandler } design += " />"; layout = read(design); - Assert.assertFalse(layout.isSpacing()); + assertFalse(layout.isSpacing()); testWrite(design, layout); } @@ -65,7 +66,7 @@ public abstract class DeclarativeMarginTestBase<L extends Layout & MarginHandler // introspection and MarginInfo is not a proper bean. It ends up // considering *all* MarginInfo objects equal... (#18229) L layout = read(design); - Assert.assertEquals("For tag: " + design, marginToTest, + assertEquals("For tag: " + design, marginToTest, layout.getMargin()); testWrite(design, layout); diff --git a/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java b/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java index 71d423808e..718f9d0222 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/FinalMethodTest.java @@ -1,10 +1,11 @@ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashSet; -import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.VaadinClasses; @@ -29,7 +30,7 @@ public class FinalMethodTest { ensureNoFinalMethods(c, tested); count++; } - Assert.assertTrue(count > 0); + assertTrue(count > 0); } private void ensureNoFinalMethods(Class<?> clazz, diff --git a/server/src/test/java/com/vaadin/tests/server/component/ItemCaptionGeneratorTest.java b/server/src/test/java/com/vaadin/tests/server/component/ItemCaptionGeneratorTest.java index 1f80e46476..a9f9b48471 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/ItemCaptionGeneratorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/ItemCaptionGeneratorTest.java @@ -1,9 +1,10 @@ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.Collection; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.provider.DataGenerator; @@ -71,9 +72,8 @@ public class ItemCaptionGeneratorTest { listing.getDataCommunicator().addDataGenerator(dataGenerator); listing.getDataCommunicator().beforeClientResponse(true); - Assert.assertEquals( - listing.getClass().getName() - + " does not convert null caption from generator to empty string", + assertEquals(listing.getClass().getName() + + " does not convert null caption from generator to empty string", "", dataGenerator.generated.hasKey((String) listing.getData()) ? dataGenerator.generated.getString( diff --git a/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java b/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java index 99c686743c..459a876467 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java @@ -1,5 +1,7 @@ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -9,7 +11,6 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -96,7 +97,7 @@ public class StateGetDoesNotMarkDirtyTest { } } } - Assert.assertTrue(count > 0); + assertTrue(count > 0); } private void prepareMockUI(Component newInstance) { diff --git a/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java b/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java index 4c65744224..c3fe9e4a4b 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/WriteEmptyDesignTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.server.component; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -22,7 +24,6 @@ import java.io.OutputStream; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Component; @@ -54,7 +55,7 @@ public class WriteEmptyDesignTest { private void checkHtml(String html) { Document doc = Jsoup.parse(html); Element body = doc.body(); - Assert.assertEquals("There should be no elements in the html body.", "", + assertEquals("There should be no elements in the html body.", "", body.html()); } -}
\ No newline at end of file +} diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java index a3b9e244cf..05e31fc0c1 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java @@ -170,7 +170,7 @@ public abstract class AbstractListingDeclarativeTest<T extends AbstractListing> private void testReadData(String design, T expected, T read, DesignContext context) { - Assert.assertEquals( + assertEquals( read.getDataCommunicator().getDataProvider() .size(new Query<>()), expected.getDataCommunicator().getDataProvider() diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java index 1b11ab11dc..35f7647049 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java @@ -68,7 +68,7 @@ public abstract class AbstractMultiSelectDeclarativeTest<T extends AbstractMulti DesignContext context = readComponentAndCompare(design, component, ctxt -> configureContext(type, attribute, component, ctxt)); - Assert.assertEquals(type, + assertEquals(type, context.getCustomAttributes(context.getRootComponent()) .get(attribute)); context = new DesignContext(); @@ -97,7 +97,7 @@ public abstract class AbstractMultiSelectDeclarativeTest<T extends AbstractMulti DesignContext context = readComponentAndCompare(design, component, ctxt -> configureContext(type, attribute, component, ctxt)); - Assert.assertEquals(type, + assertEquals(type, context.getCustomAttributes(context.getRootComponent()) .get(attribute)); context = new DesignContext(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplaceTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplaceTest.java index 79164dabd7..39d3a00d50 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplaceTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractorderedlayout/LayoutSettingsOnReplaceTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.server.component.abstractorderedlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.ui.AbstractComponent; @@ -52,7 +53,7 @@ public class LayoutSettingsOnReplaceTest { }; layout.replaceComponent(first, replace); - Assert.assertEquals( + assertEquals( "Expand ratio for replaced component is not " + "the same as for previous one", ratio, layout.getExpandRatio(replace), 0.0001); @@ -79,7 +80,7 @@ public class LayoutSettingsOnReplaceTest { }; layout.replaceComponent(first, replace); - Assert.assertEquals( + assertEquals( "Alignment for replaced component is not " + "the same as for previous one", alignment, layout.getComponentAlignment(replace)); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java index f963152960..6295b9a0e7 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractsinglecomponentcontainer/RemoveFromParentLockingTest.java @@ -15,8 +15,9 @@ */ package com.vaadin.tests.server.component.abstractsinglecomponentcontainer; +import static org.junit.Assert.assertEquals; + import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -66,7 +67,7 @@ public class RemoveFromParentLockingTest { throw new AssertionError( "Moving component when not holding its sessions's lock should throw"); } catch (IllegalStateException e) { - Assert.assertEquals( + assertEquals( "Cannot remove from parent when the session is not locked.", e.getMessage()); } @@ -99,7 +100,7 @@ public class RemoveFromParentLockingTest { throw new AssertionError( "Moving component when not holding its sessions's lock should throw"); } catch (IllegalStateException e) { - Assert.assertEquals( + assertEquals( "Cannot remove from parent when the session is not locked." + " Furthermore, there is another locked session, indicating that the component might be about to be moved from one session to another.", e.getMessage()); diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java index 6e46658b86..9dcbb31246 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java @@ -64,7 +64,7 @@ public abstract class AbstractSingleSelectDeclarativeTest<T extends AbstractSing component.setSelectedItem("bar"); DesignContext context = readComponentAndCompare(design, component); - Assert.assertEquals(type, + assertEquals(type, context.getCustomAttributes(context.getRootComponent()) .get(attribute)); context = new DesignContext(); @@ -93,7 +93,7 @@ public abstract class AbstractSingleSelectDeclarativeTest<T extends AbstractSing component.setValue("bar"); DesignContext context = readComponentAndCompare(design, component); - Assert.assertEquals(type, + assertEquals(type, context.getCustomAttributes(context.getRootComponent()) .get(attribute)); context = new DesignContext(); diff --git a/server/src/test/java/com/vaadin/tests/server/component/audio/AudioStateTest.java b/server/src/test/java/com/vaadin/tests/server/component/audio/AudioStateTest.java index d96b6b3bc9..89dc4f547c 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/audio/AudioStateTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/audio/AudioStateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.server.component.audio; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.shared.ui.audio.AudioState; @@ -30,7 +31,7 @@ public class AudioStateTest { public void getState_audioHasCustomState() { TestAudio audio = new TestAudio(); AudioState state = audio.getState(); - Assert.assertEquals("Unexpected state class", AudioState.class, + assertEquals("Unexpected state class", AudioState.class, state.getClass()); } @@ -38,14 +39,14 @@ public class AudioStateTest { public void getPrimaryStyleName_audioHasCustomPrimaryStyleName() { Audio audio = new Audio(); AudioState state = new AudioState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, audio.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + audio.getPrimaryStyleName()); } @Test public void audioStateHasCustomPrimaryStyleName() { AudioState state = new AudioState(); - Assert.assertEquals("Unexpected primary style name", "v-audio", + assertEquals("Unexpected primary style name", "v-audio", state.primaryStyleName); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java index 00bba9cd1d..2adbfe2df8 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonClickTest.java @@ -1,8 +1,11 @@ package com.vaadin.tests.server.component.button; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.VaadinRequest; @@ -25,13 +28,13 @@ public class ButtonClickTest { }); b.click(); - Assert.assertEquals(1, counter.get()); + assertEquals(1, counter.get()); } @Test public void testClick() { getButton().click(); - Assert.assertTrue("Button doesn't fire clicks", clicked); + assertTrue("Button doesn't fire clicks", clicked); } @Test @@ -39,7 +42,7 @@ public class ButtonClickTest { Button b = getButton(); b.setEnabled(false); b.click(); - Assert.assertFalse("Disabled button fires click events", clicked); + assertFalse("Disabled button fires click events", clicked); } private Button getButton() { diff --git a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java index 70f93e7cff..408a7ca3b1 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java @@ -81,23 +81,23 @@ public class ButtonDeclarativeTest extends DeclarativeTestBase<Button> { String expectedCaptionPlainText = "> One"; Button read = read(designPlainText); - Assert.assertEquals(expectedCaptionPlainText, read.getCaption()); + assertEquals(expectedCaptionPlainText, read.getCaption()); designPlainText = designPlainText.replace("vaadin-button", "vaadin-native-button"); Button nativeButton = read(designPlainText); - Assert.assertEquals(expectedCaptionPlainText, + assertEquals(expectedCaptionPlainText, nativeButton.getCaption()); String designHtml = "<vaadin-button>> One</vaadin-button>"; String expectedCaptionHtml = "> One"; read = read(designHtml); - Assert.assertEquals(expectedCaptionHtml, read.getCaption()); + assertEquals(expectedCaptionHtml, read.getCaption()); designHtml = designHtml.replace("vaadin-button", "vaadin-native-button"); nativeButton = read(designHtml); - Assert.assertEquals(expectedCaptionHtml, nativeButton.getCaption()); + assertEquals(expectedCaptionHtml, nativeButton.getCaption()); read = new Button("& Test"); read.setCaptionAsHtml(true); diff --git a/server/src/test/java/com/vaadin/tests/server/component/combobox/ComboBoxFilteringTest.java b/server/src/test/java/com/vaadin/tests/server/component/combobox/ComboBoxFilteringTest.java index 35c28eba17..9db40d2ed6 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/combobox/ComboBoxFilteringTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/combobox/ComboBoxFilteringTest.java @@ -15,13 +15,15 @@ */ package com.vaadin.tests.server.component.combobox; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -42,8 +44,8 @@ import com.vaadin.ui.ComboBox; * @author Vaadin Ltd */ public class ComboBoxFilteringTest { - private static final String[] PERSON_NAMES = { - "Enrique Iglesias", "Henry Dunant", "Erwin Engelbrecht" }; + private static final String[] PERSON_NAMES = { "Enrique Iglesias", + "Henry Dunant", "Erwin Engelbrecht" }; private ComboBox<Person> comboBox; @@ -196,28 +198,26 @@ public class ComboBoxFilteringTest { comboBox.setDataProvider(provider); - Assert.assertSame(provider, comboBox.getDataProvider()); + assertSame(provider, comboBox.getDataProvider()); } @Test public void setItems_hasListDataProvider() { comboBox.setItems(); - Assert.assertEquals(ListDataProvider.class, + assertEquals(ListDataProvider.class, comboBox.getDataProvider().getClass()); } private void checkFiltering(String filterText, String nonMatchingFilterText, int totalMatches, int matchingResults) { - Assert.assertEquals( - "ComboBox filtered out results with no filter applied", + assertEquals("ComboBox filtered out results with no filter applied", totalMatches, comboBoxSizeWithFilter(null)); - Assert.assertEquals( - "ComboBox filtered out results with empty filter string", + assertEquals("ComboBox filtered out results with empty filter string", totalMatches, comboBoxSizeWithFilter("")); - Assert.assertEquals("ComboBox filtered out wrong number of results", + assertEquals("ComboBox filtered out wrong number of results", matchingResults, comboBoxSizeWithFilter(filterText)); - Assert.assertEquals( + assertEquals( "ComboBox should have no results with a non-matching filter", 0, comboBoxSizeWithFilter(nonMatchingFilterText)); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java index 9d60628e12..8ebc620328 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/customlayout/CustomLayoutTest.java @@ -15,6 +15,10 @@ */ package com.vaadin.tests.server.component.customlayout; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.ByteArrayInputStream; import java.io.FilterInputStream; import java.io.IOException; @@ -26,7 +30,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.CustomLayout; @@ -52,9 +55,9 @@ public class CustomLayoutTest { InputStreamImpl stream = new InputStreamImpl(inputStream, buffer / 2); new CustomLayout(stream); - Assert.assertTrue("Stream is not closed in CustomLayout CTOR ", + assertTrue("Stream is not closed in CustomLayout CTOR ", stream.isClosed()); - Assert.assertEquals("Number of read bytes is incorrect", bytes.length, + assertEquals("Number of read bytes is incorrect", bytes.length, stream.getCount()); } @@ -78,7 +81,7 @@ public class CustomLayoutTest { } } } - Assert.assertNotNull( + assertNotNull( "Unable to find default buffer size in CustomLayout class", field); field.setAccessible(true); diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java index 61fd282edf..d85f9028c8 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.server.component.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.Optional; import java.util.stream.Stream; -import com.vaadin.ui.Grid; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -29,6 +31,7 @@ import com.vaadin.data.PropertyDefinition; import com.vaadin.data.PropertySet; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.grid.editor.EditorServerRpc; +import com.vaadin.ui.Grid; import com.vaadin.ui.components.grid.EditorCancelEvent; import com.vaadin.ui.components.grid.EditorCancelListener; import com.vaadin.ui.components.grid.EditorImpl; @@ -87,13 +90,13 @@ public class EditorImplTest { @Override public void onEditorCancel(EditorCancelEvent<Object> event) { - Assert.assertNull(cancelEvent); + assertNull(cancelEvent); cancelEvent = event; } @Override public void onEditorSave(EditorSaveEvent<Object> event) { - Assert.assertNull(saveEvent); + assertNull(saveEvent); saveEvent = event; } @@ -128,23 +131,23 @@ public class EditorImplTest { editor.save(); - Assert.assertNotNull(editor.saveEvent); - Assert.assertNull(editor.cancelEvent); + assertNotNull(editor.saveEvent); + assertNull(editor.cancelEvent); - Assert.assertEquals(editor, editor.saveEvent.getSource()); - Assert.assertEquals(beanToEdit, editor.saveEvent.getBean()); + assertEquals(editor, editor.saveEvent.getSource()); + assertEquals(beanToEdit, editor.saveEvent.getBean()); } @Test public void cancel_eventIsFired() { editor.cancel(); - Assert.assertNull(editor.saveEvent); - Assert.assertNotNull(editor.cancelEvent); + assertNull(editor.saveEvent); + assertNotNull(editor.cancelEvent); - Assert.assertEquals(editor, editor.cancelEvent.getSource()); + assertEquals(editor, editor.cancelEvent.getSource()); - Assert.assertEquals(beanToEdit, editor.cancelEvent.getBean()); + assertEquals(beanToEdit, editor.cancelEvent.getBean()); } @Test @@ -153,31 +156,31 @@ public class EditorImplTest { editor.rpc.save(); - Assert.assertNotNull(editor.saveEvent); - Assert.assertNull(editor.cancelEvent); + assertNotNull(editor.saveEvent); + assertNull(editor.cancelEvent); - Assert.assertEquals(editor, editor.saveEvent.getSource()); + assertEquals(editor, editor.saveEvent.getSource()); - Assert.assertEquals(beanToEdit, editor.saveEvent.getBean()); + assertEquals(beanToEdit, editor.saveEvent.getBean()); } @Test public void cancelFromClient_eventIsFired() { editor.rpc.cancel(false); - Assert.assertNull(editor.saveEvent); - Assert.assertNotNull(editor.cancelEvent); + assertNull(editor.saveEvent); + assertNotNull(editor.cancelEvent); - Assert.assertEquals(editor, editor.cancelEvent.getSource()); + assertEquals(editor, editor.cancelEvent.getSource()); - Assert.assertEquals(beanToEdit, editor.cancelEvent.getBean()); + assertEquals(beanToEdit, editor.cancelEvent.getBean()); } @Test public void cancelAfterSaveFromClient_eventIsNotFired() { editor.rpc.cancel(true); - Assert.assertNull(editor.saveEvent); - Assert.assertNull(editor.cancelEvent); + assertNull(editor.saveEvent); + assertNull(editor.cancelEvent); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java index 97cfe6ebc7..6a8e329f20 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridChildrenTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.tests.server.component.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + import java.util.Iterator; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -48,8 +51,8 @@ public class GridChildrenTest { Label label = new Label(); merged.setComponent(label); Iterator<Component> i = grid.iterator(); - Assert.assertEquals(label, i.next()); - Assert.assertFalse(i.hasNext()); + assertEquals(label, i.next()); + assertFalse(i.hasNext()); } @Test @@ -58,9 +61,9 @@ public class GridChildrenTest { "baz"); Label label = new Label(); merged.setComponent(label); - Assert.assertEquals(grid, label.getParent()); + assertEquals(grid, label.getParent()); merged.setText("foo"); - Assert.assertNull(label.getParent()); + assertNull(label.getParent()); } @Test @@ -69,9 +72,9 @@ public class GridChildrenTest { "baz"); Label label = new Label(); merged.setComponent(label); - Assert.assertEquals(grid, label.getParent()); + assertEquals(grid, label.getParent()); grid.removeHeaderRow(0); - Assert.assertNull(label.getParent()); + assertNull(label.getParent()); } @Test @@ -79,9 +82,9 @@ public class GridChildrenTest { FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz"); Label label = new Label(); merged.setComponent(label); - Assert.assertEquals(grid, label.getParent()); + assertEquals(grid, label.getParent()); merged.setText("foo"); - Assert.assertNull(label.getParent()); + assertNull(label.getParent()); } @Test @@ -89,9 +92,9 @@ public class GridChildrenTest { FooterCell merged = grid.addFooterRowAt(0).join("foo", "bar", "baz"); Label label = new Label(); merged.setComponent(label); - Assert.assertEquals(grid, label.getParent()); + assertEquals(grid, label.getParent()); grid.removeFooterRow(0); - Assert.assertNull(label.getParent()); + assertNull(label.getParent()); } @Test @@ -100,8 +103,8 @@ public class GridChildrenTest { Label label = new Label(); merged.setComponent(label); Iterator<Component> i = grid.iterator(); - Assert.assertEquals(label, i.next()); - Assert.assertFalse(i.hasNext()); - Assert.assertEquals(grid, label.getParent()); + assertEquals(label, i.next()); + assertFalse(i.hasNext()); + assertEquals(grid, label.getParent()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridCustomPropertySetTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridCustomPropertySetTest.java index c1726d77ba..ba773ca68d 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridCustomPropertySetTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridCustomPropertySetTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.server.component.grid; +import static org.junit.Assert.assertEquals; + import java.util.Optional; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.PropertyDefinition; @@ -166,20 +167,20 @@ public class GridCustomPropertySetTest { @Test public void customPropertySet() { GridWithCustomPropertySet customGrid = new GridWithCustomPropertySet(); - Assert.assertEquals(0, customGrid.getColumns().size()); + assertEquals(0, customGrid.getColumns().size()); Column<MyBeanWithoutGetters, Integer> numberColumn = (Column<MyBeanWithoutGetters, Integer>) customGrid .addColumn("numbah"); - Assert.assertEquals(1, customGrid.getColumns().size()); - Assert.assertEquals("The Number", numberColumn.getCaption()); - Assert.assertEquals(24, (int) numberColumn.getValueProvider() + assertEquals(1, customGrid.getColumns().size()); + assertEquals("The Number", numberColumn.getCaption()); + assertEquals(24, (int) numberColumn.getValueProvider() .apply(new MyBeanWithoutGetters("foo", 24))); Column<MyBeanWithoutGetters, String> stringColumn = (Column<MyBeanWithoutGetters, String>) customGrid .addColumn("string"); - Assert.assertEquals(2, customGrid.getColumns().size()); - Assert.assertEquals("The String", stringColumn.getCaption()); - Assert.assertEquals("foo", stringColumn.getValueProvider() + assertEquals(2, customGrid.getColumns().size()); + assertEquals("The String", stringColumn.getCaption()); + assertEquals("foo", stringColumn.getValueProvider() .apply(new MyBeanWithoutGetters("foo", 24))); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java index 52af306ec5..8d1d6c6955 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.server.component.grid; +import static org.junit.Assert.assertNull; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; @@ -26,7 +28,6 @@ import org.jsoup.nodes.Element; import org.jsoup.parser.Tag; import org.jsoup.select.Elements; import org.jsoup.select.Selector; -import org.junit.Assert; import org.junit.Test; import com.vaadin.data.SelectionModel.Multi; @@ -109,19 +110,17 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { String headerRowText3 = "foobar"; join.setText(headerRowText3); - String design = String.format( - "<%s><table><colgroup>" + "<col column-id='column0' sortable>" - + "<col column-id='id' sortable>" - + "<col column-id='mail' sortable>" - + "</colgroup><thead>" - + "<tr default><th plain-text column-ids='column0'>First Name</th>" - + "<th plain-text column-ids='id'>Id</th>" - + "<th plain-text column-ids='mail'>Mail</th></tr>" - + "<tr><th plain-text column-ids='column0'>%s</th>" - + "<th colspan='2' plain-text column-ids='id,mail'>foobar</th></tr>" - + "</thead></table></%s>", - getComponentTag(), headerRowText1, headerRowText3, - getComponentTag()); + String design = String.format("<%s><table><colgroup>" + + "<col column-id='column0' sortable>" + + "<col column-id='id' sortable>" + + "<col column-id='mail' sortable>" + "</colgroup><thead>" + + "<tr default><th plain-text column-ids='column0'>First Name</th>" + + "<th plain-text column-ids='id'>Id</th>" + + "<th plain-text column-ids='mail'>Mail</th></tr>" + + "<tr><th plain-text column-ids='column0'>%s</th>" + + "<th colspan='2' plain-text column-ids='id,mail'>foobar</th></tr>" + + "</thead></table></%s>", getComponentTag(), headerRowText1, + headerRowText3, getComponentTag()); testRead(design, grid); testWrite(design, grid); @@ -150,19 +149,17 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { String footerRowText2 = "foobar"; footer.join(cell2, cell3).setHtml(footerRowText2); - String design = String.format( - "<%s><table><colgroup>" + "<col column-id='column0' sortable>" - + "<col column-id='id' sortable>" - + "<col column-id='mail' sortable>" - + "</colgroup><thead>" - + "<tr default><th plain-text column-ids='column0'>First Name</th>" - + "<th plain-text column-ids='id'>Id</th>" - + "<th plain-text column-ids='mail'>Mail</th></tr></thead>" - + "<tfoot><tr><td plain-text column-ids='column0'>%s</td>" - + "<td colspan='2' column-ids='id,mail'>%s</td></tr></tfoot>" - + "</table></%s>", - getComponentTag(), footerRowText1, footerRowText2, - getComponentTag()); + String design = String.format("<%s><table><colgroup>" + + "<col column-id='column0' sortable>" + + "<col column-id='id' sortable>" + + "<col column-id='mail' sortable>" + "</colgroup><thead>" + + "<tr default><th plain-text column-ids='column0'>First Name</th>" + + "<th plain-text column-ids='id'>Id</th>" + + "<th plain-text column-ids='mail'>Mail</th></tr></thead>" + + "<tfoot><tr><td plain-text column-ids='column0'>%s</td>" + + "<td colspan='2' column-ids='id,mail'>%s</td></tr></tfoot>" + + "</table></%s>", getComponentTag(), footerRowText1, + footerRowText2, getComponentTag()); testRead(design, grid); testWrite(design, grid); @@ -203,17 +200,15 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { int expandRatio = 83; column2.setExpandRatio(expandRatio); - String design = String.format( - "<%s><table><colgroup>" - + "<col column-id='column0' sortable='%s' editable resizable='%s' hidable hidden>" - + "<col column-id='id' sortable hiding-toggle-caption='%s' width='%s' min-width='%s' max-width='%s' expand='%s'>" - + "</colgroup><thead>" - + "<tr default><th plain-text column-ids='column0'>%s</th>" - + "<th plain-text column-ids='id'>%s</th>" - + "</tr></thead>" + "</table></%s>", - getComponentTag(), sortable, resizable, hidingToggleCaption, - width, minWidth, maxWidth, expandRatio, caption, "Id", - getComponentTag()); + String design = String.format("<%s><table><colgroup>" + + "<col column-id='column0' sortable='%s' editable resizable='%s' hidable hidden>" + + "<col column-id='id' sortable hiding-toggle-caption='%s' width='%s' min-width='%s' max-width='%s' expand='%s'>" + + "</colgroup><thead>" + + "<tr default><th plain-text column-ids='column0'>%s</th>" + + "<th plain-text column-ids='id'>%s</th>" + "</tr></thead>" + + "</table></%s>", getComponentTag(), sortable, resizable, + hidingToggleCaption, width, minWidth, maxWidth, expandRatio, + caption, "Id", getComponentTag()); testRead(design, grid, true); testWrite(design, grid); @@ -232,15 +227,14 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { footerRow.getCell(column1).setText("x"); footerRow.getCell(column2).setHtml("y"); - String design = String.format( - "<%s><table><colgroup>" + "<col column-id='column0' sortable>" - + "<col column-id='id' sortable></colgroup><thead>" - + "<tr default><th plain-text column-ids='column0'>First Name</th>" - + "<th plain-text column-ids='id'>Id</th></tr>" - + "</thead><tbody></tbody>" - + "<tfoot><tr><td plain-text column-ids='column0'>x</td>" - + "<td column-ids='id'>y</td></tr></tfoot>" - + "</table></%s>", + String design = String.format("<%s><table><colgroup>" + + "<col column-id='column0' sortable>" + + "<col column-id='id' sortable></colgroup><thead>" + + "<tr default><th plain-text column-ids='column0'>First Name</th>" + + "<th plain-text column-ids='id'>Id</th></tr>" + + "</thead><tbody></tbody>" + + "<tfoot><tr><td plain-text column-ids='column0'>x</td>" + + "<td column-ids='id'>y</td></tr></tfoot>" + "</table></%s>", getComponentTag(), getComponentTag()); testRead(design, grid); @@ -259,22 +253,22 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { grid.addColumn(Person::getFirstName).setCaption("First Name"); grid.addColumn(Person::getLastName).setId("id").setCaption("Id"); - String design = String.format( - "<%s><table><colgroup>" + "<col column-id='column0' sortable>" - + "<col column-id='id' sortable></colgroup><thead>" - + "<tr default><th plain-text column-ids='column0'>First Name</th>" - + "<th plain-text column-ids='id'>Id</th></tr>" - + "</thead><tbody>" - + "<tr item='%s'><td>%s</td><td>%s</td></tr>" - + "<tr item='%s'><td>%s</td><td>%s</td></tr>" - + "</tbody></table></%s>", - getComponentTag(), person1.toString(), person1.getFirstName(), + String design = String.format("<%s><table><colgroup>" + + "<col column-id='column0' sortable>" + + "<col column-id='id' sortable></colgroup><thead>" + + "<tr default><th plain-text column-ids='column0'>First Name</th>" + + "<th plain-text column-ids='id'>Id</th></tr>" + + "</thead><tbody>" + + "<tr item='%s'><td>%s</td><td>%s</td></tr>" + + "<tr item='%s'><td>%s</td><td>%s</td></tr>" + + "</tbody></table></%s>", getComponentTag(), + person1.toString(), person1.getFirstName(), person1.getLastName(), person2.toString(), person2.getFirstName(), person2.getLastName(), getComponentTag()); Grid<?> readGrid = testRead(design, grid, true, true); - Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>())); + assertEquals(2, readGrid.getDataProvider().size(new Query<>())); testWrite(design, grid, true); } @@ -324,7 +318,7 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { person3.getLastName(), getComponentTag()); Grid<?> readGrid = testRead(design, grid, true, true); - Assert.assertEquals(3, readGrid.getDataProvider().size(new Query<>())); + assertEquals(3, readGrid.getDataProvider().size(new Query<>())); testWrite(design, grid, true); } @@ -344,22 +338,22 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { .setSelectionMode(SelectionMode.SINGLE); model.select(person2); - String design = String.format( - "<%s><table><colgroup>" + "<col column-id='column0' sortable>" - + "<col column-id='id' sortable></colgroup><thead>" - + "<tr default><th plain-text column-ids='column0'>First Name</th>" - + "<th plain-text column-ids='id'>Id</th></tr>" - + "</thead><tbody>" - + "<tr item='%s'><td>%s</td><td>%s</td></tr>" - + "<tr item='%s' selected><td>%s</td><td>%s</td></tr>" - + "</tbody></table></%s>", - getComponentTag(), person1.toString(), person1.getFirstName(), + String design = String.format("<%s><table><colgroup>" + + "<col column-id='column0' sortable>" + + "<col column-id='id' sortable></colgroup><thead>" + + "<tr default><th plain-text column-ids='column0'>First Name</th>" + + "<th plain-text column-ids='id'>Id</th></tr>" + + "</thead><tbody>" + + "<tr item='%s'><td>%s</td><td>%s</td></tr>" + + "<tr item='%s' selected><td>%s</td><td>%s</td></tr>" + + "</tbody></table></%s>", getComponentTag(), + person1.toString(), person1.getFirstName(), person1.getLastName(), person2.toString(), person2.getFirstName(), person2.getLastName(), getComponentTag()); Grid<?> readGrid = testRead(design, grid, true, true); - Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>())); + assertEquals(2, readGrid.getDataProvider().size(new Query<>())); testWrite(design, grid, true); } @@ -395,7 +389,7 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { person2.getLastName(), getComponentTag()); Grid<?> readGrid = testRead(design, grid, true, true); - Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>())); + assertEquals(2, readGrid.getDataProvider().size(new Query<>())); testWrite(design, grid, true); grid.setSelectionMode(SelectionMode.SINGLE); @@ -408,7 +402,7 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { getComponentTag()); readGrid = testRead(design, grid, true, true); - Assert.assertEquals(2, readGrid.getDataProvider().size(new Query<>())); + assertEquals(2, readGrid.getDataProvider().size(new Query<>())); testWrite(design, grid, true); } @@ -540,8 +534,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { String actualFooter = grid.getFooterRow(0).getCell(id).getText(); String expected = "> Test"; - Assert.assertEquals(expected, actualHeader); - Assert.assertEquals(expected, actualFooter); + assertEquals(expected, actualHeader); + assertEquals(expected, actualFooter); design = design.replace(plainText, ""); grid = read(design); @@ -549,8 +543,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { actualFooter = grid.getFooterRow(0).getCell(id).getHtml(); expected = "> Test"; - Assert.assertEquals(expected, actualHeader); - Assert.assertEquals(expected, actualFooter); + assertEquals(expected, actualHeader); + assertEquals(expected, actualFooter); grid = new Grid<>(); Column<Person, String> column = grid.addColumn(Person::getFirstName) @@ -566,9 +560,9 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { Element root = new Element(Tag.valueOf(getComponentTag()), ""); grid.writeDesign(root, new DesignContext()); - Assert.assertEquals("&amp; Test", + assertEquals("&amp; Test", root.getElementsByTag("th").get(0).html()); - Assert.assertEquals("&amp; Test", + assertEquals("&amp; Test", root.getElementsByTag("td").get(0).html()); header = grid.addHeaderRowAt(0); @@ -581,10 +575,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { root = new Element(Tag.valueOf(getComponentTag()), ""); grid.writeDesign(root, new DesignContext()); - Assert.assertEquals("& Test", - root.getElementsByTag("th").get(0).html()); - Assert.assertEquals("& Test", - root.getElementsByTag("td").get(0).html()); + assertEquals("& Test", root.getElementsByTag("th").get(0).html()); + assertEquals("& Test", root.getElementsByTag("td").get(0).html()); } @@ -617,14 +609,14 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { } private void compareHeaders(Grid<?> expected, Grid<?> actual) { - Assert.assertEquals("Different header row count", - expected.getHeaderRowCount(), actual.getHeaderRowCount()); + assertEquals("Different header row count", expected.getHeaderRowCount(), + actual.getHeaderRowCount()); for (int i = 0; i < expected.getHeaderRowCount(); ++i) { HeaderRow expectedRow = expected.getHeaderRow(i); HeaderRow actualRow = actual.getHeaderRow(i); if (expectedRow.equals(expected.getDefaultHeaderRow())) { - Assert.assertEquals("Different index for default header row", + assertEquals("Different index for default header row", actual.getDefaultHeaderRow(), actualRow); } @@ -636,11 +628,11 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { switch (expectedCell.getCellType()) { case TEXT: - Assert.assertEquals(baseError + "Text content", + assertEquals(baseError + "Text content", expectedCell.getText(), actualCell.getText()); break; case HTML: - Assert.assertEquals(baseError + "HTML content", + assertEquals(baseError + "HTML content", expectedCell.getHtml(), actualCell.getHtml()); break; case WIDGET: @@ -654,8 +646,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { } private void compareFooters(Grid<?> expected, Grid<?> actual) { - Assert.assertEquals("Different footer row count", - expected.getFooterRowCount(), actual.getFooterRowCount()); + assertEquals("Different footer row count", expected.getFooterRowCount(), + actual.getFooterRowCount()); for (int i = 0; i < expected.getFooterRowCount(); ++i) { FooterRow expectedRow = expected.getFooterRow(i); FooterRow actualRow = actual.getFooterRow(i); @@ -668,11 +660,11 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { switch (expectedCell.getCellType()) { case TEXT: - Assert.assertEquals(baseError + "Text content", + assertEquals(baseError + "Text content", expectedCell.getText(), actualCell.getText()); break; case HTML: - Assert.assertEquals(baseError + "HTML content", + assertEquals(baseError + "HTML content", expectedCell.getHtml(), actualCell.getHtml()); break; case WIDGET: @@ -688,7 +680,7 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { private void compareGridColumns(Grid<?> expected, Grid<?> actual) { List<?> columns = expected.getColumns(); List<?> actualColumns = actual.getColumns(); - Assert.assertEquals("Different amount of columns", columns.size(), + assertEquals("Different amount of columns", columns.size(), actualColumns.size()); for (int i = 0; i < columns.size(); ++i) { Column<?, ?> col1 = (Column<?, ?>) columns.get(i); @@ -762,7 +754,7 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { @SuppressWarnings("unchecked") Grid<Person> grid = read(design); - Assert.assertEquals(beanClass, grid.getBeanType()); + assertEquals(beanClass, grid.getBeanType()); testWrite(design, grid); } @@ -786,31 +778,29 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { Document html = Jsoup.parse(design); Elements cols = Selector.select("vaadin-grid", html) .select("colgroup > col"); - Assert.assertEquals("Number of columns in the design file", i, - cols.size()); + assertEquals("Number of columns in the design file", i, cols.size()); } private void assertColumns(int expectedCount, List<Column<Person, ?>> expectedColumns, List<Column<Person, ?>> columns, Person testPerson) { - Assert.assertEquals(expectedCount, expectedColumns.size()); - Assert.assertEquals(expectedCount, columns.size()); + assertEquals(expectedCount, expectedColumns.size()); + assertEquals(expectedCount, columns.size()); for (int i = 0; i < expectedColumns.size(); i++) { Column<Person, ?> expectedColumn = expectedColumns.get(i); Column<Person, ?> column = columns.get(i); // Property mapping - Assert.assertEquals(expectedColumn.getId(), column.getId()); + assertEquals(expectedColumn.getId(), column.getId()); // Header caption - Assert.assertEquals(expectedColumn.getCaption(), - column.getCaption()); + assertEquals(expectedColumn.getCaption(), column.getCaption()); // Value providers are not stored in the declarative file // so this only works for bean properties if (column.getId() != null && !column.getId().equals("column" + i)) { - Assert.assertEquals( + assertEquals( expectedColumn.getValueProvider().apply(testPerson), column.getValueProvider().apply(testPerson)); } @@ -834,8 +824,8 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { assertColumns(0, grid.getColumns(), readGrid.getColumns(), testPerson); // Can add a mapped property - Assert.assertEquals("The email", readGrid.addColumn("email") - .getValueProvider().apply(testPerson)); + assertEquals("The email", readGrid.addColumn("email").getValueProvider() + .apply(testPerson)); } @Test @@ -856,11 +846,11 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { assertColumns(1, grid.getColumns(), readGrid.getColumns(), testPerson); // First name should not be mapped to the property - Assert.assertNull(readGrid.getColumns().get(0).getValueProvider() + assertNull(readGrid.getColumns().get(0).getValueProvider() .apply(testPerson)); // Can add a mapped property - Assert.assertEquals("the last", readGrid.addColumn("lastName") + assertEquals("the last", readGrid.addColumn("lastName") .getValueProvider().apply(testPerson)); } @@ -882,7 +872,7 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> { assertColumns(12, grid.getColumns(), readGrid.getColumns(), testPerson); // First and last name should not be mapped to anything but should exist - Assert.assertNull(readGrid.getColumns().get(11).getValueProvider() + assertNull(readGrid.getColumns().get(11).getValueProvider() .apply(testPerson)); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java index 454b5d3b3d..08abc4b7b4 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDetailsTest.java @@ -1,11 +1,14 @@ package com.vaadin.tests.server.component.grid; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,13 +60,10 @@ public class GridDetailsTest { for (Component c : grid) { if (c instanceof Label) { String value = ((Label) c).getValue(); - Assert.assertTrue( - "Unexpected label in component iterator with value " - + value, - data.remove(value)); + assertTrue("Unexpected label in component iterator with value " + + value, data.remove(value)); } else { - Assert.fail( - "Iterator contained a component that is not a label."); + fail("Iterator contained a component that is not a label."); } } } @@ -78,10 +78,10 @@ public class GridDetailsTest { @Test public void testGridComponentIteratorIsEmptyAfterHidingDetails() { - Assert.assertTrue("Component iterator should have components.", + assertTrue("Component iterator should have components.", grid.iterator().hasNext()); data.forEach(s -> grid.setDetailsVisible(s, false)); - Assert.assertFalse("Component iterator should not have components.", + assertFalse("Component iterator should not have components.", grid.iterator().hasNext()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java index 5f8327bb8d..cb0459dc90 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java @@ -1,8 +1,12 @@ package com.vaadin.tests.server.component.grid; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -23,15 +27,14 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.vaadin.data.provider.DataCommunicator; import org.easymock.Capture; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.vaadin.data.Binder.Binding; import com.vaadin.data.ValidationException; import com.vaadin.data.ValueProvider; +import com.vaadin.data.provider.DataCommunicator; import com.vaadin.data.provider.DataGenerator; import com.vaadin.data.provider.GridSortOrder; import com.vaadin.data.provider.QuerySortOrder; @@ -75,7 +78,8 @@ public class GridTest { public void testCreateGridWithDataCommunicator() { DataCommunicator specificDataCommunicator = new DataCommunicator<>(); - TestGrid<String> grid = new TestGrid(String.class, specificDataCommunicator); + TestGrid<String> grid = new TestGrid(String.class, + specificDataCommunicator); assertEquals(specificDataCommunicator, grid.getDataCommunicator()); } @@ -184,7 +188,7 @@ public class GridTest { assertEquals("foo", event.getFirstSelectedItem().get()); assertEquals("foo", event.getAllSelectedItems().stream().findFirst().get()); - Assert.assertArrayEquals(new String[] { "foo", "bar" }, + assertArrayEquals(new String[] { "foo", "bar" }, event.getAllSelectedItems().toArray(new String[2])); grid.getSelectionModel().deselect("foo"); @@ -195,7 +199,7 @@ public class GridTest { assertEquals("bar", event.getFirstSelectedItem().get()); assertEquals("bar", event.getAllSelectedItems().stream().findFirst().get()); - Assert.assertArrayEquals(new String[] { "bar" }, + assertArrayEquals(new String[] { "bar" }, event.getAllSelectedItems().toArray(new String[1])); grid.getSelectionModel().deselectAll(); @@ -211,8 +215,7 @@ public class GridTest { public void testAddSelectionListener_noSelectionMode() { grid.setSelectionMode(SelectionMode.NONE); - grid.addSelectionListener( - event -> Assert.fail("never ever happens (tm)")); + grid.addSelectionListener(event -> fail("never ever happens (tm)")); } @Test @@ -221,8 +224,8 @@ public class GridTest { grid.sort(column); GridSortOrder<String> sortOrder = grid.getSortOrder().get(0); - Assert.assertEquals(column, sortOrder.getSorted()); - Assert.assertEquals(SortDirection.ASCENDING, sortOrder.getDirection()); + assertEquals(column, sortOrder.getSorted()); + assertEquals(SortDirection.ASCENDING, sortOrder.getDirection()); } @Test @@ -231,8 +234,8 @@ public class GridTest { grid.sort(column, SortDirection.DESCENDING); GridSortOrder<String> sortOrder = grid.getSortOrder().get(0); - Assert.assertEquals(column, sortOrder.getSorted()); - Assert.assertEquals(SortDirection.DESCENDING, sortOrder.getDirection()); + assertEquals(column, sortOrder.getSorted()); + assertEquals(SortDirection.DESCENDING, sortOrder.getDirection()); } @Test @@ -245,13 +248,11 @@ public class GridTest { grid.setSortOrder(order); List<GridSortOrder<String>> sortOrder = grid.getSortOrder(); - Assert.assertEquals(column2, sortOrder.get(0).getSorted()); - Assert.assertEquals(SortDirection.DESCENDING, - sortOrder.get(0).getDirection()); + assertEquals(column2, sortOrder.get(0).getSorted()); + assertEquals(SortDirection.DESCENDING, sortOrder.get(0).getDirection()); - Assert.assertEquals(column1, sortOrder.get(1).getSorted()); - Assert.assertEquals(SortDirection.ASCENDING, - sortOrder.get(1).getDirection()); + assertEquals(column1, sortOrder.get(1).getSorted()); + assertEquals(SortDirection.ASCENDING, sortOrder.get(1).getDirection()); } @Test @@ -272,15 +273,14 @@ public class GridTest { List<GridSortOrder<String>> list = new ArrayList<>(); AtomicReference<Boolean> fired = new AtomicReference<>(); grid.addSortListener(event -> { - Assert.assertTrue(list.isEmpty()); + assertTrue(list.isEmpty()); fired.set(true); list.addAll(event.getSortOrder()); }); grid.sort(column1, SortDirection.DESCENDING); - Assert.assertEquals(column1, list.get(0).getSorted()); - Assert.assertEquals(SortDirection.DESCENDING, - list.get(0).getDirection()); + assertEquals(column1, list.get(0).getSorted()); + assertEquals(SortDirection.DESCENDING, list.get(0).getDirection()); List<GridSortOrder<String>> order = Arrays.asList( new GridSortOrder<>(column2, SortDirection.DESCENDING), @@ -289,19 +289,17 @@ public class GridTest { grid.setSortOrder(order); - Assert.assertEquals(column2, list.get(0).getSorted()); - Assert.assertEquals(SortDirection.DESCENDING, - list.get(0).getDirection()); + assertEquals(column2, list.get(0).getSorted()); + assertEquals(SortDirection.DESCENDING, list.get(0).getDirection()); - Assert.assertEquals(column1, list.get(1).getSorted()); - Assert.assertEquals(SortDirection.ASCENDING, - list.get(1).getDirection()); + assertEquals(column1, list.get(1).getSorted()); + assertEquals(SortDirection.ASCENDING, list.get(1).getDirection()); list.clear(); fired.set(false); grid.clearSortOrder(); - Assert.assertEquals(0, list.size()); - Assert.assertTrue(fired.get()); + assertEquals(0, list.size()); + assertTrue(fired.get()); } @Test @@ -311,19 +309,18 @@ public class GridTest { Column<Person, ?> nameColumn = grid.getColumn("name"); Column<Person, ?> bornColumn = grid.getColumn("born"); - Assert.assertNotNull(nameColumn); - Assert.assertNotNull(bornColumn); + assertNotNull(nameColumn); + assertNotNull(bornColumn); - Assert.assertEquals("Name", nameColumn.getCaption()); - Assert.assertEquals("Born", bornColumn.getCaption()); + assertEquals("Name", nameColumn.getCaption()); + assertEquals("Born", bornColumn.getCaption()); JsonObject json = getRowData(grid, new Person("Lorem", 2000)); Set<String> values = Stream.of(json.keys()).map(json::getString) .collect(Collectors.toSet()); - Assert.assertEquals(new HashSet<>(Arrays.asList("Lorem", "2000")), - values); + assertEquals(new HashSet<>(Arrays.asList("Lorem", "2000")), values); assertSingleSortProperty(nameColumn, "name"); assertSingleSortProperty(bornColumn, "born"); @@ -340,18 +337,18 @@ public class GridTest { Optional<Binding<Person, ?>> maybeBinding = grid.getEditor().getBinder() .getBinding("name"); - Assert.assertTrue(maybeBinding.isPresent()); + assertTrue(maybeBinding.isPresent()); Binding<Person, ?> binding = maybeBinding.get(); - Assert.assertSame(nameField, binding.getField()); + assertSame(nameField, binding.getField()); Person person = new Person("Lorem", 2000); grid.getEditor().getBinder().setBean(person); - Assert.assertEquals("Lorem", nameField.getValue()); + assertEquals("Lorem", nameField.getValue()); nameField.setValue("Ipsum"); - Assert.assertEquals("Ipsum", person.getName()); + assertEquals("Ipsum", person.getName()); } @Test(expected = IllegalStateException.class) @@ -377,17 +374,16 @@ public class GridTest { grid.addColumn("name"); List<Column<Person, ?>> columns = grid.getColumns(); - Assert.assertEquals(2, columns.size()); - Assert.assertEquals("born", columns.get(0).getId()); - Assert.assertEquals("name", columns.get(1).getId()); + assertEquals(2, columns.size()); + assertEquals("born", columns.get(0).getId()); + assertEquals("name", columns.get(1).getId()); } @Test public void removeColumnByColumn() { grid.removeColumn(fooColumn); - Assert.assertEquals( - Arrays.asList(lengthColumn, objectColumn, randomColumn), + assertEquals(Arrays.asList(lengthColumn, objectColumn, randomColumn), grid.getColumns()); } @@ -397,8 +393,7 @@ public class GridTest { // Questionable that this doesn't throw, but that's a separate ticket... grid.removeColumn(fooColumn); - Assert.assertEquals( - Arrays.asList(lengthColumn, objectColumn, randomColumn), + assertEquals(Arrays.asList(lengthColumn, objectColumn, randomColumn), grid.getColumns()); } @@ -412,8 +407,7 @@ public class GridTest { public void removeColumnById() { grid.removeColumn("foo"); - Assert.assertEquals( - Arrays.asList(lengthColumn, objectColumn, randomColumn), + assertEquals(Arrays.asList(lengthColumn, objectColumn, randomColumn), grid.getColumns()); } @@ -421,14 +415,14 @@ public class GridTest { public void removeAllColumns() { grid.removeAllColumns(); - Assert.assertEquals(Collections.emptyList(), grid.getColumns()); + assertEquals(Collections.emptyList(), grid.getColumns()); } @Test public void removeAllColumnsInGridWithoutColumns() { grid.removeAllColumns(); grid.removeAllColumns(); - Assert.assertEquals(Collections.emptyList(), grid.getColumns()); + assertEquals(Collections.emptyList(), grid.getColumns()); } @Test @@ -474,9 +468,9 @@ public class GridTest { List<Column<String, ?>> columns = grid.getColumns(); - Assert.assertEquals(2, columns.size()); - Assert.assertEquals("length", columns.get(0).getId()); - Assert.assertEquals("foo", columns.get(1).getId()); + assertEquals(2, columns.size()); + assertEquals("length", columns.get(0).getId()); + assertEquals("foo", columns.get(1).getId()); } @Test(expected = IllegalStateException.class) @@ -496,16 +490,16 @@ public class GridTest { grid.setColumns("born", "name"); List<Column<Person, ?>> columns = grid.getColumns(); - Assert.assertEquals(2, columns.size()); - Assert.assertEquals("born", columns.get(0).getId()); - Assert.assertEquals("name", columns.get(1).getId()); + assertEquals(2, columns.size()); + assertEquals("born", columns.get(0).getId()); + assertEquals("name", columns.get(1).getId()); } @Test public void setColumnOrder_byColumn() { grid.setColumnOrder(randomColumn, lengthColumn); - Assert.assertEquals(Arrays.asList(randomColumn, lengthColumn, fooColumn, + assertEquals(Arrays.asList(randomColumn, lengthColumn, fooColumn, objectColumn), grid.getColumns()); } @@ -519,7 +513,7 @@ public class GridTest { public void setColumnOrder_byString() { grid.setColumnOrder("randomColumnId", "length"); - Assert.assertEquals(Arrays.asList(randomColumn, lengthColumn, fooColumn, + assertEquals(Arrays.asList(randomColumn, lengthColumn, fooColumn, objectColumn), grid.getColumns()); } @@ -563,12 +557,12 @@ public class GridTest { .addColumn(ValueProvider.identity()) .getComparator(SortDirection.ASCENDING); - Assert.assertNotNull(comparator); + assertNotNull(comparator); List<Object> values = new ArrayList<>(Arrays.asList(expectedOrder)); Collections.shuffle(values, new Random(42)); - Assert.assertArrayEquals(expectedOrder, + assertArrayEquals(expectedOrder, values.stream().sorted(comparator).toArray()); } @@ -587,7 +581,7 @@ public class GridTest { String formattedValue = Stream.of(rowData.keys()) .map(rowData::getString).filter(value -> !value.equals("Name")) .findFirst().orElse(null); - Assert.assertEquals(formattedValue, "2,017"); + assertEquals(formattedValue, "2,017"); } @Test(expected = IllegalArgumentException.class) @@ -605,7 +599,7 @@ public class GridTest { @Test public void columnId_sortProperty_noId() { - Assert.assertEquals(0, + assertEquals(0, objectColumn.getSortOrder(SortDirection.ASCENDING).count()); } @@ -623,10 +617,9 @@ public class GridTest { .getSortOrder(SortDirection.ASCENDING) .toArray(QuerySortOrder[]::new); - Assert.assertEquals(1, sortOrders.length); - Assert.assertEquals(SortDirection.ASCENDING, - sortOrders[0].getDirection()); - Assert.assertEquals(expectedProperty, sortOrders[0].getSorted()); + assertEquals(1, sortOrders.length); + assertEquals(SortDirection.ASCENDING, sortOrders[0].getDirection()); + assertEquals(expectedProperty, sortOrders[0].getSorted()); } private static <T> JsonObject getRowData(Grid<T> grid, T row) { diff --git a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/DefaultAlignmentTest.java b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/DefaultAlignmentTest.java index 9b6368474f..c682a43674 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/DefaultAlignmentTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/DefaultAlignmentTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.server.component.gridlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -24,10 +25,9 @@ public class DefaultAlignmentTest { TextField tf = new TextField("A TextField"); gridLayout.addComponent(label); gridLayout.addComponent(tf); - Assert.assertEquals(Alignment.TOP_LEFT, + assertEquals(Alignment.TOP_LEFT, gridLayout.getComponentAlignment(label)); - Assert.assertEquals(Alignment.TOP_LEFT, - gridLayout.getComponentAlignment(tf)); + assertEquals(Alignment.TOP_LEFT, gridLayout.getComponentAlignment(tf)); } @Test @@ -37,9 +37,9 @@ public class DefaultAlignmentTest { gridLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); gridLayout.addComponent(label); gridLayout.addComponent(tf); - Assert.assertEquals(Alignment.MIDDLE_CENTER, + assertEquals(Alignment.MIDDLE_CENTER, gridLayout.getComponentAlignment(label)); - Assert.assertEquals(Alignment.MIDDLE_CENTER, + assertEquals(Alignment.MIDDLE_CENTER, gridLayout.getComponentAlignment(tf)); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java index 0ca92e4ed5..a63ec8b20a 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/gridlayout/GridLayoutDeclarativeTest.java @@ -239,7 +239,7 @@ public class GridLayoutDeclarativeTest continue; } - Assert.assertEquals(expected.getComponentAlignment(eC), + assertEquals(expected.getComponentAlignment(eC), result.getComponentAlignment(rC)); } @@ -297,7 +297,7 @@ public class GridLayoutDeclarativeTest Component component = Design.read(input); GridLayout readLayout = (GridLayout) component; - Assert.assertEquals(layout.getRows(), readLayout.getRows()); + assertEquals(layout.getRows(), readLayout.getRows()); } @Test @@ -333,15 +333,15 @@ public class GridLayoutDeclarativeTest + "</vaadin-grid-layout>"; DesignContext context = Design .read(new ByteArrayInputStream(design.getBytes(UTF_8)), null); - Assert.assertEquals(null, context.getCustomAttributes( + assertEquals(null, context.getCustomAttributes( context.getComponentByLocalId("marginComponent"))); - Assert.assertEquals(null, context.getCustomAttributes( + assertEquals(null, context.getCustomAttributes( context.getComponentByLocalId("marginLeftComponent"))); - Assert.assertEquals(null, context.getCustomAttributes( + assertEquals(null, context.getCustomAttributes( context.getComponentByLocalId("marginRightComponent"))); - Assert.assertEquals(null, context.getCustomAttributes( + assertEquals(null, context.getCustomAttributes( context.getComponentByLocalId("marginTopComponent"))); - Assert.assertEquals(null, context.getCustomAttributes( + assertEquals(null, context.getCustomAttributes( context.getComponentByLocalId("marginBottomComponent"))); } @@ -355,8 +355,8 @@ public class GridLayoutDeclarativeTest PreconfiguredGridLayout myLayout = (PreconfiguredGridLayout) Design .read(new ByteArrayInputStream(design.getBytes(UTF_8))); - Assert.assertEquals(2, myLayout.getRows()); - Assert.assertEquals(2, myLayout.getColumns()); + assertEquals(2, myLayout.getRows()); + assertEquals(2, myLayout.getColumns()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java index 7a0a8957b0..d6eeb13d84 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/label/LabelDeclarativeTest.java @@ -94,23 +94,23 @@ public class LabelDeclarativeTest extends DeclarativeTestBase<Label> { public void testHtmlEntities() { String design = "<vaadin-label plain-text=\"true\">> Test</vaadin-label>"; Label read = read(design); - Assert.assertEquals("> Test", read.getValue()); + assertEquals("> Test", read.getValue()); design = design.replace("plain-text=\"true\"", ""); read = read(design); - Assert.assertEquals("> Test", read.getValue()); + assertEquals("> Test", read.getValue()); Label label = new Label("& Test"); label.setContentMode(ContentMode.TEXT); Element root = new Element(Tag.valueOf("vaadin-label"), ""); label.writeDesign(root, new DesignContext()); - Assert.assertEquals("&amp; Test", root.html()); + assertEquals("&amp; Test", root.html()); label.setContentMode(ContentMode.HTML); root = new Element(Tag.valueOf("vaadin-label"), ""); label.writeDesign(root, new DesignContext()); - Assert.assertEquals("& Test", root.html()); + assertEquals("& Test", root.html()); } /** diff --git a/server/src/test/java/com/vaadin/tests/server/component/loginform/LoginFormTest.java b/server/src/test/java/com/vaadin/tests/server/component/loginform/LoginFormTest.java index a69c3f32a2..b37eea5188 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/loginform/LoginFormTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/loginform/LoginFormTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.server.component.loginform; +import static org.junit.Assert.assertEquals; + import java.util.Iterator; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -27,9 +28,9 @@ public class LoginFormTest { @Test public void defaultCaptions() { - Assert.assertEquals("Username", loginForm.getUsernameCaption()); - Assert.assertEquals("Password", loginForm.getPasswordCaption()); - Assert.assertEquals("Login", loginForm.getLoginButtonCaption()); + assertEquals("Username", loginForm.getUsernameCaption()); + assertEquals("Password", loginForm.getPasswordCaption()); + assertEquals("Login", loginForm.getLoginButtonCaption()); } @Test @@ -38,9 +39,9 @@ public class LoginFormTest { loginForm.setPasswordCaption("p"); loginForm.setLoginButtonCaption("l"); - Assert.assertEquals("u", loginForm.getUsernameCaption()); - Assert.assertEquals("p", loginForm.getPasswordCaption()); - Assert.assertEquals("l", loginForm.getLoginButtonCaption()); + assertEquals("u", loginForm.getUsernameCaption()); + assertEquals("p", loginForm.getPasswordCaption()); + assertEquals("l", loginForm.getLoginButtonCaption()); } @Test @@ -51,9 +52,9 @@ public class LoginFormTest { loginForm.setPasswordCaption("p"); loginForm.setLoginButtonCaption("l"); - Assert.assertEquals("u", loginForm.getUsernameCaption()); - Assert.assertEquals("p", loginForm.getPasswordCaption()); - Assert.assertEquals("l", loginForm.getLoginButtonCaption()); + assertEquals("u", loginForm.getUsernameCaption()); + assertEquals("p", loginForm.getPasswordCaption()); + assertEquals("l", loginForm.getLoginButtonCaption()); } @Test @@ -68,9 +69,9 @@ public class LoginFormTest { loginForm.setPasswordCaption("p"); loginForm.setLoginButtonCaption("l"); - Assert.assertEquals("u", loginForm.getUsernameCaption()); - Assert.assertEquals("p", loginForm.getPasswordCaption()); - Assert.assertEquals("l", loginForm.getLoginButtonCaption()); + assertEquals("u", loginForm.getUsernameCaption()); + assertEquals("p", loginForm.getPasswordCaption()); + assertEquals("l", loginForm.getLoginButtonCaption()); } @Test @@ -100,8 +101,8 @@ public class LoginFormTest { ui.setContent(customForm); Iterator<Component> i = ((HasComponents) customForm.iterator().next()) .iterator(); - Assert.assertEquals("Username caption", i.next().getCaption()); - Assert.assertEquals("Password caption", i.next().getCaption()); - Assert.assertEquals("Do it", i.next().getCaption()); + assertEquals("Username caption", i.next().getCaption()); + assertEquals("Password caption", i.next().getCaption()); + assertEquals("Do it", i.next().getCaption()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java b/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java index bd8c2dd443..d06e1d438e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/menubar/MenuBarIdsTest.java @@ -1,9 +1,11 @@ package com.vaadin.tests.server.component.menubar; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + import java.util.HashSet; import java.util.Set; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -81,7 +83,7 @@ public class MenuBarIdsTest implements Command { private static void assertUniqueIds(Set<Object> ids, MenuItem item) { int id = item.getId(); System.out.println("Item " + item.getText() + ", id: " + id); - Assert.assertFalse(ids.contains(id)); + assertFalse(ids.contains(id)); ids.add(id); if (item.getChildren() != null) { for (MenuItem subItem : item.getChildren()) { @@ -92,8 +94,7 @@ public class MenuBarIdsTest implements Command { @Override public void menuSelected(MenuItem selectedItem) { - Assert.assertNull( - "lastSelectedItem was not cleared before selecting an item", + assertNull("lastSelectedItem was not cleared before selecting an item", lastSelectedItem); lastSelectedItem = selectedItem; diff --git a/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/DefaultAlignmentTest.java b/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/DefaultAlignmentTest.java index 7560c21adb..f0d9e9832a 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/DefaultAlignmentTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/orderedlayout/DefaultAlignmentTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.server.component.orderedlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -37,10 +38,8 @@ public class DefaultAlignmentTest { TextField tf = new TextField("A TextField"); layout.addComponent(label); layout.addComponent(tf); - Assert.assertEquals(Alignment.TOP_LEFT, - layout.getComponentAlignment(label)); - Assert.assertEquals(Alignment.TOP_LEFT, - layout.getComponentAlignment(tf)); + assertEquals(Alignment.TOP_LEFT, layout.getComponentAlignment(label)); + assertEquals(Alignment.TOP_LEFT, layout.getComponentAlignment(tf)); } @Test @@ -59,9 +58,8 @@ public class DefaultAlignmentTest { layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); layout.addComponent(label); layout.addComponent(tf); - Assert.assertEquals(Alignment.MIDDLE_CENTER, + assertEquals(Alignment.MIDDLE_CENTER, layout.getComponentAlignment(label)); - Assert.assertEquals(Alignment.MIDDLE_CENTER, - layout.getComponentAlignment(tf)); + assertEquals(Alignment.MIDDLE_CENTER, layout.getComponentAlignment(tf)); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java b/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java index 91cfe7712a..54fb58a9c3 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/tabsheet/TabSheetTest.java @@ -1,15 +1,16 @@ package com.vaadin.tests.server.component.tabsheet; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import java.util.Iterator; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.ui.tabsheet.TabsheetServerRpc; @@ -35,7 +36,7 @@ public class TabSheetTest { Iterator<Component> iter = tabSheet.getComponentIterator(); assertEquals(c, iter.next()); - Assert.assertFalse(iter.hasNext()); + assertFalse(iter.hasNext()); assertNotNull(tabSheet.getTab(c)); } @@ -207,10 +208,10 @@ public class TabSheetTest { tabSheet.replaceComponent(lbl1, lbl2); assertSame(tab1, tabSheet.getTab(lbl1)); assertSame(tab2, tabSheet.getTab(lbl2)); - Assert.assertFalse(tab1.isClosable()); - Assert.assertTrue(tab2.isClosable()); - Assert.assertFalse(tab1.isEnabled()); - Assert.assertTrue(tab2.isEnabled()); + assertFalse(tab1.isClosable()); + assertTrue(tab2.isClosable()); + assertFalse(tab1.isEnabled()); + assertTrue(tab2.isEnabled()); assertEquals("description", tab1.getDescription()); assertEquals(null, tab2.getDescription()); assertEquals(3, tabSheet.getComponentCount()); @@ -226,7 +227,7 @@ public class TabSheetTest { assertNull(tabSheet.getTab(lbl1)); assertNull(tab1.getComponent()); assertNotNull(tabSheet.getTab(lbl3)); - Assert.assertFalse(tabSheet.getTab(lbl3).isEnabled()); + assertFalse(tabSheet.getTab(lbl3).isEnabled()); assertEquals("description", tab1.getDescription()); assertEquals(1, tabSheet.getTabPosition(tabSheet.getTab(lbl3))); } @@ -322,18 +323,18 @@ public class TabSheetTest { }); tabsheet.setSelectedTab(b2); - Assert.assertFalse(userOriginated.get()); - Assert.assertEquals(b2, selected.get()); + assertFalse(userOriginated.get()); + assertEquals(b2, selected.get()); TabsheetServerRpc rpc = ComponentTest.getRpcProxy(tabsheet, TabsheetServerRpc.class); rpc.setSelected(tabsheet.getKey(b1)); - Assert.assertTrue(userOriginated.get()); - Assert.assertEquals(b1, selected.get()); + assertTrue(userOriginated.get()); + assertEquals(b1, selected.get()); tabsheet.setSelectedTab(tabsheet.getTab(b4)); - Assert.assertFalse(userOriginated.get()); - Assert.assertEquals(b4, selected.get()); + assertFalse(userOriginated.get()); + assertEquals(b4, selected.get()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java index ad8d88e9c5..2c830279e9 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/textarea/TextAreaDeclarativeTest.java @@ -68,7 +68,7 @@ public class TextAreaDeclarativeTest public void testHtmlEntities() throws IOException { String design = "<vaadin-text-area>& Test</vaadin-text-area>"; TextArea read = read(design); - Assert.assertEquals("& Test", read.getValue()); + assertEquals("& Test", read.getValue()); read.setValue("& Test"); @@ -76,7 +76,7 @@ public class TextAreaDeclarativeTest Element root = new Element(Tag.valueOf("vaadin-text-area"), ""); read.writeDesign(root, dc); - Assert.assertEquals("&amp; Test", root.html()); + assertEquals("&amp; Test", root.html()); } @Test diff --git a/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java index a8f7741f1b..b2c0c8ae21 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/tree/TreeDeclarativeTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.server.component.tree; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.data.TreeData; @@ -32,28 +33,26 @@ public class TreeDeclarativeTest Tree<Person> tree = new Tree<>(); tree.setTreeData(data); tree.setItemCaptionGenerator(item -> item.getFirstName()); - - String designString = String.format("<%s>" - + "<node item='%s'>%s</node>" - + "<node item='%s' parent='%s'>%s</node>" - + "<node item='%s' parent='%s'>%s</node>" - + "<node item='%s' parent='%s'>%s</node>" - + "<node item='%s'>%s</node>" - + "</%s>", getComponentTag(), - person1.toString(), person1.getFirstName(), + + String designString = String.format( + "<%s>" + "<node item='%s'>%s</node>" + + "<node item='%s' parent='%s'>%s</node>" + + "<node item='%s' parent='%s'>%s</node>" + + "<node item='%s' parent='%s'>%s</node>" + + "<node item='%s'>%s</node>" + "</%s>", + getComponentTag(), person1.toString(), person1.getFirstName(), person2.toString(), person1.toString(), person2.getFirstName(), person3.toString(), person1.toString(), person3.getFirstName(), person4.toString(), person3.toString(), person4.getFirstName(), - person5.toString(), person5.getFirstName(), - getComponentTag()); + person5.toString(), person5.getFirstName(), getComponentTag()); testWrite(designString, tree, true); Tree<String> readTree = testRead(designString, tree); - Assert.assertEquals(2, readTree.getDataProvider() + assertEquals(2, readTree.getDataProvider() .getChildCount(new HierarchicalQuery<>(null, null))); - Assert.assertEquals(2, readTree.getDataProvider().getChildCount( + assertEquals(2, readTree.getDataProvider().getChildCount( new HierarchicalQuery<>(null, person1.toString()))); - Assert.assertEquals(1, readTree.getDataProvider().getChildCount( + assertEquals(1, readTree.getDataProvider().getChildCount( new HierarchicalQuery<>(null, person3.toString()))); } @@ -154,11 +153,11 @@ public class TreeDeclarativeTest @Override protected void assertEquals(String message, Object o1, Object o2) { if (o1 instanceof ItemCaptionGenerator) { - Assert.assertTrue(o2 instanceof ItemCaptionGenerator); + assertTrue(o2 instanceof ItemCaptionGenerator); return; } if (o1 instanceof IconGenerator) { - Assert.assertTrue(o2 instanceof IconGenerator); + assertTrue(o2 instanceof IconGenerator); return; } super.assertEquals(message, o1, o2); diff --git a/server/src/test/java/com/vaadin/tests/server/component/treegrid/TreeGridDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/treegrid/TreeGridDeclarativeTest.java index a13ba357ef..5905d8d767 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/treegrid/TreeGridDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/treegrid/TreeGridDeclarativeTest.java @@ -68,13 +68,13 @@ public class TreeGridDeclarativeTest person7.getLastName(), getComponentTag()); TreeGrid<String> readGrid = testRead(design, grid); - Assert.assertEquals(3, readGrid.getDataProvider() + assertEquals(3, readGrid.getDataProvider() .size(new HierarchicalQuery<>(null, null))); - Assert.assertEquals(2, readGrid.getDataProvider() + assertEquals(2, readGrid.getDataProvider() .size(new HierarchicalQuery<>(null, person1.toString()))); - Assert.assertEquals(1, readGrid.getDataProvider() + assertEquals(1, readGrid.getDataProvider() .size(new HierarchicalQuery<>(null, person5.toString()))); - Assert.assertEquals(1, readGrid.getDataProvider() + assertEquals(1, readGrid.getDataProvider() .size(new HierarchicalQuery<>(null, person6.toString()))); testWrite(design, grid, true); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java index 22695f3918..d43491f00c 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadDeclarativeTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.server.component.upload; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.tests.design.DeclarativeTestBase; @@ -62,12 +64,11 @@ public class UploadDeclarativeTest extends DeclarativeTestBase<Upload> { @Test public void testImmediateModeDefault() { - Assert.assertTrue( - testRead("<v-upload />", new Upload()).isImmediateMode()); + assertTrue(testRead("<v-upload />", new Upload()).isImmediateMode()); Upload upload = new Upload(); upload.setImmediateMode(false); - Assert.assertFalse(testRead("<v-upload immediate-mode=false />", upload) + assertFalse(testRead("<v-upload immediate-mode=false />", upload) .isImmediateMode()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java index a2364b132d..a453769c66 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/upload/UploadTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.server.component.upload; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.server.StreamVariable; @@ -38,14 +41,14 @@ public class UploadTest { variable.streamingFailed(new TestStreamingErrorEvent()); } catch (Exception e) { } - Assert.assertFalse(upload.isUploading()); + assertFalse(upload.isUploading()); } @Test public void setImmediateMode_defaultTrue() { Upload upload = new Upload(); - Assert.assertTrue("Upload should be in immediate mode by default", + assertTrue("Upload should be in immediate mode by default", upload.isImmediateMode()); } @@ -53,7 +56,7 @@ public class UploadTest { public void getState_uploadHasCustomState() { TestUpload upload = new TestUpload(); UploadState state = upload.getState(); - Assert.assertEquals("Unexpected state class", UploadState.class, + assertEquals("Unexpected state class", UploadState.class, state.getClass()); } @@ -61,14 +64,14 @@ public class UploadTest { public void getPrimaryStyleName_uploadHasCustomPrimaryStyleName() { Upload upload = new Upload(); UploadState state = new UploadState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, upload.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + upload.getPrimaryStyleName()); } @Test public void uploadStateHasCustomPrimaryStyleName() { UploadState state = new UploadState(); - Assert.assertEquals("Unexpected primary style name", "v-upload", + assertEquals("Unexpected primary style name", "v-upload", state.primaryStyleName); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java b/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java index 8416a216c1..cd7570e7b6 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/window/AttachDetachWindowTest.java @@ -226,7 +226,7 @@ public class AttachDetachWindowTest { eventFired[0] = event.getAttachedComponent().equals(window); }); ui.addWindow(window); - Assert.assertTrue("Attach event is not fired for added window", + assertTrue("Attach event is not fired for added window", eventFired[0]); } @@ -242,7 +242,7 @@ public class AttachDetachWindowTest { ui.addWindow(window); ui.removeWindow(window); - Assert.assertTrue("Detach event is not fired for removed window", + assertTrue("Detach event is not fired for removed window", eventFired[0]); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java index ab4ef3b40f..a832ce6341 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.server.component.window; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.event.ShortcutAction.KeyCode; @@ -134,7 +135,7 @@ public class WindowDeclarativeTest extends DeclarativeTestBase<Window> { protected void assertInvalidPosition(String position) { try { read("<vaadin-window position='" + position + "'>"); - Assert.fail("Invalid position '" + position + "' should throw"); + fail("Invalid position '" + position + "' should throw"); } catch (Exception e) { // expected } diff --git a/server/src/test/java/com/vaadin/tests/server/component/window/WindowTest.java b/server/src/test/java/com/vaadin/tests/server/component/window/WindowTest.java index d743c4f009..aedcfbc5f0 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/window/WindowTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/window/WindowTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.server.component.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -38,23 +39,23 @@ public class WindowTest { Button b2 = new Button("button 2"); window.setAssistiveDescription(l1, b2); - Assert.assertEquals(2, window.getAssistiveDescription().length); - Assert.assertEquals(l1, window.getAssistiveDescription()[0]); - Assert.assertEquals(b2, window.getAssistiveDescription()[1]); + assertEquals(2, window.getAssistiveDescription().length); + assertEquals(l1, window.getAssistiveDescription()[0]); + assertEquals(b2, window.getAssistiveDescription()[1]); // Modifying return value must not change actual value window.getAssistiveDescription()[0] = null; - Assert.assertEquals(2, window.getAssistiveDescription().length); - Assert.assertEquals(l1, window.getAssistiveDescription()[0]); - Assert.assertEquals(b2, window.getAssistiveDescription()[1]); + assertEquals(2, window.getAssistiveDescription().length); + assertEquals(l1, window.getAssistiveDescription()[0]); + assertEquals(b2, window.getAssistiveDescription()[1]); } @Test public void testSetPosition() { window.setPosition(100, 200); - Assert.assertEquals(100, window.getPositionX()); - Assert.assertEquals(200, window.getPositionY()); + assertEquals(100, window.getPositionX()); + assertEquals(200, window.getPositionY()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java index e5537992c0..89c95ffeb8 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/AddRemoveComponentTest.java @@ -1,11 +1,13 @@ package com.vaadin.tests.server.componentcontainer; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.VaadinClasses; @@ -23,7 +25,7 @@ public class AddRemoveComponentTest { List<Class<? extends ComponentContainer>> containerClasses = VaadinClasses .getComponentContainersSupportingAddRemoveComponent(); - Assert.assertTrue(containerClasses.size() > 0); + assertTrue(containerClasses.size() > 0); // No default constructor, special case containerClasses.remove(CustomLayout.class); @@ -52,7 +54,7 @@ public class AddRemoveComponentTest { hl.addComponent(label); componentContainer.removeComponent(label); - Assert.assertEquals( + assertEquals( "Parent no longer correct for " + componentContainer.getClass(), hl, label.getParent()); } diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java index 53bb87717f..10dc79da5b 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java @@ -1,5 +1,6 @@ package com.vaadin.tests.server.componentcontainer; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; @@ -7,7 +8,6 @@ import static org.junit.Assert.fail; import java.util.Iterator; import java.util.NoSuchElementException; -import org.junit.Assert; import org.junit.Test; import com.vaadin.shared.ui.orderedlayout.FormLayoutState; @@ -43,8 +43,8 @@ public class FormLayoutTest extends AbstractIndexedLayoutTestBase { return getLayout().getComponentCount(); } - Component[] children = { new Label("A"), new Label("B"), - new Label("C"), new Label("D") }; + Component[] children = { new Label("A"), new Label("B"), new Label("C"), + new Label("D") }; @Test public void testConstructorWithComponents() { @@ -63,7 +63,7 @@ public class FormLayoutTest extends AbstractIndexedLayoutTestBase { public void getState_formLayoutHasCustomState() { TestFormLayout layout = new TestFormLayout(); FormLayoutState state = layout.getState(); - Assert.assertEquals("Unexpected state class", FormLayoutState.class, + assertEquals("Unexpected state class", FormLayoutState.class, state.getClass()); } @@ -71,14 +71,14 @@ public class FormLayoutTest extends AbstractIndexedLayoutTestBase { public void getPrimaryStyleName_formLayoutHasCustomPrimaryStyleName() { FormLayout layout = new FormLayout(); FormLayoutState state = new FormLayoutState(); - Assert.assertEquals("Unexpected primary style name", - state.primaryStyleName, layout.getPrimaryStyleName()); + assertEquals("Unexpected primary style name", state.primaryStyleName, + layout.getPrimaryStyleName()); } @Test public void formLayoutStateHasCustomPrimaryStyleName() { FormLayoutState state = new FormLayoutState(); - Assert.assertEquals("Unexpected primary style name", "v-formlayout", + assertEquals("Unexpected primary style name", "v-formlayout", state.primaryStyleName); } diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/HorizontalLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/HorizontalLayoutTest.java index 12f235011e..ec5784e7c4 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/HorizontalLayoutTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/HorizontalLayoutTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.server.componentcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import org.junit.Test; import com.vaadin.ui.Button; @@ -46,30 +48,30 @@ public class HorizontalLayoutTest extends AbstractIndexedLayoutTestBase { layout.addComponentsAndExpand(b1, b2); - Assert.assertEquals(3, layout.getComponentCount()); + assertEquals(3, layout.getComponentCount()); - Assert.assertSame(b3, layout.getComponent(0)); - Assert.assertSame(b1, layout.getComponent(1)); - Assert.assertSame(b2, layout.getComponent(2)); + assertSame(b3, layout.getComponent(0)); + assertSame(b1, layout.getComponent(1)); + assertSame(b2, layout.getComponent(2)); - Assert.assertEquals(0, layout.getExpandRatio(b3), 0); - Assert.assertEquals(1, layout.getExpandRatio(b1), 0); - Assert.assertEquals(1, layout.getExpandRatio(b2), 0); + assertEquals(0, layout.getExpandRatio(b3), 0); + assertEquals(1, layout.getExpandRatio(b1), 0); + assertEquals(1, layout.getExpandRatio(b2), 0); - Assert.assertEquals(-1, b3.getWidth(), 0); - Assert.assertEquals(100, b1.getWidth(), 0); - Assert.assertEquals(100, b2.getWidth(), 0); + assertEquals(-1, b3.getWidth(), 0); + assertEquals(100, b1.getWidth(), 0); + assertEquals(100, b2.getWidth(), 0); } @Test public void addAndExpand_undefinedHeightUpdated() { HorizontalLayout layout = getLayout(); - Assert.assertEquals(-1, layout.getWidth(), 0); + assertEquals(-1, layout.getWidth(), 0); layout.addComponentsAndExpand(); - Assert.assertEquals(100, layout.getWidth(), 0); + assertEquals(100, layout.getWidth(), 0); } @Test @@ -80,7 +82,7 @@ public class HorizontalLayoutTest extends AbstractIndexedLayoutTestBase { layout.addComponentsAndExpand(); - Assert.assertEquals(150, layout.getWidth(), 0); + assertEquals(150, layout.getWidth(), 0); } } diff --git a/server/src/test/java/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java b/server/src/test/java/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java index 2bb5d3a433..037b97c5a1 100644 --- a/server/src/test/java/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java +++ b/server/src/test/java/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.server.componentcontainer; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + import org.junit.Test; import com.vaadin.ui.Button; @@ -46,30 +48,30 @@ public class VerticalLayoutTest extends AbstractIndexedLayoutTestBase { layout.addComponentsAndExpand(b1, b2); - Assert.assertEquals(3, layout.getComponentCount()); + assertEquals(3, layout.getComponentCount()); - Assert.assertSame(b3, layout.getComponent(0)); - Assert.assertSame(b1, layout.getComponent(1)); - Assert.assertSame(b2, layout.getComponent(2)); + assertSame(b3, layout.getComponent(0)); + assertSame(b1, layout.getComponent(1)); + assertSame(b2, layout.getComponent(2)); - Assert.assertEquals(0, layout.getExpandRatio(b3), 0); - Assert.assertEquals(1, layout.getExpandRatio(b1), 0); - Assert.assertEquals(1, layout.getExpandRatio(b2), 0); + assertEquals(0, layout.getExpandRatio(b3), 0); + assertEquals(1, layout.getExpandRatio(b1), 0); + assertEquals(1, layout.getExpandRatio(b2), 0); - Assert.assertEquals(-1, b3.getHeight(), 0); - Assert.assertEquals(100, b1.getHeight(), 0); - Assert.assertEquals(100, b2.getHeight(), 0); + assertEquals(-1, b3.getHeight(), 0); + assertEquals(100, b1.getHeight(), 0); + assertEquals(100, b2.getHeight(), 0); } @Test public void addAndExpand_undefinedHeightUpdated() { VerticalLayout layout = getLayout(); - Assert.assertEquals(-1, layout.getHeight(), 0); + assertEquals(-1, layout.getHeight(), 0); layout.addComponentsAndExpand(); - Assert.assertEquals(100, layout.getHeight(), 0); + assertEquals(100, layout.getHeight(), 0); } @Test @@ -80,7 +82,7 @@ public class VerticalLayoutTest extends AbstractIndexedLayoutTestBase { layout.addComponentsAndExpand(); - Assert.assertEquals(150, layout.getHeight(), 0); + assertEquals(150, layout.getHeight(), 0); } } diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java index 019c13698d..2a756da1cb 100644 --- a/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/src/test/java/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -17,9 +17,11 @@ package com.vaadin.tests.server.navigator; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.LinkedList; @@ -31,7 +33,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.easymock.EasyMock; import org.easymock.IArgumentMatcher; import org.easymock.IMocksControl; -import org.junit.Assert; import org.junit.Test; import com.vaadin.navigator.NavigationStateManager; @@ -370,24 +371,23 @@ public class NavigatorTest { TestNavigatorWithFragments navigator = new TestNavigatorWithFragments( ui); - Assert.assertTrue("Add URI fragment Page method has not been called", + assertTrue("Add URI fragment Page method has not been called", page.addUriFragmentCalled()); - Assert.assertFalse("Unexpected remove URI fragment Page method call", + assertFalse("Unexpected remove URI fragment Page method call", page.removeUriFragmentCalled()); - Assert.assertNotNull("Navigator is null in UI", ui.getNavigator()); + assertNotNull("Navigator is null in UI", ui.getNavigator()); navigator.destroy(); - Assert.assertTrue( + assertTrue( "Remove URI fragment Page method has not been called after destroy", page.removeUriFragmentCalled()); - Assert.assertNull("Navigator is not null in UI after destroy", + assertNull("Navigator is not null in UI after destroy", ui.getNavigator()); try { page.setUriFragment("foobar", true); // This should throw - Assert.fail( - "Expected null pointer exception after call uriFragmentChanged " - + "for destroyed navigator"); + fail("Expected null pointer exception after call uriFragmentChanged " + + "for destroyed navigator"); } catch (NullPointerException e) { // All ok. } @@ -399,25 +399,24 @@ public class NavigatorTest { UI ui = new TestPushStateUI(page); TestNavigator navigator = new TestNavigator(ui); - Assert.assertTrue("Add URI fragment Page method has not been called", + assertTrue("Add URI fragment Page method has not been called", page.addPopstateCalled()); - Assert.assertFalse("Unexpected remove URI fragment Page method call", + assertFalse("Unexpected remove URI fragment Page method call", page.removePopstateCalled()); - Assert.assertNotNull("Navigator is null in UI", ui.getNavigator()); + assertNotNull("Navigator is null in UI", ui.getNavigator()); navigator.destroy(); - Assert.assertTrue( + assertTrue( "Remove URI fragment Page method has not been called after destroy", page.removePopstateCalled()); - Assert.assertNull("Navigator is not null in UI after destroy", + assertNull("Navigator is not null in UI after destroy", ui.getNavigator()); try { page.updateLocation("http://server/path/info", true, true); - Assert.fail( - "Expected null pointer exception after call uriFragmentChanged " - + "for destroyed navigator"); + fail("Expected null pointer exception after call uriFragmentChanged " + + "for destroyed navigator"); } catch (NullPointerException e) { // All ok. } @@ -531,12 +530,12 @@ public class NavigatorTest { navigator.addProvider(provider); navigator.navigateTo("test2"); - Assert.assertEquals("", view2.getParams()); - Assert.assertEquals(null, view1.getParams()); + assertEquals("", view2.getParams()); + assertEquals(null, view1.getParams()); navigator.navigateTo(""); - Assert.assertEquals("", view1.getParams()); + assertEquals("", view1.getParams()); navigator.navigateTo("test1/params"); - Assert.assertEquals("params", view1.getParams()); + assertEquals("params", view1.getParams()); } @Test @@ -1005,11 +1004,11 @@ public class NavigatorTest { // First time navigation navigator.navigateTo(viewName); - Assert.assertEquals(1, count[0]); + assertEquals(1, count[0]); // Second time navigation to the same view navigator.navigateTo(viewName); - Assert.assertEquals(1, count[0]); + assertEquals(1, count[0]); } public static class ViewIsNotAComponent implements View { @@ -1065,8 +1064,8 @@ public class NavigatorTest { navigator.addView("foo", ViewIsNotAComponent.class); navigator.navigateTo("foo"); - Assert.assertEquals(HorizontalLayout.class, ui.getContent().getClass()); - Assert.assertEquals("Hello", + assertEquals(HorizontalLayout.class, ui.getContent().getClass()); + assertEquals("Hello", ((Label) ((HorizontalLayout) ui.getContent()).getComponent(0)) .getValue()); } @@ -1074,14 +1073,14 @@ public class NavigatorTest { @Test public void parameterMap_noViewSeparator() { Navigator navigator = createNavigatorWithState("fooview"); - Assert.assertTrue(navigator.getStateParameterMap().isEmpty()); - Assert.assertTrue(navigator.getStateParameterMap("foo").isEmpty()); + assertTrue(navigator.getStateParameterMap().isEmpty()); + assertTrue(navigator.getStateParameterMap("foo").isEmpty()); } @Test public void parameterMap_noParameters() { Navigator navigator = createNavigatorWithState("fooview/"); - Assert.assertTrue(navigator.getStateParameterMap().isEmpty()); + assertTrue(navigator.getStateParameterMap().isEmpty()); } @Test @@ -1119,12 +1118,12 @@ public class NavigatorTest { @SafeVarargs private final void assertMap(Map<String, String> map, Entry<String, String>... entries) { - Assert.assertEquals(entries.length, map.size()); + assertEquals(entries.length, map.size()); for (Entry<String, String> entry : entries) { - Assert.assertTrue( + assertTrue( "Map should contain a key called '" + entry.getKey() + "'", map.containsKey(entry.getKey())); - Assert.assertEquals(entry.getValue(), map.get(entry.getKey())); + assertEquals(entry.getValue(), map.get(entry.getKey())); } } @@ -1179,8 +1178,8 @@ public class NavigatorTest { navigator.navigateTo("view1"); - Assert.assertTrue(mapRef.get().isEmpty()); - Assert.assertTrue(mapRefB.get().isEmpty()); + assertTrue(mapRef.get().isEmpty()); + assertTrue(mapRefB.get().isEmpty()); navigator.navigateTo("view1/a&b=c&d"); assertMap(mapRef.get(), entry("a", ""), entry("b", "c"), @@ -1208,7 +1207,7 @@ public class NavigatorTest { navigator.addView("view2", view2); navigator.navigateTo("view1"); navigator.navigateTo("view2"); - Assert.assertEquals("view1", navigator.getState()); + assertEquals("view1", navigator.getState()); } @Test @@ -1231,7 +1230,7 @@ public class NavigatorTest { navigator.addView("view2", view2); navigator.navigateTo("view1"); navigator.navigateTo("view2"); - Assert.assertEquals("view2", navigator.getState()); + assertEquals("view2", navigator.getState()); } @@ -1256,9 +1255,9 @@ public class NavigatorTest { navigator.addView("view2", view2); navigator.navigateTo("view1"); navigator.navigateTo("view2"); - Assert.assertEquals("view1", navigator.getState()); + assertEquals("view1", navigator.getState()); eventRef.get().navigate(); - Assert.assertEquals("view2", navigator.getState()); + assertEquals("view2", navigator.getState()); } @@ -1287,9 +1286,9 @@ public class NavigatorTest { navigator.runAfterLeaveConfirmation(() -> { leaveCount.incrementAndGet(); }); - Assert.assertEquals(0, leaveCount.get()); + assertEquals(0, leaveCount.get()); eventRef.get().navigate(); - Assert.assertEquals(1, leaveCount.get()); - Assert.assertEquals("view1", navigator.getState()); + assertEquals(1, leaveCount.get()); + assertEquals("view1", navigator.getState()); } } diff --git a/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java b/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java index 230f2f2a65..66742dd7a1 100644 --- a/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java +++ b/server/src/test/java/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java @@ -16,9 +16,12 @@ package com.vaadin.tests.server.navigator; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.easymock.EasyMock; import org.easymock.IMocksControl; -import org.junit.Assert; import org.junit.Test; import com.vaadin.navigator.Navigator; @@ -40,10 +43,9 @@ public class UriFragmentManagerTest { EasyMock.replay(page); // test manager using the mock - Assert.assertEquals("Incorrect fragment value", "", manager.getState()); + assertEquals("Incorrect fragment value", "", manager.getState()); manager.setState("test"); - Assert.assertEquals("Incorrect fragment value", "test", - manager.getState()); + assertEquals("Incorrect fragment value", "test", manager.getState()); } @Test @@ -71,10 +73,10 @@ public class UriFragmentManagerTest { UriFragmentManager manager = new UriFragmentManager(page); manager.setNavigator(EasyMock.createMock(Navigator.class)); - Assert.assertTrue( + assertTrue( "addUriFragmentChangedListener() method is not called for the Page", page.addUriFragmentCalled()); - Assert.assertFalse( + assertFalse( "removeUriFragmentChangedListener() method is called for the Page", page.removeUriFragmentCalled()); } @@ -87,7 +89,7 @@ public class UriFragmentManagerTest { manager.setNavigator(EasyMock.createMock(Navigator.class)); manager.setNavigator(null); - Assert.assertTrue( + assertTrue( "removeUriFragmentChangedListener() method is not called for the Page", page.removeUriFragmentCalled()); } diff --git a/server/src/test/java/com/vaadin/tests/util/TestUtil.java b/server/src/test/java/com/vaadin/tests/util/TestUtil.java index eb5bd5e525..e98d6c07ab 100644 --- a/server/src/test/java/com/vaadin/tests/util/TestUtil.java +++ b/server/src/test/java/com/vaadin/tests/util/TestUtil.java @@ -1,13 +1,14 @@ package com.vaadin.tests.util; -import java.util.Iterator; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; -import org.junit.Assert; +import java.util.Iterator; public class TestUtil { public static void assertArrays(Object[] actualObjects, Object[] expectedObjects) { - Assert.assertEquals( + assertEquals( "Actual contains a different number of values than was expected", expectedObjects.length, actualObjects.length); @@ -15,8 +16,7 @@ public class TestUtil { Object actual = actualObjects[i]; Object expected = expectedObjects[i]; - Assert.assertEquals("Item[" + i + "] does not match", expected, - actual); + assertEquals("Item[" + i + "] does not match", expected, actual); } } @@ -29,18 +29,15 @@ public class TestUtil { while (i1.hasNext()) { Object o1 = i1.next(); if (!i2.hasNext()) { - Assert.fail( - "The second iterable contains fewer items than the first. The object " - + o1 + " has no match in the second iterable."); + fail("The second iterable contains fewer items than the first. The object " + + o1 + " has no match in the second iterable."); } Object o2 = i2.next(); - Assert.assertEquals(o1, o2); + assertEquals(o1, o2); } if (i2.hasNext()) { - Assert.fail( - "The second iterable contains more items than the first. The object " - + i2.next() - + " has no match in the first iterable."); + fail("The second iterable contains more items than the first. The object " + + i2.next() + " has no match in the first iterable."); } } diff --git a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java index deafe8368e..86f6929d38 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java @@ -1,5 +1,9 @@ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; @@ -7,7 +11,6 @@ import java.util.List; import java.util.stream.Stream; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -73,8 +76,7 @@ public class AbstractListingTest { } } - private static final String[] ITEM_ARRAY = { "Foo", "Bar", - "Baz" }; + private static final String[] ITEM_ARRAY = { "Foo", "Bar", "Baz" }; private TestListing listing; private List<String> items; @@ -89,20 +91,20 @@ public class AbstractListingTest { public void testSetItemsWithCollection() { listing.setItems(items); List<String> list = new LinkedList<>(items); - listing.getDataProvider().fetch(new Query()).forEach( - str -> Assert.assertTrue("Unexpected item in data provider", + listing.getDataProvider().fetch(new Query()) + .forEach(str -> assertTrue("Unexpected item in data provider", list.remove(str))); - Assert.assertTrue("Not all items from list were in data provider", + assertTrue("Not all items from list were in data provider", list.isEmpty()); } @Test public void testSetItemsWithVarargs() { listing.setItems(ITEM_ARRAY); - listing.getDataProvider().fetch(new Query()).forEach( - str -> Assert.assertTrue("Unexpected item in data provider", + listing.getDataProvider().fetch(new Query()) + .forEach(str -> assertTrue("Unexpected item in data provider", items.remove(str))); - Assert.assertTrue("Not all items from list were in data provider", + assertTrue("Not all items from list were in data provider", items.isEmpty()); } @@ -111,14 +113,14 @@ public class AbstractListingTest { ListDataProvider<String> dataProvider = DataProvider .ofCollection(items); listing.setDataProvider(dataProvider); - Assert.assertEquals("setDataProvider did not set data provider", - dataProvider, listing.getDataProvider()); + assertEquals("setDataProvider did not set data provider", dataProvider, + listing.getDataProvider()); listing.setDataProvider( DataProvider.fromCallbacks( query -> Stream.of(ITEM_ARRAY).skip(query.getOffset()) .limit(query.getLimit()), query -> ITEM_ARRAY.length)); - Assert.assertNotEquals("setDataProvider did not replace data provider", + assertNotEquals("setDataProvider did not replace data provider", dataProvider, listing.getDataProvider()); } @@ -128,7 +130,7 @@ public class AbstractListingTest { generator.extend(listing); listing.setItems("Foo"); listing.runDataGeneration(); - Assert.assertEquals("Generator should have been called once", 1, + assertEquals("Generator should have been called once", 1, generator.callCount); } @@ -138,7 +140,7 @@ public class AbstractListingTest { listing.setItems("Foo"); generator.extend(listing); listing.runDataGeneration(); - Assert.assertEquals("Generator should have been called once", 1, + assertEquals("Generator should have been called once", 1, generator.callCount); } @@ -148,10 +150,10 @@ public class AbstractListingTest { CountGenerator generator = new CountGenerator(); generator.extend(listing); listing.runDataGeneration(); - Assert.assertEquals("Generator should have been called once", 1, + assertEquals("Generator should have been called once", 1, generator.callCount); listing.runDataGeneration(); - Assert.assertEquals("Generator should not have been called again", 1, + assertEquals("Generator should not have been called again", 1, generator.callCount); } @@ -162,7 +164,7 @@ public class AbstractListingTest { generator.extend(listing); generator.remove(); listing.runDataGeneration(); - Assert.assertEquals("Generator should not have been called", 0, + assertEquals("Generator should not have been called", 0, generator.callCount); } @@ -172,11 +174,11 @@ public class AbstractListingTest { CountGenerator generator = new CountGenerator(); generator.extend(listing); listing.runDataGeneration(); - Assert.assertEquals("Generator should have been called once", 1, + assertEquals("Generator should have been called once", 1, generator.callCount); generator.refresh("Foo"); listing.runDataGeneration(); - Assert.assertEquals("Generator should have been called again", 2, + assertEquals("Generator should have been called again", 2, generator.callCount); } } diff --git a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java index 0dcef85579..6bbd314761 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java @@ -15,6 +15,12 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -29,7 +35,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -124,7 +129,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { registration = selectToTest.addSelectionListener(event -> { listenerCount.incrementAndGet(); - Assert.assertFalse(event.isUserOriginated()); + assertFalse(event.isUserOriginated()); }); selectToTest.select("1"); @@ -136,23 +141,23 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { selectToTest.select("2", "3", "4"); selectToTest.deselect("1", "4"); - Assert.assertEquals(6, listenerCount.get()); + assertEquals(6, listenerCount.get()); // select partly selected selectToTest.select("2", "3", "4"); - Assert.assertEquals(7, listenerCount.get()); + assertEquals(7, listenerCount.get()); // select completely selected selectToTest.select("2", "3", "4"); - Assert.assertEquals(7, listenerCount.get()); + assertEquals(7, listenerCount.get()); // deselect partly not selected selectToTest.select("1", "4"); - Assert.assertEquals(8, listenerCount.get()); + assertEquals(8, listenerCount.get()); // deselect completely not selected selectToTest.select("1", "4"); - Assert.assertEquals(8, listenerCount.get()); + assertEquals(8, listenerCount.get()); verifyValueChangeEvents(); } @@ -162,7 +167,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { registration = selectToTest.addSelectionListener(event -> { listenerCount.incrementAndGet(); - Assert.assertTrue(event.isUserOriginated()); + assertTrue(event.isUserOriginated()); }); rpcSelect("1"); @@ -177,58 +182,58 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { rpcDeselectItems("1", "3"); assertSelectionOrder("6"); - Assert.assertEquals(5, listenerCount.get()); + assertEquals(5, listenerCount.get()); // select partly selected rpcSelect("2", "3", "4"); - Assert.assertEquals(6, listenerCount.get()); + assertEquals(6, listenerCount.get()); assertSelectionOrder("6", "2", "3", "4"); // select completely selected rpcSelect("2", "3", "4"); - Assert.assertEquals(6, listenerCount.get()); + assertEquals(6, listenerCount.get()); assertSelectionOrder("6", "2", "3", "4"); // deselect partly not selected rpcDeselectItems("1", "4"); - Assert.assertEquals(7, listenerCount.get()); + assertEquals(7, listenerCount.get()); assertSelectionOrder("6", "2", "3"); // deselect completely not selected rpcDeselectItems("1", "4"); - Assert.assertEquals(7, listenerCount.get()); + assertEquals(7, listenerCount.get()); assertSelectionOrder("6", "2", "3"); // select completely selected and deselect completely not selected rpcUpdateSelection(new String[] { "3" }, new String[] { "1", "4" }); - Assert.assertEquals(7, listenerCount.get()); + assertEquals(7, listenerCount.get()); assertSelectionOrder("6", "2", "3"); // select partly selected and deselect completely not selected rpcUpdateSelection(new String[] { "4", "2" }, new String[] { "1", "8" }); - Assert.assertEquals(8, listenerCount.get()); + assertEquals(8, listenerCount.get()); assertSelectionOrder("6", "2", "3", "4"); // select completely selected and deselect partly not selected rpcUpdateSelection(new String[] { "4", "3" }, new String[] { "1", "2" }); - Assert.assertEquals(9, listenerCount.get()); + assertEquals(9, listenerCount.get()); assertSelectionOrder("6", "3", "4"); // duplicate case - ignored rpcUpdateSelection(new String[] { "2" }, new String[] { "2" }); - Assert.assertEquals(9, listenerCount.get()); + assertEquals(9, listenerCount.get()); assertSelectionOrder("6", "3", "4"); // duplicate case - duplicate removed rpcUpdateSelection(new String[] { "2" }, new String[] { "2", "3" }); - Assert.assertEquals(10, listenerCount.get()); + assertEquals(10, listenerCount.get()); assertSelectionOrder("6", "4"); // duplicate case - duplicate removed rpcUpdateSelection(new String[] { "6", "8" }, new String[] { "6" }); - Assert.assertEquals(11, listenerCount.get()); + assertEquals(11, listenerCount.get()); assertSelectionOrder("6", "4", "8"); verifyValueChangeEvents(); } @@ -237,19 +242,18 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { public void getValue() { selectToTest.select("1"); - Assert.assertEquals(Collections.singleton("1"), - selectToTest.getValue()); + assertEquals(Collections.singleton("1"), selectToTest.getValue()); selectToTest.deselectAll(); LinkedHashSet<String> set = new LinkedHashSet<>(); set.add("1"); set.add("5"); selectToTest.select(set.toArray(new String[2])); - Assert.assertEquals(set, selectToTest.getValue()); + assertEquals(set, selectToTest.getValue()); set.add("3"); selectToTest.select("3"); - Assert.assertEquals(set, selectToTest.getValue()); + assertEquals(set, selectToTest.getValue()); verifyValueChangeEvents(); } @@ -276,7 +280,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { } }; - Assert.assertSame(set, select.getValue()); + assertSame(set, select.getValue()); verifyValueChangeEvents(); } @@ -284,7 +288,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { public void setValue() { selectToTest.setValue(Collections.singleton("1")); - Assert.assertEquals(Collections.singleton("1"), + assertEquals(Collections.singleton("1"), selectToTest.getSelectedItems()); Set<String> set = new LinkedHashSet<>(); @@ -292,7 +296,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { set.add("3"); selectToTest.setValue(set); - Assert.assertEquals(set, selectToTest.getSelectedItems()); + assertEquals(set, selectToTest.getSelectedItems()); verifyValueChangeEvents(); } @@ -352,18 +356,18 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { AtomicReference<ValueChangeEvent<?>> event = new AtomicReference<>(); Registration actualRegistration = select.addValueChangeListener(evt -> { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(evt); }); - Assert.assertSame(registration, actualRegistration); + assertSame(registration, actualRegistration); selectionListener.get().selectionChange(new MultiSelectionEvent<>( select, Mockito.mock(Set.class), true)); - Assert.assertEquals(select, event.get().getComponent()); - Assert.assertEquals(set, event.get().getValue()); - Assert.assertTrue(event.get().isUserOriginated()); + assertEquals(select, event.get().getComponent()); + assertEquals(set, event.get().getValue()); + assertTrue(event.get().isUserOriginated()); } private void rpcSelect(String... keysToSelect) { @@ -388,16 +392,16 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> { } private void assertSelectionOrder(String... selectionOrder) { - Assert.assertEquals(Arrays.asList(selectionOrder), + assertEquals(Arrays.asList(selectionOrder), new ArrayList<>(selectToTest.getSelectedItems())); } private void verifyValueChangeEvents() { if (oldValues.size() > 0) { - Assert.assertTrue(oldValues.get(0).isEmpty()); - Assert.assertEquals(values.size(), oldValues.size()); + assertTrue(oldValues.get(0).isEmpty()); + assertEquals(values.size(), oldValues.size()); for (int i = 0; i < oldValues.size() - 1; i++) { - Assert.assertEquals(values.get(i), oldValues.get(i + 1)); + assertEquals(values.get(i), oldValues.get(i + 1)); } } } diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java index 5796f01cc5..d96793bf8e 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java @@ -17,6 +17,8 @@ package com.vaadin.ui; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.util.ArrayList; @@ -27,7 +29,6 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; import org.jsoup.nodes.Element; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -190,10 +191,10 @@ public class AbstractSingleSelectTest { public void getValue() { listing.setSelectedItem(PERSON_B); - Assert.assertEquals(PERSON_B, listing.getValue()); + assertEquals(PERSON_B, listing.getValue()); listing.setValue(null); - Assert.assertNull(listing.getValue()); + assertNull(listing.getValue()); verifyValueChanges(); } @@ -205,22 +206,22 @@ public class AbstractSingleSelectTest { Mockito.when(select.getSelectedItem()).thenReturn(selected); Mockito.doCallRealMethod().when(select).getValue(); - Assert.assertSame(selected.get(), select.getValue()); + assertSame(selected.get(), select.getValue()); selected = Optional.empty(); Mockito.when(select.getSelectedItem()).thenReturn(selected); - Assert.assertNull(select.getValue()); + assertNull(select.getValue()); } @Test public void setValue() { listing.setValue(PERSON_C); - Assert.assertEquals(PERSON_C, listing.getSelectedItem().get()); + assertEquals(PERSON_C, listing.getSelectedItem().get()); listing.setValue(null); - Assert.assertFalse(listing.getSelectedItem().isPresent()); + assertFalse(listing.getSelectedItem().isPresent()); verifyValueChanges(); } @@ -281,18 +282,18 @@ public class AbstractSingleSelectTest { AtomicReference<ValueChangeEvent<?>> event = new AtomicReference<>(); Registration actualRegistration = select.addValueChangeListener(evt -> { - Assert.assertNull(event.get()); + assertNull(event.get()); event.set(evt); }); - Assert.assertSame(registration, actualRegistration); + assertSame(registration, actualRegistration); selectionListener.get().selectionChange( new SingleSelectionEvent<>(select, value, true)); - Assert.assertEquals(select, event.get().getComponent()); - Assert.assertEquals(value, event.get().getOldValue()); - Assert.assertEquals(value, event.get().getValue()); - Assert.assertTrue(event.get().isUserOriginated()); + assertEquals(select, event.get().getComponent()); + assertEquals(value, event.get().getOldValue()); + assertEquals(value, event.get().getValue()); + assertTrue(event.get().isUserOriginated()); } private void verifyValueChanges() { diff --git a/server/src/test/java/com/vaadin/ui/CheckBoxTest.java b/server/src/test/java/com/vaadin/ui/CheckBoxTest.java index 539d6fbf63..d2c280f12d 100644 --- a/server/src/test/java/com/vaadin/ui/CheckBoxTest.java +++ b/server/src/test/java/com/vaadin/ui/CheckBoxTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.ServerRpcManager; @@ -29,16 +31,16 @@ public class CheckBoxTest { @Test public void initiallyFalse() { CheckBox cb = new CheckBox(); - Assert.assertFalse(cb.getValue()); + assertFalse(cb.getValue()); } @Test public void testSetValue() { CheckBox cb = new CheckBox(); cb.setValue(true); - Assert.assertTrue(cb.getValue()); + assertTrue(cb.getValue()); cb.setValue(false); - Assert.assertFalse(cb.getValue()); + assertFalse(cb.getValue()); } @Test @@ -53,12 +55,12 @@ public class CheckBoxTest { ComponentTest.syncToClient(cb); ServerRpcManager.getRpcProxy(cb, CheckBoxServerRpc.class) .setChecked(true, new MouseEventDetails()); - Assert.assertTrue(userOriginated.get()); + assertTrue(userOriginated.get()); userOriginated.set(false); ComponentTest.syncToClient(cb); ServerRpcManager.getRpcProxy(cb, CheckBoxServerRpc.class) .setChecked(false, new MouseEventDetails()); - Assert.assertTrue(userOriginated.get()); + assertTrue(userOriginated.get()); } @Test @@ -71,10 +73,10 @@ public class CheckBoxTest { userOriginated.set(e.isUserOriginated()); }); cb.setValue(true); - Assert.assertFalse(userOriginated.get()); + assertFalse(userOriginated.get()); userOriginated.set(true); cb.setValue(false); - Assert.assertFalse(userOriginated.get()); + assertFalse(userOriginated.get()); } @Test(expected = NullPointerException.class) diff --git a/server/src/test/java/com/vaadin/ui/ComponentTest.java b/server/src/test/java/com/vaadin/ui/ComponentTest.java index 58a8829d5e..23e15e1bff 100644 --- a/server/src/test/java/com/vaadin/ui/ComponentTest.java +++ b/server/src/test/java/com/vaadin/ui/ComponentTest.java @@ -15,12 +15,12 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; + import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashSet; -import org.junit.Assert; - import com.vaadin.server.ClientConnector; import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.ServerRpcManager; @@ -111,8 +111,7 @@ public class ComponentTest { JsonObject encodeState = connector.encodeState(); // Collect to HashSet so that order doesn't matter - Assert.assertEquals(message, - new HashSet<>(Arrays.asList(expectedProperties)), + assertEquals(message, new HashSet<>(Arrays.asList(expectedProperties)), new HashSet<>(Arrays.asList(encodeState.keys()))); } diff --git a/server/src/test/java/com/vaadin/ui/CustomFieldTest.java b/server/src/test/java/com/vaadin/ui/CustomFieldTest.java index 94636dcdc0..e193809c1a 100644 --- a/server/src/test/java/com/vaadin/ui/CustomFieldTest.java +++ b/server/src/test/java/com/vaadin/ui/CustomFieldTest.java @@ -15,10 +15,14 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.Iterator; import java.util.NoSuchElementException; -import org.junit.Assert; import org.junit.Test; public class CustomFieldTest { @@ -54,10 +58,10 @@ public class CustomFieldTest { // iterator() can't do it even though it should... field.getContent(); Iterator<Component> iterator = field.iterator(); - Assert.assertNotNull(iterator); - Assert.assertTrue(iterator.hasNext()); - Assert.assertEquals(field.button, iterator.next()); - Assert.assertFalse(iterator.hasNext()); + assertNotNull(iterator); + assertTrue(iterator.hasNext()); + assertEquals(field.button, iterator.next()); + assertFalse(iterator.hasNext()); iterator.next(); } } diff --git a/server/src/test/java/com/vaadin/ui/DateFieldConstructorTest.java b/server/src/test/java/com/vaadin/ui/DateFieldConstructorTest.java index 6fa83f14d0..7bd7aeda24 100644 --- a/server/src/test/java/com/vaadin/ui/DateFieldConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/DateFieldConstructorTest.java @@ -15,34 +15,37 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import java.time.LocalDate; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; import com.vaadin.shared.ui.datefield.DateResolution; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; public class DateFieldConstructorTest { @Test public void initiallyEmpty() { DateField dateField = new DateField(); - Assert.assertTrue(dateField.isEmpty()); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); + assertTrue(dateField.isEmpty()); + assertEquals(DateResolution.DAY, dateField.getResolution()); } @Test public void testValueConstructor_emptyAfterClear() { DateField dateField = new DateField(null, LocalDate.now()); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); - Assert.assertFalse(dateField.isEmpty()); + assertEquals(DateResolution.DAY, dateField.getResolution()); + assertFalse(dateField.isEmpty()); dateField.clear(); - Assert.assertTrue(dateField.isEmpty()); + assertTrue(dateField.isEmpty()); } @Test @@ -50,7 +53,7 @@ public class DateFieldConstructorTest { HasValue.ValueChangeListener valueChangeListener = Mockito .mock(HasValue.ValueChangeListener.class); DateField dateField = new DateField(valueChangeListener); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); + assertEquals(DateResolution.DAY, dateField.getResolution()); dateField.setValue(LocalDate.now()); @@ -65,7 +68,7 @@ public class DateFieldConstructorTest { .mock(HasValue.ValueChangeListener.class); DateField dateField = new DateField("Caption", LocalDate.now(), valueChangeListener); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); + assertEquals(DateResolution.DAY, dateField.getResolution()); verify(valueChangeListener, never()) .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); diff --git a/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java index e67d7bde13..f50141df66 100644 --- a/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java +++ b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java @@ -3,10 +3,11 @@ package com.vaadin.ui; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.time.LocalDate; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -33,14 +34,14 @@ public class DateFieldTestCase { public void rangeStartIsAcceptedAsValue() { dateField.setRangeStart(date); dateField.setValue(date); - Assert.assertNull(dateField.getComponentError()); + assertNull(dateField.getComponentError()); } @Test public void belowRangeStartIsNotAcceptedAsValue() { dateField.setRangeStart(date); dateField.setValue(date.minusDays(1)); - Assert.assertNotNull(dateField.getComponentError()); + assertNotNull(dateField.getComponentError()); } @Test @@ -54,13 +55,13 @@ public class DateFieldTestCase { public void rangeEndIsAcceptedAsValue() { dateField.setRangeEnd(date); dateField.setValue(date); - Assert.assertNull(dateField.getComponentError()); + assertNull(dateField.getComponentError()); } @Test public void aboveRangeEndIsNotAcceptedAsValue() { dateField.setRangeEnd(date); dateField.setValue(date.plusDays(1)); - Assert.assertNotNull(dateField.getComponentError()); + assertNotNull(dateField.getComponentError()); } } diff --git a/server/src/test/java/com/vaadin/ui/DateTimeFieldConstructorTest.java b/server/src/test/java/com/vaadin/ui/DateTimeFieldConstructorTest.java index 90a452942e..d4675556c3 100644 --- a/server/src/test/java/com/vaadin/ui/DateTimeFieldConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/DateTimeFieldConstructorTest.java @@ -15,37 +15,38 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import java.time.LocalDateTime; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; import com.vaadin.shared.ui.datefield.DateTimeResolution; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; public class DateTimeFieldConstructorTest { @Test public void initiallyEmpty() { DateTimeField dateTimeField = new DateTimeField(); - Assert.assertTrue(dateTimeField.isEmpty()); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertTrue(dateTimeField.isEmpty()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); } @Test public void testValueConstructor_emptyAfterClear() { DateTimeField dateTimeField = new DateTimeField(null, LocalDateTime.now()); - Assert.assertFalse(dateTimeField.isEmpty()); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertFalse(dateTimeField.isEmpty()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); dateTimeField.clear(); - Assert.assertTrue(dateTimeField.isEmpty()); + assertTrue(dateTimeField.isEmpty()); } @Test @@ -53,8 +54,7 @@ public class DateTimeFieldConstructorTest { HasValue.ValueChangeListener valueChangeListener = Mockito .mock(HasValue.ValueChangeListener.class); DateTimeField dateTimeField = new DateTimeField(valueChangeListener); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); dateTimeField.setValue(LocalDateTime.now()); @@ -69,8 +69,7 @@ public class DateTimeFieldConstructorTest { .mock(HasValue.ValueChangeListener.class); DateTimeField dateTimeField = new DateTimeField("Caption", LocalDateTime.now(), valueChangeListener); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); verify(valueChangeListener, never()) .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); diff --git a/server/src/test/java/com/vaadin/ui/HorizontalSplitPanelTest.java b/server/src/test/java/com/vaadin/ui/HorizontalSplitPanelTest.java index fcdb0a85ad..2eb3ba5f3c 100644 --- a/server/src/test/java/com/vaadin/ui/HorizontalSplitPanelTest.java +++ b/server/src/test/java/com/vaadin/ui/HorizontalSplitPanelTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.shared.ui.splitpanel.HorizontalSplitPanelState; @@ -24,7 +25,7 @@ public class HorizontalSplitPanelTest { @Test public void primaryStyleName() { - Assert.assertEquals(new HorizontalSplitPanelState().primaryStyleName, + assertEquals(new HorizontalSplitPanelState().primaryStyleName, new HorizontalSplitPanel().getPrimaryStyleName()); } } diff --git a/server/src/test/java/com/vaadin/ui/InlineDateFieldConstructorTest.java b/server/src/test/java/com/vaadin/ui/InlineDateFieldConstructorTest.java index 936efcdc03..1bf518460f 100644 --- a/server/src/test/java/com/vaadin/ui/InlineDateFieldConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/InlineDateFieldConstructorTest.java @@ -15,35 +15,37 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import java.time.LocalDate; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; import com.vaadin.shared.ui.datefield.DateResolution; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - public class InlineDateFieldConstructorTest { @Test public void initiallyEmpty() { InlineDateField dateField = new InlineDateField(); - Assert.assertTrue(dateField.isEmpty()); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); + assertTrue(dateField.isEmpty()); + assertEquals(DateResolution.DAY, dateField.getResolution()); } @Test public void testValueConstructor_emptyAfterClear() { InlineDateField dateField = new InlineDateField(null, LocalDate.now()); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); - Assert.assertFalse(dateField.isEmpty()); + assertEquals(DateResolution.DAY, dateField.getResolution()); + assertFalse(dateField.isEmpty()); dateField.clear(); - Assert.assertTrue(dateField.isEmpty()); + assertTrue(dateField.isEmpty()); } @Test @@ -51,7 +53,7 @@ public class InlineDateFieldConstructorTest { HasValue.ValueChangeListener valueChangeListener = Mockito .mock(HasValue.ValueChangeListener.class); InlineDateField dateField = new InlineDateField(valueChangeListener); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); + assertEquals(DateResolution.DAY, dateField.getResolution()); dateField.setValue(LocalDate.now()); @@ -66,7 +68,7 @@ public class InlineDateFieldConstructorTest { .mock(HasValue.ValueChangeListener.class); InlineDateField dateField = new InlineDateField("Caption", LocalDate.now(), valueChangeListener); - Assert.assertEquals(DateResolution.DAY, dateField.getResolution()); + assertEquals(DateResolution.DAY, dateField.getResolution()); verify(valueChangeListener, never()) .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); diff --git a/server/src/test/java/com/vaadin/ui/InlineDateTimeFieldConstructorTest.java b/server/src/test/java/com/vaadin/ui/InlineDateTimeFieldConstructorTest.java index 6a2aaca7aa..0c900276b6 100644 --- a/server/src/test/java/com/vaadin/ui/InlineDateTimeFieldConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/InlineDateTimeFieldConstructorTest.java @@ -15,38 +15,38 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import java.time.LocalDateTime; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; import com.vaadin.shared.ui.datefield.DateTimeResolution; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - public class InlineDateTimeFieldConstructorTest { @Test public void initiallyEmpty() { InlineDateTimeField dateTimeField = new InlineDateTimeField(); - Assert.assertTrue(dateTimeField.isEmpty()); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertTrue(dateTimeField.isEmpty()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); } @Test public void testValueConstructor_emptyAfterClear() { InlineDateTimeField dateTimeField = new InlineDateTimeField(null, LocalDateTime.now()); - Assert.assertFalse(dateTimeField.isEmpty()); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertFalse(dateTimeField.isEmpty()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); dateTimeField.clear(); - Assert.assertTrue(dateTimeField.isEmpty()); + assertTrue(dateTimeField.isEmpty()); } @Test @@ -55,8 +55,7 @@ public class InlineDateTimeFieldConstructorTest { .mock(HasValue.ValueChangeListener.class); InlineDateTimeField dateTimeField = new InlineDateTimeField( valueChangeListener); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); dateTimeField.setValue(LocalDateTime.now()); @@ -71,8 +70,7 @@ public class InlineDateTimeFieldConstructorTest { .mock(HasValue.ValueChangeListener.class); InlineDateTimeField dateTimeField = new InlineDateTimeField("Caption", LocalDateTime.now(), valueChangeListener); - Assert.assertEquals(DateTimeResolution.MINUTE, - dateTimeField.getResolution()); + assertEquals(DateTimeResolution.MINUTE, dateTimeField.getResolution()); verify(valueChangeListener, never()) .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); diff --git a/server/src/test/java/com/vaadin/ui/LabelTest.java b/server/src/test/java/com/vaadin/ui/LabelTest.java index 5bf082f659..e98c4a0d7b 100644 --- a/server/src/test/java/com/vaadin/ui/LabelTest.java +++ b/server/src/test/java/com/vaadin/ui/LabelTest.java @@ -1,25 +1,26 @@ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class LabelTest { @Test public void emptyLabelValue() { - Assert.assertEquals("", new Label().getValue()); + assertEquals("", new Label().getValue()); } @Test public void labelInitialValue() { - Assert.assertEquals("initial", new Label("initial").getValue()); + assertEquals("initial", new Label("initial").getValue()); } @Test public void labelSetValue() { Label label = new Label(); label.setValue("foo"); - Assert.assertEquals("foo", label.getValue()); + assertEquals("foo", label.getValue()); } } diff --git a/server/src/test/java/com/vaadin/ui/PasswordFieldConstructorTest.java b/server/src/test/java/com/vaadin/ui/PasswordFieldConstructorTest.java index d6f8cc2a5c..a9ad4bbbe5 100644 --- a/server/src/test/java/com/vaadin/ui/PasswordFieldConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/PasswordFieldConstructorTest.java @@ -15,29 +15,31 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; public class PasswordFieldConstructorTest { @Test public void initiallyEmpty() { PasswordField passwordField = new PasswordField(); - Assert.assertTrue(passwordField.isEmpty()); + assertTrue(passwordField.isEmpty()); } @Test public void testValueConstructor_emptyAfterClear() { PasswordField passwordField = new PasswordField(null, "foobar"); - Assert.assertFalse(passwordField.isEmpty()); + assertFalse(passwordField.isEmpty()); passwordField.clear(); - Assert.assertTrue(passwordField.isEmpty()); + assertTrue(passwordField.isEmpty()); } @Test diff --git a/server/src/test/java/com/vaadin/ui/PushConfigurationTransportTest.java b/server/src/test/java/com/vaadin/ui/PushConfigurationTransportTest.java index 6111ccc65b..8841bc70bc 100644 --- a/server/src/test/java/com/vaadin/ui/PushConfigurationTransportTest.java +++ b/server/src/test/java/com/vaadin/ui/PushConfigurationTransportTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.server.VaadinRequest; @@ -38,14 +41,13 @@ public class PushConfigurationTransportTest { }; for (Transport transport : Transport.values()) { ui.getPushConfiguration().setTransport(transport); - Assert.assertEquals(ui.getPushConfiguration().getTransport(), - transport); + assertEquals(ui.getPushConfiguration().getTransport(), transport); if (transport == Transport.WEBSOCKET_XHR) { - Assert.assertTrue(ui + assertTrue(ui .getState().pushConfiguration.alwaysUseXhrForServerRequests); } else { - Assert.assertFalse(ui + assertFalse(ui .getState().pushConfiguration.alwaysUseXhrForServerRequests); } } diff --git a/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java b/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java index b87d459517..fd2350685a 100644 --- a/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java +++ b/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -42,7 +45,7 @@ public class RadioButtonGroupTest { radioButtonGroup.addSelectionListener(event -> { listenerCount.incrementAndGet(); - Assert.assertFalse(event.isUserOriginated()); + assertFalse(event.isUserOriginated()); }); radioButtonGroup.setValue("First"); @@ -51,7 +54,7 @@ public class RadioButtonGroupTest { radioButtonGroup.setValue(null); radioButtonGroup.setValue(null); - Assert.assertEquals(3, listenerCount.get()); + assertEquals(3, listenerCount.get()); } @Test @@ -60,7 +63,7 @@ public class RadioButtonGroupTest { radioButtonGroup.addSelectionListener(event -> { listenerCount.incrementAndGet(); - Assert.assertTrue(event.isUserOriginated()); + assertTrue(event.isUserOriginated()); }); SelectionServerRpc rpc = ServerRpcManager.getRpcProxy(radioButtonGroup, @@ -70,7 +73,7 @@ public class RadioButtonGroupTest { rpc.select(getItemKey("Second")); rpc.deselect(getItemKey("Second")); - Assert.assertEquals(3, listenerCount.get()); + assertEquals(3, listenerCount.get()); } private String getItemKey(String dataObject) { diff --git a/server/src/test/java/com/vaadin/ui/RichTextAreaConstructorTest.java b/server/src/test/java/com/vaadin/ui/RichTextAreaConstructorTest.java index b77690594c..212ce2da9f 100644 --- a/server/src/test/java/com/vaadin/ui/RichTextAreaConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/RichTextAreaConstructorTest.java @@ -15,29 +15,31 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; public class RichTextAreaConstructorTest { @Test public void initiallyEmpty() { RichTextArea richTextArea = new RichTextArea(); - Assert.assertTrue(richTextArea.isEmpty()); + assertTrue(richTextArea.isEmpty()); } @Test public void testValueConstructor_emptyAfterClear() { RichTextArea richTextArea = new RichTextArea(null, "foobar"); - Assert.assertFalse(richTextArea.isEmpty()); + assertFalse(richTextArea.isEmpty()); richTextArea.clear(); - Assert.assertTrue(richTextArea.isEmpty()); + assertTrue(richTextArea.isEmpty()); } @Test diff --git a/server/src/test/java/com/vaadin/ui/RichTextAreaTest.java b/server/src/test/java/com/vaadin/ui/RichTextAreaTest.java index 7c042df931..3c27ae9820 100644 --- a/server/src/test/java/com/vaadin/ui/RichTextAreaTest.java +++ b/server/src/test/java/com/vaadin/ui/RichTextAreaTest.java @@ -18,8 +18,10 @@ package com.vaadin.ui; import static com.vaadin.ui.ComponentTest.isDirty; import static com.vaadin.ui.ComponentTest.syncToClient; import static com.vaadin.ui.ComponentTest.updateDiffState; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import org.junit.Assert; import org.junit.Test; import com.vaadin.server.ClientConnector; @@ -33,7 +35,7 @@ public class RichTextAreaTest { @Test public void initiallyEmpty() { RichTextArea tf = new RichTextArea(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } @Test @@ -41,7 +43,7 @@ public class RichTextAreaTest { RichTextArea tf = new RichTextArea(); tf.setReadOnly(true); tf.setValue("foo"); - Assert.assertEquals("foo", tf.getValue()); + assertEquals("foo", tf.getValue()); } @Test @@ -64,8 +66,8 @@ public class RichTextAreaTest { // The real value will be sent back as long as the field is marked as // dirty and diffstate contains what the client has - Assert.assertEquals("foo", getDiffStateString(rta, "value")); - Assert.assertTrue("Component should be marked dirty", isDirty(rta)); + assertEquals("foo", getDiffStateString(rta, "value")); + assertTrue("Component should be marked dirty", isDirty(rta)); } @Test @@ -78,7 +80,7 @@ public class RichTextAreaTest { updateDiffState(rta); ServerRpcManager.getRpcProxy(rta, RichTextAreaServerRpc.class) .setText("foo"); - Assert.assertEquals("foo", getDiffStateString(rta, "value")); + assertEquals("foo", getDiffStateString(rta, "value")); } private String getDiffStateString(ClientConnector connector, String key) { @@ -92,7 +94,7 @@ public class RichTextAreaTest { tf.setValue("bar"); tf.setReadOnly(true); tf.setValue("foo", true); - Assert.assertEquals("bar", tf.getValue()); + assertEquals("bar", tf.getValue()); } @Test(expected = NullPointerException.class) @@ -105,9 +107,9 @@ public class RichTextAreaTest { public void emptyAfterClear() { RichTextArea tf = new RichTextArea(); tf.setValue("foobar"); - Assert.assertFalse(tf.isEmpty()); + assertFalse(tf.isEmpty()); tf.clear(); - Assert.assertTrue(tf.isEmpty()); + assertTrue(tf.isEmpty()); } } diff --git a/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java b/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java index c090d86efe..0c89d53051 100644 --- a/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java @@ -15,29 +15,31 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; public class TextAreaConstructorTest { @Test public void initiallyEmpty() { TextArea textArea = new TextArea(); - Assert.assertTrue(textArea.isEmpty()); + assertTrue(textArea.isEmpty()); } @Test public void testValueConstructor_emptyAfterClear() { TextArea textArea = new TextArea(null, "foobar"); - Assert.assertFalse(textArea.isEmpty()); + assertFalse(textArea.isEmpty()); textArea.clear(); - Assert.assertTrue(textArea.isEmpty()); + assertTrue(textArea.isEmpty()); } @Test diff --git a/server/src/test/java/com/vaadin/ui/TextAreaTest.java b/server/src/test/java/com/vaadin/ui/TextAreaTest.java index 6c3d5fecd5..110fa86eff 100644 --- a/server/src/test/java/com/vaadin/ui/TextAreaTest.java +++ b/server/src/test/java/com/vaadin/ui/TextAreaTest.java @@ -15,23 +15,25 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class TextAreaTest { @Test public void initiallyEmpty() { TextArea textArea = new TextArea(); - Assert.assertTrue(textArea.isEmpty()); + assertTrue(textArea.isEmpty()); } @Test public void emptyAfterClear() { TextArea textArea = new TextArea(); textArea.setValue("foobar"); - Assert.assertFalse(textArea.isEmpty()); + assertFalse(textArea.isEmpty()); textArea.clear(); - Assert.assertTrue(textArea.isEmpty()); + assertTrue(textArea.isEmpty()); } } diff --git a/server/src/test/java/com/vaadin/ui/TextFieldConstructorTest.java b/server/src/test/java/com/vaadin/ui/TextFieldConstructorTest.java index 3bcb457fec..d8b5e986cc 100644 --- a/server/src/test/java/com/vaadin/ui/TextFieldConstructorTest.java +++ b/server/src/test/java/com/vaadin/ui/TextFieldConstructorTest.java @@ -15,29 +15,31 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + import org.junit.Test; import org.mockito.Mockito; import com.vaadin.data.HasValue; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; public class TextFieldConstructorTest { @Test public void initiallyEmpty() { TextField textField = new TextField(); - Assert.assertTrue(textField.isEmpty()); + assertTrue(textField.isEmpty()); } @Test public void testValueConstructor_emptyAfterClear() { TextField textField = new TextField(null, "foobar"); - Assert.assertFalse(textField.isEmpty()); + assertFalse(textField.isEmpty()); textField.clear(); - Assert.assertTrue(textField.isEmpty()); + assertTrue(textField.isEmpty()); } @Test diff --git a/server/src/test/java/com/vaadin/ui/UIInitRefreshTest.java b/server/src/test/java/com/vaadin/ui/UIInitRefreshTest.java index 65bbc59a5b..a1b8394c7b 100644 --- a/server/src/test/java/com/vaadin/ui/UIInitRefreshTest.java +++ b/server/src/test/java/com/vaadin/ui/UIInitRefreshTest.java @@ -15,11 +15,14 @@ */ package com.vaadin.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.Locale; import org.easymock.EasyMock; import org.easymock.IMocksControl; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -47,36 +50,36 @@ public class UIInitRefreshTest { initCalled = true; - Assert.assertEquals("foo", getPage().getUriFragment()); - Assert.assertEquals(100, getPage().getBrowserWindowWidth()); - Assert.assertEquals(100, getPage().getBrowserWindowHeight()); + assertEquals("foo", getPage().getUriFragment()); + assertEquals(100, getPage().getBrowserWindowWidth()); + assertEquals(100, getPage().getBrowserWindowHeight()); - Assert.assertFalse(fragmentChangeCalled); - Assert.assertFalse(browserWindowResizeCalled); + assertFalse(fragmentChangeCalled); + assertFalse(browserWindowResizeCalled); } @Override protected void refresh(VaadinRequest request) { refreshCalled = true; - Assert.assertEquals("bar", getPage().getUriFragment()); - Assert.assertEquals(200, getPage().getBrowserWindowWidth()); - Assert.assertEquals(200, getPage().getBrowserWindowHeight()); + assertEquals("bar", getPage().getUriFragment()); + assertEquals(200, getPage().getBrowserWindowWidth()); + assertEquals(200, getPage().getBrowserWindowHeight()); - Assert.assertFalse(fragmentChangeCalled); - Assert.assertFalse(browserWindowResizeCalled); + assertFalse(fragmentChangeCalled); + assertFalse(browserWindowResizeCalled); } @Override public void browserWindowResized(BrowserWindowResizeEvent event) { - Assert.assertEquals(200, event.getWidth()); - Assert.assertEquals(200, event.getHeight()); + assertEquals(200, event.getWidth()); + assertEquals(200, event.getHeight()); browserWindowResizeCalled = true; } @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { - Assert.assertEquals("bar", event.getUriFragment()); + assertEquals("bar", event.getUriFragment()); fragmentChangeCalled = true; } } @@ -117,14 +120,14 @@ public class UIInitRefreshTest { ui.setSession(session); ui.doInit(initRequest, 0, ""); - Assert.assertTrue(initCalled); - Assert.assertFalse(fragmentChangeCalled); - Assert.assertFalse(browserWindowResizeCalled); + assertTrue(initCalled); + assertFalse(fragmentChangeCalled); + assertFalse(browserWindowResizeCalled); ui.doRefresh(reinitRequest); - Assert.assertTrue(refreshCalled); - Assert.assertTrue(fragmentChangeCalled); - Assert.assertTrue(browserWindowResizeCalled); + assertTrue(refreshCalled); + assertTrue(fragmentChangeCalled); + assertTrue(browserWindowResizeCalled); } } diff --git a/server/src/test/java/com/vaadin/ui/UITest.java b/server/src/test/java/com/vaadin/ui/UITest.java index 8bc3c98470..886dd38087 100644 --- a/server/src/test/java/com/vaadin/ui/UITest.java +++ b/server/src/test/java/com/vaadin/ui/UITest.java @@ -1,5 +1,9 @@ package com.vaadin.ui; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + import java.lang.ref.WeakReference; import java.util.Properties; import java.util.concurrent.ConcurrentLinkedQueue; @@ -9,7 +13,6 @@ import java.util.concurrent.locks.ReentrantLock; import javax.servlet.ServletConfig; -import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; @@ -132,16 +135,16 @@ public class UITest { if (websocketThread.isAlive() || uiDisconnectThread.isAlive()) { websocketThread.interrupt(); uiDisconnectThread.interrupt(); - Assert.fail("Threads are still running"); + fail("Threads are still running"); } if (!exceptions.isEmpty()) { for (Exception e : exceptions) { e.printStackTrace(); } - Assert.fail("There were exceptions in the threads"); + fail("There were exceptions in the threads"); } - Assert.assertNull(ui.getSession()); + assertNull(ui.getSession()); // PushConnection is set to null in another thread. We need to wait for // that to happen @@ -152,7 +155,7 @@ public class UITest { Thread.sleep(500); } - Assert.assertNull(ui.getPushConnection()); + assertNull(ui.getPushConnection()); } @@ -195,7 +198,7 @@ public class UITest { CurrentInstanceTest.waitUntilGarbageCollected(contentOnlyOnServer); // Should not clean references for connectors available in the browser // until the session is unlocked and we know if it has been moved - Assert.assertNotNull(contentSentToClient.get()); + assertNotNull(contentSentToClient.get()); session.unlock(); CurrentInstanceTest.waitUntilGarbageCollected(contentSentToClient); } diff --git a/server/src/test/java/com/vaadin/ui/VerticalSplitPanelTest.java b/server/src/test/java/com/vaadin/ui/VerticalSplitPanelTest.java index d77f307d49..bc732177f4 100644 --- a/server/src/test/java/com/vaadin/ui/VerticalSplitPanelTest.java +++ b/server/src/test/java/com/vaadin/ui/VerticalSplitPanelTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.shared.ui.splitpanel.VerticalSplitPanelState; @@ -24,7 +25,7 @@ public class VerticalSplitPanelTest { @Test public void primaryStyleName() { - Assert.assertEquals(new VerticalSplitPanelState().primaryStyleName, + assertEquals(new VerticalSplitPanelState().primaryStyleName, new VerticalSplitPanel().getPrimaryStyleName()); } } diff --git a/server/src/test/java/com/vaadin/ui/components/grid/StaticSectionTest.java b/server/src/test/java/com/vaadin/ui/components/grid/StaticSectionTest.java index 1223cfaef8..8ae35e72a3 100644 --- a/server/src/test/java/com/vaadin/ui/components/grid/StaticSectionTest.java +++ b/server/src/test/java/com/vaadin/ui/components/grid/StaticSectionTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.ui.components.grid; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.HashSet; import org.jsoup.nodes.Element; import org.jsoup.parser.Tag; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -129,9 +130,9 @@ public class StaticSectionTest { staticRow.writeDesign(container, null); - Assert.assertEquals(2, container.children().size()); - Assert.assertEquals("col1,col2", container.child(0).attr("column-ids")); - Assert.assertEquals("col3", container.child(1).attr("column-ids")); + assertEquals(2, container.children().size()); + assertEquals("col1,col2", container.child(0).attr("column-ids")); + assertEquals("col3", container.child(1).attr("column-ids")); } } diff --git a/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java b/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java index 769a02dedc..928eb3acb6 100644 --- a/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java +++ b/server/src/test/java/com/vaadin/ui/declarative/DesignTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.ui.declarative; +import static org.junit.Assert.assertEquals; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.Field; @@ -27,7 +29,6 @@ import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; import org.jsoup.nodes.TextNode; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.Component; @@ -62,7 +63,7 @@ public class DesignTest { String cp1251Html = getHtml(); setUtf8Charset(); String utf8Html = getHtml(); - Assert.assertEquals( + assertEquals( "Html written with UTF-8 as default encoding " + "differs from html written with cp1251 encoding", cp1251Html, utf8Html); @@ -74,7 +75,7 @@ public class DesignTest { IllegalArgumentException, IllegalAccessException { setCp1251Charset(); String cp1251Html = getHtml(); - Assert.assertEquals( + assertEquals( "Non ascii string parsed from serialized HTML " + "differs from expected", NON_ASCII_STRING, getHtmlLabelValue(cp1251Html)); @@ -86,7 +87,7 @@ public class DesignTest { IllegalArgumentException, IllegalAccessException { setUtf8Charset(); String utf8 = getHtml(); - Assert.assertEquals( + assertEquals( "Non ascii string parsed from serialized HTML " + "differs from expected", NON_ASCII_STRING, getHtmlLabelValue(utf8)); diff --git a/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java b/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java index dd4cc3f543..74b8ce7e6d 100644 --- a/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java +++ b/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.util; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; import java.lang.ref.WeakReference; import java.lang.reflect.Field; @@ -27,7 +30,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.easymock.EasyMock; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -52,8 +54,7 @@ public class CurrentInstanceTest { @Test public void testClearedAfterRemove() throws Exception { CurrentInstance.set(CurrentInstanceTest.class, this); - Assert.assertEquals(this, - CurrentInstance.get(CurrentInstanceTest.class)); + assertEquals(this, CurrentInstance.get(CurrentInstanceTest.class)); CurrentInstance.set(CurrentInstanceTest.class, null); assertCleared(); @@ -62,8 +63,7 @@ public class CurrentInstanceTest { @Test public void testClearedWithClearAll() throws Exception { CurrentInstance.set(CurrentInstanceTest.class, this); - Assert.assertEquals(this, - CurrentInstance.get(CurrentInstanceTest.class)); + assertEquals(this, CurrentInstance.get(CurrentInstanceTest.class)); CurrentInstance.clearAll(); assertCleared(); @@ -71,7 +71,7 @@ public class CurrentInstanceTest { private void assertCleared() throws SecurityException, NoSuchFieldException, IllegalAccessException { - Assert.assertNull(getInternalCurrentInstanceVariable().get()); + assertNull(getInternalCurrentInstanceVariable().get()); } private ThreadLocal<Map<Class<?>, CurrentInstance>> getInternalCurrentInstanceVariable() @@ -156,7 +156,7 @@ public class CurrentInstanceTest { CurrentInstance.restoreInstances(previous); - Assert.assertNull(VaadinSession.getCurrent()); + assertNull(VaadinSession.getCurrent()); } public static void waitUntilGarbageCollected(WeakReference<?> ref) @@ -168,7 +168,7 @@ public class CurrentInstanceTest { } Thread.sleep(100); } - Assert.fail("Value was not garbage collected."); + fail("Value was not garbage collected."); } @Test @@ -177,10 +177,10 @@ public class CurrentInstanceTest { CurrentInstance.clearAll(); CurrentInstance.set(CurrentInstanceTest.class, this); - Assert.assertNotNull(CurrentInstance.get(CurrentInstanceTest.class)); + assertNotNull(CurrentInstance.get(CurrentInstanceTest.class)); Callable<Void> runnable = () -> { - Assert.assertNull(CurrentInstance.get(CurrentInstanceTest.class)); + assertNull(CurrentInstance.get(CurrentInstanceTest.class)); return null; }; ExecutorService service = Executors.newSingleThreadExecutor(); diff --git a/server/src/test/java/com/vaadin/util/EncodeUtilTest.java b/server/src/test/java/com/vaadin/util/EncodeUtilTest.java index 7bac539968..59efec59ad 100644 --- a/server/src/test/java/com/vaadin/util/EncodeUtilTest.java +++ b/server/src/test/java/com/vaadin/util/EncodeUtilTest.java @@ -15,18 +15,19 @@ */ package com.vaadin.util; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class EncodeUtilTest { @Test public void rfc5987Encode() { - Assert.assertEquals("A", EncodeUtil.rfc5987Encode("A")); - Assert.assertEquals("%20", EncodeUtil.rfc5987Encode(" ")); - Assert.assertEquals("%c3%a5", EncodeUtil.rfc5987Encode("å")); - Assert.assertEquals("%e6%97%a5", EncodeUtil.rfc5987Encode("日")); + assertEquals("A", EncodeUtil.rfc5987Encode("A")); + assertEquals("%20", EncodeUtil.rfc5987Encode(" ")); + assertEquals("%c3%a5", EncodeUtil.rfc5987Encode("å")); + assertEquals("%e6%97%a5", EncodeUtil.rfc5987Encode("日")); - Assert.assertEquals("A" + "%20" + "%c3%a5" + "%e6%97%a5", + assertEquals("A" + "%20" + "%c3%a5" + "%e6%97%a5", EncodeUtil.rfc5987Encode("A å日")); } } diff --git a/server/src/test/java/com/vaadin/util/ReflectToolsTest.java b/server/src/test/java/com/vaadin/util/ReflectToolsTest.java index 353bf0972c..6fba5d761f 100644 --- a/server/src/test/java/com/vaadin/util/ReflectToolsTest.java +++ b/server/src/test/java/com/vaadin/util/ReflectToolsTest.java @@ -15,39 +15,40 @@ */ package com.vaadin.util; +import static org.junit.Assert.assertSame; + import java.io.Serializable; -import org.junit.Assert; import org.junit.Test; public class ReflectToolsTest implements Serializable { @Test public void findCommonBaseType_sameType() { - Assert.assertSame(Number.class, + assertSame(Number.class, ReflectTools.findCommonBaseType(Number.class, Number.class)); } @Test public void findCommonBaseType_aExtendsB() { - Assert.assertSame(Number.class, + assertSame(Number.class, ReflectTools.findCommonBaseType(Integer.class, Number.class)); } @Test public void findCommonBaseType_bExtendsA() { - Assert.assertSame(Number.class, + assertSame(Number.class, ReflectTools.findCommonBaseType(Number.class, Integer.class)); } @Test public void findCommonBaseType_commonBase() { - Assert.assertSame(Number.class, + assertSame(Number.class, ReflectTools.findCommonBaseType(Double.class, Integer.class)); } @Test public void findCommonBaseType_noCommonBase() { - Assert.assertSame(Object.class, + assertSame(Object.class, ReflectTools.findCommonBaseType(String.class, Number.class)); } } diff --git a/shared/src/test/java/com/vaadin/shared/util/SharedUtilTest.java b/shared/src/test/java/com/vaadin/shared/util/SharedUtilTest.java index b468093da1..94530cd64c 100644 --- a/shared/src/test/java/com/vaadin/shared/util/SharedUtilTest.java +++ b/shared/src/test/java/com/vaadin/shared/util/SharedUtilTest.java @@ -1,11 +1,14 @@ package com.vaadin.shared.util; import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.util.Locale; -import org.junit.Assert; import org.junit.Test; public class SharedUtilTest { @@ -37,25 +40,23 @@ public class SharedUtilTest { @Test public void camelCaseToHumanReadable() { - Assert.assertEquals("First Name", + assertEquals("First Name", SharedUtil.camelCaseToHumanFriendly("firstName")); - Assert.assertEquals("First Name", + assertEquals("First Name", SharedUtil.camelCaseToHumanFriendly("first name")); - Assert.assertEquals("First Name2", + assertEquals("First Name2", SharedUtil.camelCaseToHumanFriendly("firstName2")); - Assert.assertEquals("First", - SharedUtil.camelCaseToHumanFriendly("first")); - Assert.assertEquals("First", - SharedUtil.camelCaseToHumanFriendly("First")); - Assert.assertEquals("Some XYZ Abbreviation", + assertEquals("First", SharedUtil.camelCaseToHumanFriendly("first")); + assertEquals("First", SharedUtil.camelCaseToHumanFriendly("First")); + assertEquals("Some XYZ Abbreviation", SharedUtil.camelCaseToHumanFriendly("SomeXYZAbbreviation")); // Javadoc examples - Assert.assertEquals("My Bean Container", + assertEquals("My Bean Container", SharedUtil.camelCaseToHumanFriendly("MyBeanContainer")); - Assert.assertEquals("Awesome URL Factory", + assertEquals("Awesome URL Factory", SharedUtil.camelCaseToHumanFriendly("AwesomeURLFactory")); - Assert.assertEquals("Some Uri Action", + assertEquals("Some Uri Action", SharedUtil.camelCaseToHumanFriendly("SomeUriAction")); } @@ -76,7 +77,7 @@ public class SharedUtilTest { private void assertCamelCaseSplit(String camelCaseString, String... parts) { String[] splitParts = SharedUtil.splitCamelCase(camelCaseString); - Assert.assertArrayEquals(parts, splitParts); + assertArrayEquals(parts, splitParts); } @Test @@ -84,26 +85,23 @@ public class SharedUtilTest { String s1 = "foo-bar-baz"; String s2 = "foo--bar"; - Assert.assertEquals("foobarbaz", SharedUtil.join(s1.split("-"), "")); - Assert.assertEquals("foo!bar!baz", SharedUtil.join(s1.split("-"), "!")); - Assert.assertEquals("foo!!bar!!baz", - SharedUtil.join(s1.split("-"), "!!")); + assertEquals("foobarbaz", SharedUtil.join(s1.split("-"), "")); + assertEquals("foo!bar!baz", SharedUtil.join(s1.split("-"), "!")); + assertEquals("foo!!bar!!baz", SharedUtil.join(s1.split("-"), "!!")); - Assert.assertEquals("foo##bar", SharedUtil.join(s2.split("-"), "#")); + assertEquals("foo##bar", SharedUtil.join(s2.split("-"), "#")); } @Test public void dashSeparatedToCamelCase() { - Assert.assertEquals(null, SharedUtil.dashSeparatedToCamelCase(null)); - Assert.assertEquals("", SharedUtil.dashSeparatedToCamelCase("")); - Assert.assertEquals("foo", SharedUtil.dashSeparatedToCamelCase("foo")); - Assert.assertEquals("fooBar", - SharedUtil.dashSeparatedToCamelCase("foo-bar")); - Assert.assertEquals("fooBar", - SharedUtil.dashSeparatedToCamelCase("foo--bar")); - Assert.assertEquals("fooBarBaz", + assertEquals(null, SharedUtil.dashSeparatedToCamelCase(null)); + assertEquals("", SharedUtil.dashSeparatedToCamelCase("")); + assertEquals("foo", SharedUtil.dashSeparatedToCamelCase("foo")); + assertEquals("fooBar", SharedUtil.dashSeparatedToCamelCase("foo-bar")); + assertEquals("fooBar", SharedUtil.dashSeparatedToCamelCase("foo--bar")); + assertEquals("fooBarBaz", SharedUtil.dashSeparatedToCamelCase("foo-bar-baz")); - Assert.assertEquals("fooBarBaz", + assertEquals("fooBarBaz", SharedUtil.dashSeparatedToCamelCase("foo-Bar-Baz")); } @@ -112,8 +110,8 @@ public class SharedUtilTest { Locale defaultLocale = Locale.getDefault(); try { Locale.setDefault(new Locale("tr", "TR")); - Assert.assertEquals("Integer", SharedUtil.capitalize("integer")); - Assert.assertEquals("I", SharedUtil.capitalize("i")); + assertEquals("Integer", SharedUtil.capitalize("integer")); + assertEquals("I", SharedUtil.capitalize("i")); } finally { Locale.setDefault(defaultLocale); } @@ -121,61 +119,56 @@ public class SharedUtilTest { @Test public void duplicatesInArray() { - Assert.assertTrue( - SharedUtil.containsDuplicates(new Object[] { "a", "a" })); - Assert.assertTrue( + assertTrue(SharedUtil.containsDuplicates(new Object[] { "a", "a" })); + assertTrue( SharedUtil.containsDuplicates(new Object[] { "a", "b", "a" })); - Assert.assertTrue(SharedUtil + assertTrue(SharedUtil .containsDuplicates(new Object[] { "a", "b", "a", "b" })); - Assert.assertTrue( - SharedUtil.containsDuplicates(new Object[] { 1, "b", 1 })); - - Assert.assertFalse(SharedUtil.containsDuplicates(new Object[] {})); - Assert.assertFalse(SharedUtil.containsDuplicates(new Object[] { "a" })); - Assert.assertFalse( - SharedUtil.containsDuplicates(new Object[] { "a", "b" })); - Assert.assertFalse( - SharedUtil.containsDuplicates(new Object[] { "1", 1 })); + assertTrue(SharedUtil.containsDuplicates(new Object[] { 1, "b", 1 })); + + assertFalse(SharedUtil.containsDuplicates(new Object[] {})); + assertFalse(SharedUtil.containsDuplicates(new Object[] { "a" })); + assertFalse(SharedUtil.containsDuplicates(new Object[] { "a", "b" })); + assertFalse(SharedUtil.containsDuplicates(new Object[] { "1", 1 })); } @Test public void getDuplicates() { - Assert.assertEquals("", SharedUtil.getDuplicates(new Object[] { "a" })); - Assert.assertEquals("a", - SharedUtil.getDuplicates(new Object[] { "a", "a" })); - Assert.assertEquals("a, b", + assertEquals("", SharedUtil.getDuplicates(new Object[] { "a" })); + assertEquals("a", SharedUtil.getDuplicates(new Object[] { "a", "a" })); + assertEquals("a, b", SharedUtil.getDuplicates(new Object[] { "a", "b", "a", "b" })); - Assert.assertEquals("a, b, c", SharedUtil + assertEquals("a, b, c", SharedUtil .getDuplicates(new Object[] { "c", "a", "b", "a", "b", "c" })); - Assert.assertEquals("1.2", + assertEquals("1.2", SharedUtil.getDuplicates(new Object[] { 1.2, "a", 1.2 })); } @Test public void propertyIdToHumanFriendly() { - Assert.assertEquals("", SharedUtil.propertyIdToHumanFriendly("")); - Assert.assertEquals("First Name", + assertEquals("", SharedUtil.propertyIdToHumanFriendly("")); + assertEquals("First Name", SharedUtil.propertyIdToHumanFriendly("firstName")); - Assert.assertEquals("First Name", + assertEquals("First Name", SharedUtil.propertyIdToHumanFriendly("FirstName")); - Assert.assertEquals("First Name", + assertEquals("First Name", SharedUtil.propertyIdToHumanFriendly("FIRST_NAME")); - Assert.assertEquals("Firstname", + assertEquals("Firstname", SharedUtil.propertyIdToHumanFriendly("FIRSTNAME")); - Assert.assertEquals("2015 Q3", + assertEquals("2015 Q3", SharedUtil.propertyIdToHumanFriendly("2015_Q3")); - Assert.assertEquals("Column X", + assertEquals("Column X", SharedUtil.propertyIdToHumanFriendly("_COLUMN_X")); - Assert.assertEquals("Column X", + assertEquals("Column X", SharedUtil.propertyIdToHumanFriendly("__COLUMN_X")); - Assert.assertEquals("1column Foobar", + assertEquals("1column Foobar", SharedUtil.propertyIdToHumanFriendly("1COLUMN_FOOBAR")); - Assert.assertEquals("Result 2015", + assertEquals("Result 2015", SharedUtil.propertyIdToHumanFriendly("RESULT_2015")); - Assert.assertEquals("2015result", + assertEquals("2015result", SharedUtil.propertyIdToHumanFriendly("2015RESULT")); - Assert.assertEquals("Result2015", + assertEquals("Result2015", SharedUtil.propertyIdToHumanFriendly("RESULT2015")); } diff --git a/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java b/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java index 2c9bcb5895..dd7c158692 100644 --- a/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java +++ b/test/bean-api-validation/src/test/java/com/vaadin/data/BeanValidationTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.data; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.ui.TextField; @@ -44,7 +46,7 @@ public class BeanValidationTest { public void binderWorksWithoutBeanValidationLib() { try { Class.forName("javax.validation.Validation"); - Assert.fail(); + fail(); } catch (ClassNotFoundException ignored) { } @@ -57,7 +59,7 @@ public class BeanValidationTest { binder.setBean(bean); field.setValue("foo"); - Assert.assertEquals(field.getValue(), bean.getProperty()); + assertEquals(field.getValue(), bean.getProperty()); } } diff --git a/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java b/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java index a3b2fdc2c0..e495ee279b 100644 --- a/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java +++ b/test/bean-impl-validation/src/test/java/com/vaadin/data/BeanValidationTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.data; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import javax.validation.Validation; -import org.junit.Assert; import org.junit.Test; import com.vaadin.ui.TextField; @@ -46,7 +48,7 @@ public class BeanValidationTest { public void binderWorksWithoutBeanValidationImpl() { // Just to make sure that it's available at the compilation time and in // runtime - Assert.assertNotNull(Validation.class); + assertNotNull(Validation.class); Binder<Bean> binder = new Binder<>(Bean.class); @@ -57,7 +59,7 @@ public class BeanValidationTest { binder.setBean(bean); field.setValue("foo"); - Assert.assertEquals(field.getValue(), bean.getProperty()); + assertEquals(field.getValue(), bean.getProperty()); } } diff --git a/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java b/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java index d3244417db..95cebdc974 100644 --- a/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java +++ b/test/cdi/src/test/java/com/vaadin/test/cdi/VaadinCDISmokeIT.java @@ -1,6 +1,8 @@ package com.vaadin.test.cdi; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -29,8 +31,8 @@ public class VaadinCDISmokeIT extends TestBenchTestCase { $(ButtonElement.class).first().click(); - Assert.assertTrue($(NotificationElement.class).exists()); - Assert.assertEquals(ThankYouServiceImpl.THANK_YOU_TEXT, + assertTrue($(NotificationElement.class).exists()); + assertEquals(ThankYouServiceImpl.THANK_YOU_TEXT, $(NotificationElement.class).first().getText()); } } diff --git a/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java b/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java index 5256def3f5..09f0d333a2 100644 --- a/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java +++ b/test/dependency-rewrite/src/test/java/com/vaadin/test/dependencyrewrite/DependencyFilterIT.java @@ -1,6 +1,7 @@ package com.vaadin.test.dependencyrewrite; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.phantomjs.PhantomJSDriver; @@ -13,7 +14,7 @@ public class DependencyFilterIT extends TestBenchTestCase { public void dynamicallyAddedResources() { setDriver(new PhantomJSDriver()); getDriver().get("http://localhost:8080/dynamic/"); - Assert.assertEquals(1L, ((JavascriptExecutor) getDriver()) + assertEquals(1L, ((JavascriptExecutor) getDriver()) .executeScript("return window.jqueryLoaded")); } @@ -22,7 +23,7 @@ public class DependencyFilterIT extends TestBenchTestCase { setDriver(new PhantomJSDriver()); getDriver().get("http://localhost:8080/initial/"); // 2 because of https://github.com/vaadin/framework/issues/9181 - Assert.assertEquals(2L, ((JavascriptExecutor) getDriver()) + assertEquals(2L, ((JavascriptExecutor) getDriver()) .executeScript("return window.jqueryLoaded")); } diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java index dc1fe4e6a8..aa8f87686a 100644 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/push/LongPollingProxyServerIT.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.integration.push; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -67,14 +68,14 @@ public class LongPollingProxyServerIT extends AbstractIntegrationTest { // The wildfly9-nginx server has a configured timeout of 10s for // *-timeout urls Thread.sleep(15000); - Assert.assertEquals(0, getClientCounter()); + assertEquals(0, getClientCounter()); getIncrementButton().click(); - Assert.assertEquals(1, getClientCounter()); + assertEquals(1, getClientCounter()); } @Test public void basicPush() { - Assert.assertEquals(0, getServerCounter()); + assertEquals(0, getServerCounter()); getServerCounterStartButton().click(); waitUntil(e -> getServerCounter() > 1, 10); } diff --git a/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java b/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java index 76fc8790e2..d0e3b4c4ae 100644 --- a/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java +++ b/test/spring-boot/src/test/java/com/example/VaadinSpringBootSmokeIT.java @@ -1,6 +1,8 @@ package com.example; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -43,8 +45,8 @@ public class VaadinSpringBootSmokeIT extends TestBenchTestCase { public void testPageLoadsAndButtonWorks() { getDriver().navigate().to("http://localhost:" + port + ""); $(ButtonElement.class).first().click(); - Assert.assertTrue($(NotificationElement.class).exists()); - Assert.assertEquals(ThankYouService.THANK_YOU_TEXT, + assertTrue($(NotificationElement.class).exists()); + assertEquals(ThankYouService.THANK_YOU_TEXT, $(NotificationElement.class).first().getText()); } } diff --git a/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java b/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java index c6d4f1756b..28657067d3 100644 --- a/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java +++ b/test/widget-set-testutil/src/main/java/com/vaadin/test/defaultwidgetset/AbstractWidgetSetIT.java @@ -1,8 +1,10 @@ package com.vaadin.test.defaultwidgetset; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.openqa.selenium.By; @@ -44,26 +46,25 @@ public abstract class AbstractWidgetSetIT extends TestBenchTestCase { $(ButtonElement.class).first().click(); - Assert.assertEquals("Label shown", 2, - $(LabelElement.class).all().size()); + assertEquals("Label shown", 2, $(LabelElement.class).all().size()); - Assert.assertEquals("Thanks John Dåe, it works!", + assertEquals("Thanks John Dåe, it works!", $(LabelElement.class).get(1).getText()); - Assert.assertEquals(expectedWidgetSet, + assertEquals(expectedWidgetSet, findElement(By.id("widgetsetinfo")).getText()); } protected void assertNoUnknownComponentShown() { - Assert.assertEquals(0, + assertEquals(0, findElements(By.className("vaadin-unknown-caption")).size()); } protected void assertUnknownComponentShown(String componentClass) { WebElement unknownComponentCaption = findElement( By.className("vaadin-unknown-caption")); - Assert.assertTrue(unknownComponentCaption.getText().contains( + assertTrue(unknownComponentCaption.getText().contains( "does not contain implementation for " + componentClass)); } @@ -77,8 +78,7 @@ public abstract class AbstractWidgetSetIT extends TestBenchTestCase { break; } } - Assert.assertTrue( - "Cannot find debug message containing '" + message + "'", + assertTrue("Cannot find debug message containing '" + message + "'", found); } diff --git a/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java b/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java index 2bfa1f9ad4..a604756d94 100644 --- a/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java +++ b/uitest/src/test/java/com/vaadin/tests/CurrentTimeMillisTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.tests; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -46,7 +49,7 @@ public class CurrentTimeMillisTest extends MultiBrowserTest { && !BrowserUtil.isSafari(getDesiredCapabilities()); String time = getJsonParsingTime(); - Assert.assertNotNull("JSON parsing time is not found", time); + assertNotNull("JSON parsing time is not found", time); time = time.trim(); if (time.endsWith("ms")) { time = time.substring(0, time.length() - 2); @@ -56,19 +59,19 @@ public class CurrentTimeMillisTest extends MultiBrowserTest { || BrowserUtil.isFirefox(getDesiredCapabilities())) { // Chrome (version 33 at least) sometimes doesn't use high res // time for very short times - Assert.assertTrue( + assertTrue( "High resolution time is not used in " + "JSON parsing mesurement. Time=" + time, time.equals("0") || time.equals("1") || time.indexOf('.') > 0); } else { - Assert.assertTrue( + assertTrue( "High resolution time is not used in " + "JSON parsing mesurement. Time=" + time, time.indexOf('.') > 0); } } else { - Assert.assertFalse("Unexpected dot is detected in browser " + assertFalse("Unexpected dot is detected in browser " + "that doesn't support high resolution time and " + "should report time as integer number. Time=" + time, time.indexOf('.') > 0); diff --git a/uitest/src/test/java/com/vaadin/tests/VerifyAssertionsEnabledTest.java b/uitest/src/test/java/com/vaadin/tests/VerifyAssertionsEnabledTest.java index 1180cc8332..a34d2b4d7f 100644 --- a/uitest/src/test/java/com/vaadin/tests/VerifyAssertionsEnabledTest.java +++ b/uitest/src/test/java/com/vaadin/tests/VerifyAssertionsEnabledTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -9,6 +10,6 @@ public class VerifyAssertionsEnabledTest extends SingleBrowserTest { @Test public void verifyServerAssertions() throws Exception { openTestURL(); - Assert.assertEquals("1. Assertions are enabled", getLogRow(0)); + assertEquals("1. Assertions are enabled", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/accessibility/WindowWaiAriaRolesTest.java b/uitest/src/test/java/com/vaadin/tests/accessibility/WindowWaiAriaRolesTest.java index 6162136aa1..c7a41761dc 100644 --- a/uitest/src/test/java/com/vaadin/tests/accessibility/WindowWaiAriaRolesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/accessibility/WindowWaiAriaRolesTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.accessibility; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -35,7 +36,7 @@ public class WindowWaiAriaRolesTest extends MultiBrowserTest { $(ButtonElement.class).caption("Regular").first().click(); String role = getWindowRole(); - Assert.assertTrue( + assertTrue( "Dialog has incorrect role '" + role + "', expected 'dialog'", "dialog".equals(role)); } @@ -45,7 +46,7 @@ public class WindowWaiAriaRolesTest extends MultiBrowserTest { openTestURL(); $(ButtonElement.class).caption("Alert").first().click(); String role = getWindowRole(); - Assert.assertTrue( + assertTrue( "Dialog has incorrect role '" + role + "', expected 'alertdialog'", "alertdialog".equals(role)); diff --git a/uitest/src/test/java/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java index a1b36d0b0e..b171d3d1ff 100644 --- a/uitest/src/test/java/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.actions; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; @@ -22,13 +23,13 @@ public class ActionsOnInvisibleComponentsTest extends MultiBrowserTest { @Test public void testShortcutsOnInvisibleDisabledButtons() { openTestURL(); - Assert.assertEquals(LAST_INIT_LOG, getLogRow(0)); + assertEquals(LAST_INIT_LOG, getLogRow(0)); invokeShortcut("A"); - Assert.assertEquals(LAST_INIT_LOG, getLogRow(0)); + assertEquals(LAST_INIT_LOG, getLogRow(0)); invokeShortcut("B"); - Assert.assertEquals(LAST_INIT_LOG, getLogRow(0)); + assertEquals(LAST_INIT_LOG, getLogRow(0)); invokeShortcut("C"); - Assert.assertEquals("4. Click event for enabled button", getLogRow(0)); + assertEquals("4. Click event for enabled button", getLogRow(0)); } private void invokeShortcut(CharSequence key) { diff --git a/uitest/src/test/java/com/vaadin/tests/application/ConnectorBundleStatusTest.java b/uitest/src/test/java/com/vaadin/tests/application/ConnectorBundleStatusTest.java index 58419bf43f..2a03d3d9b4 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ConnectorBundleStatusTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ConnectorBundleStatusTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.application; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.By; @@ -45,7 +46,6 @@ public class ConnectorBundleStatusTest extends SingleBrowserTest { private void assertLoaded(String... expectedNames) { String bundleStatus = findElement(By.id("bundleStatus")).getText(); - Assert.assertEquals(Arrays.asList(expectedNames).toString(), - bundleStatus); + assertEquals(Arrays.asList(expectedNames).toString(), bundleStatus); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/InitiallyDeferredLoadingTest.java b/uitest/src/test/java/com/vaadin/tests/application/InitiallyDeferredLoadingTest.java index c61b12fbb1..74d3eec47f 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/InitiallyDeferredLoadingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/InitiallyDeferredLoadingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -29,6 +30,6 @@ public class InitiallyDeferredLoadingTest extends SingleBrowserTest { WebElement deferredComponent = findElement(By.id("deferred")); - Assert.assertEquals("DeferredConnector", deferredComponent.getText()); + assertEquals("DeferredConnector", deferredComponent.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/MissingHierarchyDetectionTest.java b/uitest/src/test/java/com/vaadin/tests/application/MissingHierarchyDetectionTest.java index 64b999b7d5..a5fe6e96f3 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/MissingHierarchyDetectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/MissingHierarchyDetectionTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -28,18 +30,18 @@ public class MissingHierarchyDetectionTest extends SingleBrowserTest { public void testMissingHierarchyDetection() { openTestURL(); - Assert.assertTrue(isElementPresent(By.id("label"))); + assertTrue(isElementPresent(By.id("label"))); ButtonElement toggleProperly = $(ButtonElement.class) .caption("Toggle properly").first(); toggleProperly.click(); assertNoSystemNotifications(); - Assert.assertFalse(isElementPresent(By.id("label"))); + assertFalse(isElementPresent(By.id("label"))); toggleProperly.click(); assertNoSystemNotifications(); - Assert.assertTrue(isElementPresent(LabelElement.class)); + assertTrue(isElementPresent(LabelElement.class)); ButtonElement toggleImproperly = $(ButtonElement.class) .caption("Toggle improperly").first(); diff --git a/uitest/src/test/java/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java b/uitest/src/test/java/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java index af39d1e625..c9e4597b18 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -43,7 +44,7 @@ public class PreserveWithExpiredHeartbeatTest extends SingleBrowserTest { openTestURL(); // Verify that that we still get the same UI - Assert.assertEquals("Original UI has been closed", originalId, + assertEquals("Original UI has been closed", originalId, getUiIdentification()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java index 49dabf467c..121abd505e 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java @@ -15,13 +15,15 @@ */ package com.vaadin.tests.application; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import javax.imageio.ImageIO; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; @@ -46,7 +48,7 @@ public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { ButtonElement helloButton = $(ButtonElement.class).caption("Say hello") .first(); helloButton.click(); - Assert.assertEquals("1. Hello from the server", getLogRow(0)); + assertEquals("1. Hello from the server", getLogRow(0)); disconnectProxy(); helloButton.click(); testBench().disableWaitForVaadin(); @@ -130,7 +132,7 @@ public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { } } } - Assert.fail(message); + fail(message); } diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java index 3cbf8c38c7..ffbdf0dc0d 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogUITest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -38,12 +41,11 @@ public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { getButton().click(); waitForReconnectDialogPresent(); WebElement body = findElement(By.xpath("//body")); - Assert.assertTrue("Body should have a style name when reconnecting", + assertTrue("Body should have a style name when reconnecting", hasCssClass(body, "v-reconnecting")); connectProxy(); waitForReconnectDialogToDisappear(); - Assert.assertFalse( - "Body should no longer have a style name when reconnected", + assertFalse("Body should no longer have a style name when reconnected", hasCssClass(body, "v-reconnecting")); } @@ -51,14 +53,14 @@ public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { public void reconnectDialogShownAndDisappears() throws JSchException { openTestURL(); getButton().click(); - Assert.assertEquals("1. Hello from the server", getLogRow(0)); + assertEquals("1. Hello from the server", getLogRow(0)); disconnectProxy(); getButton().click(); waitForReconnectDialogWithText( "Server connection lost, trying to reconnect..."); connectProxy(); waitForReconnectDialogToDisappear(); - Assert.assertEquals("2. Hello from the server", getLogRow(0)); + assertEquals("2. Hello from the server", getLogRow(0)); } private void waitForReconnectDialogWithText(final String text) { diff --git a/uitest/src/test/java/com/vaadin/tests/application/RefreshFragmentChangeTest.java b/uitest/src/test/java/com/vaadin/tests/application/RefreshFragmentChangeTest.java index ea415bcaae..acbd022be4 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/RefreshFragmentChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/RefreshFragmentChangeTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.By; @@ -24,6 +25,6 @@ public class RefreshFragmentChangeTest extends MultiBrowserTest { private void assertLogText(String expected) { waitForElementPresent(By.className("v-label")); - Assert.assertEquals("Incorrect log text,", expected, getLogRow(0)); + assertEquals("Incorrect log text,", expected, getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTest.java b/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTest.java index 3257e3429f..3211c15633 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.By; @@ -24,7 +25,6 @@ public class RefreshStatePreserveTest extends MultiBrowserTest { private void assertCorrectState() { waitForElementPresent(By.className("v-label")); LabelElement uiIdLabel = $(LabelElement.class).get(7); - Assert.assertEquals("Incorrect UI id,", UI_ID_TEXT, - uiIdLabel.getText()); + assertEquals("Incorrect UI id,", UI_ID_TEXT, uiIdLabel.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java b/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java index e2740f9537..48ff4c0844 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -15,6 +16,6 @@ public class RefreshStatePreserveTitleTest extends MultiBrowserTest { } private void assertTitleText() { - Assert.assertEquals("Incorrect page title,", "TEST", driver.getTitle()); + assertEquals("Incorrect page title,", "TEST", driver.getTitle()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/ResynchronizeUITest.java b/uitest/src/test/java/com/vaadin/tests/application/ResynchronizeUITest.java index 63f1e4566d..f92b1271dd 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ResynchronizeUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ResynchronizeUITest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.application; +import static org.junit.Assert.fail; + import java.util.Collections; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.remote.DesiredCapabilities; @@ -47,8 +48,7 @@ public class ResynchronizeUITest extends SingleBrowserTest { waitForThemeToChange("runo"); try { button.click(); - Assert.fail( - "The old button element should have been removed by the click and replaced by a new one."); + fail("The old button element should have been removed by the click and replaced by a new one."); } catch (StaleElementReferenceException e) { // This is what should happen } diff --git a/uitest/src/test/java/com/vaadin/tests/application/TerminalErrorNotificationTest.java b/uitest/src/test/java/com/vaadin/tests/application/TerminalErrorNotificationTest.java index 8d55ee74d7..d01aef95e0 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/TerminalErrorNotificationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/TerminalErrorNotificationTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -12,8 +14,8 @@ public class TerminalErrorNotificationTest extends MultiBrowserTest { public void tb2test() throws Exception { openTestURL(); $(ButtonElement.class).first().click(); - Assert.assertTrue(isElementPresent(NotificationElement.class)); - Assert.assertEquals("Got an exception: You asked for it", + assertTrue(isElementPresent(NotificationElement.class)); + assertEquals("Got an exception: You asked for it", $(NotificationElement.class).first().getCaption()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java b/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java index 4600e89862..b8afba529d 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ThreadLocalInstancesTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -30,6 +31,6 @@ public class ThreadLocalInstancesTest extends MultiBrowserTest { } private void assertLogText(String expected, int index) { - Assert.assertEquals("Incorrect log text,", expected, getLogRow(index)); + assertEquals("Incorrect log text,", expected, getLogRow(index)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/TimingInfoReportedTest.java b/uitest/src/test/java/com/vaadin/tests/application/TimingInfoReportedTest.java index 559da03366..e5964d95a6 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/TimingInfoReportedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/TimingInfoReportedTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -26,8 +27,8 @@ public class TimingInfoReportedTest extends SingleBrowserTestPhantomJS2 { @Test public void ensureTimingsAvailable() { openTestURL(); - Assert.assertEquals("2. Timings ok", getLogRow(0)); + assertEquals("2. Timings ok", getLogRow(0)); $(ButtonElement.class).first().click(); - Assert.assertEquals("4. Timings ok", getLogRow(0)); + assertEquals("4. Timings ok", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java b/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java index 10b6dfb7a9..bc74927ee1 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/WebBrowserTimeZoneTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.application; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -20,8 +21,7 @@ public class WebBrowserTimeZoneTest extends MultiBrowserTest { private void assertLabelText(String caption, String expected) { String actual = $(LabelElement.class).caption(caption).first() .getText(); - Assert.assertEquals( - String.format("Unexpected text in label '%s',", caption), + assertEquals(String.format("Unexpected text in label '%s',", caption), expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationcontext/ChangeSessionIdTest.java b/uitest/src/test/java/com/vaadin/tests/applicationcontext/ChangeSessionIdTest.java index ec1479ce15..e7563fa5b6 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationcontext/ChangeSessionIdTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationcontext/ChangeSessionIdTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.applicationcontext; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -20,7 +21,7 @@ public class ChangeSessionIdTest extends MultiBrowserTest { private void checkLogMatches(String expected) { String actual = getLogRow(0); - Assert.assertTrue(String.format( + assertTrue(String.format( "Unexpected log row.\n expected format: '%s'\n was: '%s'", expected, actual), actual.matches(expected)); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationcontext/CleanupBrokenUITest.java b/uitest/src/test/java/com/vaadin/tests/applicationcontext/CleanupBrokenUITest.java index a25b6c1abd..48800e37fb 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationcontext/CleanupBrokenUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationcontext/CleanupBrokenUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationcontext; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -26,19 +27,19 @@ public class CleanupBrokenUITest extends SingleBrowserTest { public void ensureUIDetached() { openTestURL(); // UI 1 has not yet been added in UI.init where logging takes place - Assert.assertEquals("1. UIs in session: 0", getLogRow(0)); + assertEquals("1. UIs in session: 0", getLogRow(0)); String url = getTestURL(getUIClass()).replace("restartApplication", "1"); driver.get(url); // UI 1 remains in session during UI2 init where logging takes place - Assert.assertEquals("1. UIs in session: 1", getLogRow(0)); + assertEquals("1. UIs in session: 1", getLogRow(0)); // At this point UI1 should be removed from the session driver.get(url); // UI 2 remains in session during UI3 init where logging takes place // UI 1 should have been removed - Assert.assertEquals("1. UIs in session: 1", getLogRow(0)); + assertEquals("1. UIs in session: 1", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationcontext/CloseSessionTest.java b/uitest/src/test/java/com/vaadin/tests/applicationcontext/CloseSessionTest.java index 5a6657801d..c58f51373b 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationcontext/CloseSessionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationcontext/CloseSessionTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.applicationcontext; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.By; @@ -47,8 +48,7 @@ public class CloseSessionTest extends MultiBrowserTest { @Test public void testCloseVaadinServiceAndRedirect() { clickButton("Close VaadinServiceSession and redirect elsewhere"); - Assert.assertEquals("Unexpected page contents,", - "This is a static file", + assertEquals("Unexpected page contents,", "This is a static file", findElement(By.xpath("//h1")).getText()); } @@ -91,13 +91,13 @@ public class CloseSessionTest extends MultiBrowserTest { } private void assertLogText(int index, String expected) { - Assert.assertEquals("Unexpected log text,", expected, getLogRow(index)); + assertEquals("Unexpected log text,", expected, getLogRow(index)); } private void assertSessionExpired() { String expected = "Session Expired"; String actual = $(NotificationElement.class).first().getCaption(); - Assert.assertEquals("Unexpected notification,", actual, expected); + assertEquals("Unexpected notification,", actual, expected); } public void clickButton(String caption) { diff --git a/uitest/src/test/java/com/vaadin/tests/applicationcontext/RpcForClosedUITest.java b/uitest/src/test/java/com/vaadin/tests/applicationcontext/RpcForClosedUITest.java index d2818205df..499bc0a7fe 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationcontext/RpcForClosedUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationcontext/RpcForClosedUITest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.applicationcontext; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -21,7 +23,7 @@ public class RpcForClosedUITest extends MultiBrowserTest { clickButton("Log 'hello'"); /* Ensure 'hello' was not logged */ checkLogMatches("2. Current WrappedSession id: .*"); - Assert.assertFalse("Page contains word 'Hello'", + assertFalse("Page contains word 'Hello'", driver.getPageSource().contains("Hello")); } @@ -31,7 +33,7 @@ public class RpcForClosedUITest extends MultiBrowserTest { private void checkLogMatches(String expected) { String actual = getLogRow(0); - Assert.assertTrue(String.format( + assertTrue(String.format( "Unexpected log row.\n expected format: '%s'\n was: '%s'", expected, actual), actual.matches(expected)); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ContextProtocolTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ContextProtocolTest.java index a4bd0b5f85..186523545d 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ContextProtocolTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ContextProtocolTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.By; @@ -27,9 +28,9 @@ public class ContextProtocolTest extends SingleBrowserTest { public void contextPathCorrect() { openTestURL(); // Added by bootstrap - Assert.assertEquals("said", executeScript("return window.hello")); + assertEquals("said", executeScript("return window.hello")); // Added by client side - Assert.assertEquals(getBaseURL() + "/statictestfiles/image.png", + assertEquals(getBaseURL() + "/statictestfiles/image.png", findElement(By.id("image")).getAttribute("src")); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/CustomDeploymentConfTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/CustomDeploymentConfTest.java index 7c4788a4d5..d22e9687b7 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/CustomDeploymentConfTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/CustomDeploymentConfTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -33,9 +34,8 @@ public class CustomDeploymentConfTest extends MultiBrowserTest { LabelElement customParamLabel = $$(VerticalLayoutElement.class) .$$(VerticalLayoutElement.class).$$(LabelElement.class).get(1); - Assert.assertEquals("Resource cache time: 3599", - cacheTimeLabel.getText()); - Assert.assertEquals("Custom config param: customValue", + assertEquals("Resource cache time: 3599", cacheTimeLabel.getText()); + assertEquals("Custom config param: customValue", customParamLabel.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java index 4c0fc483a9..7ce9781629 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -28,7 +29,7 @@ public class DisableSendUrlAsParametersTest extends SingleBrowserTest { String logRow = getLogRow(0); - Assert.assertEquals( + assertEquals( "1. Init location exception: Location is not available as the sendUrlsAsParameters parameter is configured as false", logRow); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java index 5e835d219b..76055be44d 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/MultipleServletConfigurationTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -24,7 +25,7 @@ public class MultipleServletConfigurationTest extends MultiBrowserTest { } private void assertLabelText(String expected) { - Assert.assertEquals("Unexpected label text,", expected, + assertEquals("Unexpected label text,", expected, $(LabelElement.class).first().getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java index 50667b7449..6661a6a231 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -29,10 +30,9 @@ public class NoApplicationClassTest extends SingleBrowserTest { String exceptionMessage = getDriver().findElement(By.xpath("//pre[2]")) .getText(); String expected = "ServletException: java.lang.ClassNotFoundException: ClassThatIsNotPresent"; - Assert.assertTrue( - String.format( - "Unexpected error message.\n expected to contain: '%s'\n was: %s", - expected, exceptionMessage), + assertTrue(String.format( + "Unexpected error message.\n expected to contain: '%s'\n was: %s", + expected, exceptionMessage), exceptionMessage.contains(expected)); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServiceInitListenersTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServiceInitListenersTest.java index a23a6f1a1f..4b1f3c5a7b 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServiceInitListenersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServiceInitListenersTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -26,9 +27,9 @@ public class ServiceInitListenersTest extends SingleBrowserTest { public void testServiceInitListenerTriggered() { openTestURL(); - Assert.assertNotEquals(getLogRow(0), 0, extractCount(getLogRow(0))); - Assert.assertNotEquals(getLogRow(1), 0, extractCount(getLogRow(1))); - Assert.assertNotEquals(getLogRow(2), 0, extractCount(getLogRow(2))); + assertNotEquals(getLogRow(0), 0, extractCount(getLogRow(0))); + assertNotEquals(getLogRow(1), 0, extractCount(getLogRow(1))); + assertNotEquals(getLogRow(2), 0, extractCount(getLogRow(2))); } private int extractCount(String logRow) { diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java index 92d5795eee..fa539e0c0b 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/ServletWithResourcesTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.applicationservlet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -42,24 +44,21 @@ public class ServletWithResourcesTest extends SingleBrowserTest { @Test public void servletServesResources() { openTestURL(); - Assert.assertEquals("Enabled", - $(CheckBoxElement.class).first().getCaption()); + assertEquals("Enabled", $(CheckBoxElement.class).first().getCaption()); List<WebElement> links = findElements(By.xpath("//head/link")); for (WebElement link : links) { String href = link.getAttribute("href"); - Assert.assertTrue( - "href '" + href - + "' should contain '/servlet-with-resources/VAADIN'", + assertTrue("href '" + href + + "' should contain '/servlet-with-resources/VAADIN'", href.contains("/servlet-with-resources/VAADIN")); } List<WebElement> scripts = findElements(By.xpath("//head/script")); for (WebElement script : scripts) { String src = script.getAttribute("src"); - Assert.assertTrue( - "src '" + src - + "' should contain '/servlet-with-resources/VAADIN'", + assertTrue("src '" + src + + "' should contain '/servlet-with-resources/VAADIN'", src.contains("/servlet-with-resources/VAADIN")); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/SystemMessagesTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/SystemMessagesTest.java index dd5248ce76..bd0920c56a 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/SystemMessagesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/SystemMessagesTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -26,9 +27,9 @@ public class SystemMessagesTest extends MultiBrowserTest { private void verifyError(String locale) { $(ButtonElement.class).first().click(); NotificationElement notification = $(NotificationElement.class).first(); - Assert.assertEquals("Incorrect notification caption,", + assertEquals("Incorrect notification caption,", notification.getCaption(), "Internal error"); - Assert.assertEquals("Incorrect notification description,", + assertEquals("Incorrect notification description,", notification.getDescription(), "MessagesInfo locale: " + locale); } diff --git a/uitest/src/test/java/com/vaadin/tests/applicationservlet/VaadinRefreshServletTest.java b/uitest/src/test/java/com/vaadin/tests/applicationservlet/VaadinRefreshServletTest.java index 06911b909f..0930663925 100644 --- a/uitest/src/test/java/com/vaadin/tests/applicationservlet/VaadinRefreshServletTest.java +++ b/uitest/src/test/java/com/vaadin/tests/applicationservlet/VaadinRefreshServletTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.applicationservlet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -29,7 +30,7 @@ public class VaadinRefreshServletTest extends SingleBrowserTest { getDriver().get(getBaseURL() + "/vaadinrefresh/"); waitUntil((WebDriver d) -> "Please login" .equals(findElement(By.tagName("body")).getText())); - Assert.assertEquals(getBaseURL() + "/statictestfiles/login.html", + assertEquals(getBaseURL() + "/statictestfiles/login.html", getDriver().getCurrentUrl()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java b/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java index 4d8449fa38..d108d70af3 100644 --- a/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorInheritedClassesTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.componentlocator; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -20,18 +21,18 @@ public class ComponentLocatorInheritedClassesTest extends SingleBrowserTest { @Test public void label_finds_all_three() { openTestURL(); - Assert.assertEquals(3, $(LabelElement.class).all().size()); + assertEquals(3, $(LabelElement.class).all().size()); } @Test public void defaultlabel_finds_two() { openTestURL(); - Assert.assertEquals(2, $(DefaultLabelElement.class).all().size()); + assertEquals(2, $(DefaultLabelElement.class).all().size()); } @Test public void mycustomlabel_finds_one() { openTestURL(); - Assert.assertEquals(1, $(MyCustomLabelElement.class).all().size()); + assertEquals(1, $(MyCustomLabelElement.class).all().size()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorOldClassesTest.java b/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorOldClassesTest.java index eb465f2c51..a282385d2b 100644 --- a/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorOldClassesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/componentlocator/ComponentLocatorOldClassesTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.componentlocator; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TextFieldElement; @@ -11,8 +12,7 @@ public class ComponentLocatorOldClassesTest extends SingleBrowserTest { @Test public void testTestBenchFindsBothTextFields() { openTestURL(); - Assert.assertEquals( - "ComponentLocator did not find elements as expected.", 2, + assertEquals("ComponentLocator did not find elements as expected.", 2, $(TextFieldElement.class).all().size()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java b/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java index 750545ce89..2dc9e02914 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ErrorLevelsTest.java @@ -1,11 +1,12 @@ package com.vaadin.tests.components; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -115,7 +116,7 @@ public class ErrorLevelsTest extends SingleBrowserTest { private void assertHasRightClassNames(WebElement element, String prefix, ErrorLevel errorLevel) { - Assert.assertTrue("Element must have only one error level class name", + assertTrue("Element must have only one error level class name", containsCorrectErrorLevelClassNameOnly(element, prefix, errorLevel)); } 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 09c4572526..689fe719e5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/HasValueRequiredIndicatorTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Point; @@ -35,21 +36,21 @@ public abstract class HasValueRequiredIndicatorTest extends MultiBrowserTest { public void requiredIndicatorVisible() { openTestURL(); List<WebElement> layouts = findElements(By.className("vaadin-layout")); - Assert.assertTrue(layouts.size() > 0); + assertTrue(layouts.size() > 0); layouts.stream().forEach(this::checkRequiredIndicator); } protected void checkRequiredIndicator(WebElement layout) { WebElement caption = layout.findElement(By.className("v-caption")); - Assert.assertTrue(caption.isDisplayed()); + assertTrue(caption.isDisplayed()); WebElement indicator = caption .findElement(By.className("v-required-field-indicator")); - Assert.assertTrue(indicator.isDisplayed()); + assertTrue(indicator.isDisplayed()); Point layoutLocation = layout.getLocation(); Point indicatorLocation = indicator.getLocation(); - Assert.assertTrue("Indicator x-axis location is not inside layout", + assertTrue("Indicator x-axis location is not inside layout", indicatorLocation.getX() >= layoutLocation.getX()); - Assert.assertTrue("Indicator y-axis location is not inside layout", + assertTrue("Indicator y-axis location is not inside layout", indicatorLocation.getY() >= layoutLocation.getY()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/SaneErrorsTest.java b/uitest/src/test/java/com/vaadin/tests/components/SaneErrorsTest.java index 34bf03aecd..c3478c99cd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/SaneErrorsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/SaneErrorsTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -54,7 +55,7 @@ public class SaneErrorsTest extends MultiBrowserTest { .findElements(By.className("v-label")); for (WebElement webElement : errorMessages) { String text = webElement.getText(); - Assert.assertEquals("java.lang.NullPointerException", text); + assertEquals("java.lang.NullPointerException", text); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/TooltipPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/TooltipPositionTest.java index 64fa0442d7..7c28fa1aae 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/TooltipPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/TooltipPositionTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -47,7 +48,7 @@ public class TooltipPositionTest extends MultiBrowserTest { waitForElementPresent(By.cssSelector(".v-tooltip")); WebElement tooltip = driver.findElement(By.cssSelector(".v-tooltip")); - Assert.assertTrue( + assertTrue( "This init tooltip with text ' ' is present in the DOM and should be entirely outside the browser window", isOutsideOfWindow(tooltip)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizeComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizeComponentsTest.java index 45d7941c58..37b25090bd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizeComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizeComponentsTest.java @@ -1,13 +1,17 @@ package com.vaadin.tests.components.absolutelayout; -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Optional; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import java.util.Optional; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; /** * Tests for component positioning after width changes from defined to relative @@ -23,16 +27,16 @@ public class AbsoluteLayoutResizeComponentsTest extends MultiBrowserTest { Optional<WebElement> panelWrapper = getComponentWrapper(componentId); - Assert.assertTrue("No wrapper element found for expanding panel [ID: " + assertTrue("No wrapper element found for expanding panel [ID: " + componentId + "]", panelWrapper.isPresent()); String left = panelWrapper.get().getCssValue("left"); - Assert.assertEquals( + assertEquals( "Component wrapper was missing left:0; from its css positioning", "0px", left); WebElement panelComponent = findElement(By.id(componentId)); - Assert.assertEquals("Panel is not on the left side of the screen", 0, + assertEquals("Panel is not on the left side of the screen", 0, panelComponent.getLocation().getX()); // Click button to change component size @@ -42,11 +46,11 @@ public class AbsoluteLayoutResizeComponentsTest extends MultiBrowserTest { // version 40 which calculates the actual left value, testing width // instead of the wrapper instead String width = panelWrapper.get().getCssValue("width"); - Assert.assertEquals("Width was more that it should have been.", "250px", + assertEquals("Width was more that it should have been.", "250px", width); - Assert.assertNotEquals("Panel is still on the left side of the screen", - 0, panelComponent.getLocation().getX()); + assertNotEquals("Panel is still on the left side of the screen", 0, + panelComponent.getLocation().getX()); } @Test @@ -57,32 +61,31 @@ public class AbsoluteLayoutResizeComponentsTest extends MultiBrowserTest { Optional<WebElement> panelWrapper = getComponentWrapper(componentId); - Assert.assertTrue( + assertTrue( "No wrapper element found for panel [ID: " + componentId + "]", panelWrapper.isPresent()); String width = panelWrapper.get().getCssValue("width"); - Assert.assertEquals("Width was more that it should have been.", "250px", + assertEquals("Width was more that it should have been.", "250px", width); WebElement panelComponent = findElement(By.id(componentId)); - Assert.assertNotEquals( - "Panel is positioned to the left side of the screen", 0, + assertNotEquals("Panel is positioned to the left side of the screen", 0, panelComponent.getLocation().getX()); // Click button to change component size $(ButtonElement.class).id(componentId + "-button").click(); String left = panelWrapper.get().getCssValue("left"); - Assert.assertEquals( + assertEquals( "Component wrapper was missing left:0; from its css positioning", "0px", left); width = panelWrapper.get().getCssValue("width"); - Assert.assertNotEquals("Width hasn't changed from the initial value.", - "250px", width); + assertNotEquals("Width hasn't changed from the initial value.", "250px", + width); - Assert.assertEquals("Panel is not on the left side of the screen", 0, + assertEquals("Panel is not on the left side of the screen", 0, panelComponent.getLocation().getX()); } @@ -94,31 +97,30 @@ public class AbsoluteLayoutResizeComponentsTest extends MultiBrowserTest { Optional<WebElement> panelWrapper = getComponentWrapper(componentId); - Assert.assertTrue("No wrapper element found for AbsoluteLayout [ID: " + assertTrue("No wrapper element found for AbsoluteLayout [ID: " + componentId + "].", panelWrapper.isPresent()); String width = panelWrapper.get().getCssValue("width"); - Assert.assertEquals("Width was more that it should have been.", "250px", + assertEquals("Width was more that it should have been.", "250px", width); WebElement panelComponent = findElement(By.id(componentId)); - Assert.assertNotEquals( - "Panel is positioned to the left side of the screen", 0, + assertNotEquals("Panel is positioned to the left side of the screen", 0, panelComponent.getLocation().getX()); // Click button to change component size $(ButtonElement.class).id(componentId + "-button").click(); String left = panelWrapper.get().getCssValue("left"); - Assert.assertEquals( + assertEquals( "Component wrapper was missing left:0; from its css positioning", "0px", left); width = panelWrapper.get().getCssValue("width"); - Assert.assertNotEquals("Width hasn't changed from the initial value.", - "250px", width); + assertNotEquals("Width hasn't changed from the initial value.", "250px", + width); - Assert.assertEquals("Panel is not on the left side of the screen", 0, + assertEquals("Panel is not on the left side of the screen", 0, panelComponent.getLocation().getX()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java b/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java index 6063cfd189..7c2ebcc85b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.abstractcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -29,7 +30,7 @@ public class ChangeHierarchyBeforeResponseTest extends SingleBrowserTest { ButtonElement button = $(ButtonElement.class).first(); - Assert.assertEquals( + assertEquals( "Button caption should change by its own beforeClientResponse", "Add label to layout", button.getText()); @@ -37,7 +38,7 @@ public class ChangeHierarchyBeforeResponseTest extends SingleBrowserTest { LabelElement label = $(LabelElement.class).all().get(1); - Assert.assertEquals("Label should have been considered initial twice", + assertEquals("Label should have been considered initial twice", "Initial count: 2", label.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java b/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java index 2b6d1d3b9b..740fc857bf 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.abstractcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -29,7 +30,7 @@ public class ResponseWritingErrorHandlingTest extends SingleBrowserTest { $(ButtonElement.class).first().click(); - Assert.assertEquals("Message should be logged by error handler", + assertEquals("Message should be logged by error handler", "1. Button.beforeClientResponse", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/TooltipModesTest.java b/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/TooltipModesTest.java index 489d7e2470..3813d547c5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/TooltipModesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/abstractcomponent/TooltipModesTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.abstractcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -59,7 +60,6 @@ public class TooltipModesTest extends TooltipTest { WebElement tooltip = getTooltip(); WebElement tooltipContent = tooltip .findElement(By.className("v-tooltip-text")); - Assert.assertEquals(tooltipText, - tooltipContent.getAttribute("innerHTML")); + assertEquals(tooltipText, tooltipContent.getAttribute("innerHTML")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/abstractfield/AbstractComponentStyleNameTest.java b/uitest/src/test/java/com/vaadin/tests/components/abstractfield/AbstractComponentStyleNameTest.java index 3b602b2f2c..3c0c534985 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/abstractfield/AbstractComponentStyleNameTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/abstractfield/AbstractComponentStyleNameTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.abstractfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -34,60 +35,60 @@ public class AbstractComponentStyleNameTest { @Test public void add() { c.addStyleName("foo"); - Assert.assertEquals("foo", c.getStyleName()); + assertEquals("foo", c.getStyleName()); } @Test public void addWithHeadingSpace() { c.addStyleName(" foo"); - Assert.assertEquals("foo", c.getStyleName()); + assertEquals("foo", c.getStyleName()); } @Test public void addWithTrailingSpace() { c.addStyleName("foo "); - Assert.assertEquals("foo", c.getStyleName()); + assertEquals("foo", c.getStyleName()); } @Test public void removeWithHeadingSpace() { c.setStyleName("foo"); c.removeStyleName(" foo"); - Assert.assertEquals("", c.getStyleName()); + assertEquals("", c.getStyleName()); } @Test public void removeWithTrailingSpace() { c.setStyleName("foo"); c.removeStyleName("foo "); - Assert.assertEquals("", c.getStyleName()); + assertEquals("", c.getStyleName()); } @Test public void addMultipleTimes() { c.addStyleName("foo"); c.addStyleName("foo"); - Assert.assertEquals("foo", c.getStyleName()); + assertEquals("foo", c.getStyleName()); } @Test public void setStyleAdd() { c.setStyleName("foo", true); - Assert.assertEquals("foo", c.getStyleName()); + assertEquals("foo", c.getStyleName()); } @Test public void setStyleMultipleAdd() { c.setStyleName("foo", true); c.setStyleName("foo", true); - Assert.assertEquals("foo", c.getStyleName()); + assertEquals("foo", c.getStyleName()); } @Test public void setStyleRemove() { c.addStyleName("foo"); c.setStyleName("foo", false); - Assert.assertEquals("", c.getStyleName()); + assertEquals("", c.getStyleName()); } @Test @@ -95,14 +96,14 @@ public class AbstractComponentStyleNameTest { c.addStyleName("foo"); c.setStyleName("foo", false); c.setStyleName("foo", false); - Assert.assertEquals("", c.getStyleName()); + assertEquals("", c.getStyleName()); } @Test public void remove() { c.addStyleName("foo"); c.removeStyleName("foo"); - Assert.assertEquals("", c.getStyleName()); + assertEquals("", c.getStyleName()); } @Test @@ -110,6 +111,6 @@ public class AbstractComponentStyleNameTest { c.addStyleName("foo"); c.removeStyleName("foo"); c.removeStyleName("foo"); - Assert.assertEquals("", c.getStyleName()); + assertEquals("", c.getStyleName()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java b/uitest/src/test/java/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java index 269d84be59..1cc110931a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.abstractfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -30,13 +31,13 @@ public class ShortcutWhenBodyFocusedTest extends SingleBrowserTest { openTestURL(); ButtonElement b = $(ButtonElement.class).caption("Hello").first(); b.click(); - Assert.assertEquals("1. Hello clicked", getLogRow(0)); + assertEquals("1. Hello clicked", getLogRow(0)); b.sendKeys("A"); - Assert.assertEquals("2. Hello clicked", getLogRow(0)); + assertEquals("2. Hello clicked", getLogRow(0)); WebElement body = findElement(By.xpath("//body")); body.sendKeys("A"); - Assert.assertEquals("3. Hello clicked", getLogRow(0)); + assertEquals("3. Hello clicked", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/abstractsingleselect/AbstractSingleSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/abstractsingleselect/AbstractSingleSelectionTest.java index 4623dac714..549243c971 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/abstractsingleselect/AbstractSingleSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/abstractsingleselect/AbstractSingleSelectionTest.java @@ -1,10 +1,14 @@ package com.vaadin.tests.components.abstractsingleselect; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,16 +62,15 @@ public class AbstractSingleSelectionTest extends SingleBrowserTest { AbstractSingleSelectElement selectElement = getSelectElement(); // TODO: TB API behavior should be unified. if (selectElement instanceof RadioButtonGroupElement) { - Assert.assertNull("No value should be selected", - selectElement.getValue()); + assertNull("No value should be selected", selectElement.getValue()); } else if (selectElement instanceof ComboBoxElement) { - Assert.assertTrue("No value should be selected", + assertTrue("No value should be selected", selectElement.getValue().isEmpty()); } else { // NativeSelectElement throws if no value is selected. try { selectElement.getValue(); - Assert.fail("No value should be selected"); + fail("No value should be selected"); } catch (NoSuchElementException e) { // All is fine. } @@ -82,11 +85,11 @@ public class AbstractSingleSelectionTest extends SingleBrowserTest { AbstractSingleSelectElement select = getSelectElement(); select.selectByText("Baz"); - Assert.assertEquals("Value should change", "Baz", select.getValue()); + assertEquals("Value should change", "Baz", select.getValue()); $(ButtonElement.class).caption("Refresh").first().click(); - Assert.assertEquals("Value should stay the same through refreshAll", - "Baz", select.getValue()); + assertEquals("Value should stay the same through refreshAll", "Baz", + select.getValue()); } @Test @@ -97,10 +100,10 @@ public class AbstractSingleSelectionTest extends SingleBrowserTest { AbstractSingleSelectElement select = getSelectElement(); select.selectByText("Baz"); - Assert.assertEquals("Value should change", "Baz", select.getValue()); + assertEquals("Value should change", "Baz", select.getValue()); $(ButtonElement.class).caption("Select Bar").first().click(); - Assert.assertEquals("Original value should be selected again", "Bar", + assertEquals("Original value should be selected again", "Bar", select.getValue()); } @@ -113,12 +116,12 @@ public class AbstractSingleSelectionTest extends SingleBrowserTest { AbstractSingleSelectElement rbg = getSelectElement(); rbg.selectByText("Reset"); // Selecting "Reset" selects "Bar" on server. Value was initially "Bar" - Assert.assertEquals("Original value should be selected again", "Bar", + assertEquals("Original value should be selected again", "Bar", rbg.getValue()); } private void assertInitial() { - Assert.assertEquals("Initial state unexpected", "Bar", + assertEquals("Initial state unexpected", "Bar", getSelectElement().getValue()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionAddTabTest.java b/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionAddTabTest.java index 77d9454424..dbf9dc3db0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionAddTabTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionAddTabTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.accordion; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -41,7 +42,7 @@ public class AccordionAddTabTest extends MultiBrowserTest { List<WebElement> panels = driver.findElements(By.className("v-panel")); - Assert.assertEquals( + assertEquals( "Found two widgets inside one tab after " + "subsequent tab removal and addition", 1, panels.size()); diff --git a/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java b/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java index 836b9ddc57..1100c1e1d8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/accordion/AccordionRemoveTabTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.accordion; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -53,7 +55,7 @@ public class AccordionRemoveTabTest extends MultiBrowserTest { WebElement caption = firstItem .findElement(By.className("v-accordion-item-caption")); caption.click(); - Assert.assertEquals("Errors present in console", 0, + assertEquals("Errors present in console", 0, findElements(By.className("SEVERE")).size()); } @@ -61,11 +63,10 @@ public class AccordionRemoveTabTest extends MultiBrowserTest { WebElement firstItem = driver .findElement(By.className("v-accordion-item-first")); WebElement label = firstItem.findElement(By.className("v-label")); - Assert.assertEquals("Unexpected text in first item", text, - label.getText()); + assertEquals("Unexpected text in first item", text, label.getText()); int height = firstItem.getSize().getHeight(); WebElement accordion = driver.findElement(By.className("v-accordion")); - Assert.assertTrue("First item in accordion has unexpected height", + assertTrue("First item in accordion has unexpected height", height > accordion.getSize().getHeight() / 2); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/button/ButtonKeyboardClickTest.java b/uitest/src/test/java/com/vaadin/tests/components/button/ButtonKeyboardClickTest.java index 9ff6d771cc..a0fe8408fd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/button/ButtonKeyboardClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/button/ButtonKeyboardClickTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.button; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -52,56 +53,56 @@ public class ButtonKeyboardClickTest extends MultiBrowserTest { private void checkCoordinates(WebElement button) { int xRelative = getValue("xRelative"); - Assert.assertTrue( + assertTrue( "X relative click coordinate is greater than middle of the button", button.getSize().getWidth() / 2 >= xRelative - 1); - Assert.assertTrue( + assertTrue( "X relative click coordinate is lower than middle of the button", button.getSize().getWidth() / 2 <= xRelative + 1); int yRelative = getValue("yRelative"); - Assert.assertTrue( + assertTrue( "Y relative click coordinate is greater than middle of the button", button.getSize().getHeight() / 2 >= yRelative - 1); - Assert.assertTrue( + assertTrue( "Y relative click coordinate is lower than middle of the button", button.getSize().getHeight() / 2 <= yRelative + 1); - Assert.assertTrue( + assertTrue( "Client X click cooridnate is lower than X button coordinate", getValue("x") > button.getLocation().getX()); - Assert.assertTrue( + assertTrue( "Client X click cooridnate is greater than right button " + "border coordinate", getValue("x") < button.getLocation().getX() + button.getSize().getWidth()); - Assert.assertTrue( + assertTrue( "Client Y click cooridnate is lower than Y button coordinate", getValue("y") > button.getLocation().getY()); - Assert.assertTrue( + assertTrue( "Client Y click cooridnate is greater than bottom button " + "border coordinate", getValue("y") < button.getLocation().getY() + button.getSize().getHeight()); - Assert.assertTrue( + assertTrue( "Client X click cooridnate is greater than X middle button " + "coordinate", button.getLocation().getX() + button.getSize().getWidth() / 2 >= getValue("x") - 1); - Assert.assertTrue( + assertTrue( "Client Y click cooridnate is greater than Y middle button coordinate", button.getLocation().getY() + button.getSize().getHeight() / 2 >= getValue("y") - 1); - Assert.assertTrue( + assertTrue( "Client X click cooridnate is lower than X middle button " + "coordinate", button.getLocation().getX() + button.getSize().getWidth() / 2 <= getValue("x") + 1); - Assert.assertTrue( + assertTrue( "Client Y click cooridnate is lower than Y middle button coordinate", button.getLocation().getY() + button.getSize().getHeight() / 2 <= getValue("y") diff --git a/uitest/src/test/java/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java index 7b298972a9..f4d793834f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/button/ButtonUndefinedWidthTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.button; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -97,13 +98,12 @@ public class ButtonUndefinedWidthTest extends MultiBrowserTest { } private void assertRowWrapperWidth(int wrapperWidth, int rowWidth) { - Assert.assertTrue("Wrapper should be narrower than its parent: " - + wrapperWidth + " < " + rowWidth, wrapperWidth < rowWidth); + assertTrue("Wrapper should be narrower than its parent: " + wrapperWidth + + " < " + rowWidth, wrapperWidth < rowWidth); } private void assertButtonWidth(int buttonWidth, int containerWidth) { - Assert.assertTrue("Button should be narrower than its parent: " - + buttonWidth + " < " + containerWidth, - buttonWidth < containerWidth); + assertTrue("Button should be narrower than its parent: " + buttonWidth + + " < " + containerWidth, buttonWidth < containerWidth); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java index 0c44732ee4..5bbd243f45 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.checkbox; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; @@ -37,17 +38,17 @@ public class CheckboxContextClickTest extends MultiBrowserTest { public void contextClickCheckboxAndText() { openTestURL(); CheckBoxElement checkbox = $(CheckBoxElement.class).first(); - Assert.assertEquals("checked", checkbox.getValue()); + assertEquals("checked", checkbox.getValue()); WebElement input = checkbox.findElement(By.xpath("input")); WebElement label = checkbox.findElement(By.xpath("label")); contextClickElement(input); - Assert.assertEquals("1. checkbox context clicked", getLogRow(0)); - Assert.assertEquals("checked", checkbox.getValue()); + assertEquals("1. checkbox context clicked", getLogRow(0)); + assertEquals("checked", checkbox.getValue()); contextClickElement(label); - Assert.assertEquals("2. checkbox context clicked", getLogRow(0)); - Assert.assertEquals("checked", checkbox.getValue()); + assertEquals("2. checkbox context clicked", getLogRow(0)); + assertEquals("checked", checkbox.getValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxFocusClickTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxFocusClickTest.java index 63d54ff372..b478bb123f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxFocusClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckboxFocusClickTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.checkbox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -29,10 +30,10 @@ public class CheckboxFocusClickTest extends MultiBrowserTest { public void contextClickCheckboxAndText() { openTestURL(); CheckBoxElement checkbox = $(CheckBoxElement.class).first(); - Assert.assertEquals("checked", checkbox.getValue()); + assertEquals("checked", checkbox.getValue()); WebElement label = checkbox.findElement(By.xpath("label")); label.click(); - Assert.assertEquals("1. checkbox focused", getLogRow(0)); + assertEquals("1. checkbox focused", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupFocusBlurTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupFocusBlurTest.java index 2f3c8b8cd1..7554b167b4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupFocusBlurTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupFocusBlurTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.checkboxgroup; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -44,11 +46,11 @@ public class CheckBoxGroupFocusBlurTest extends MultiBrowserTest { $(CheckBoxGroupElement.class).first().selectByText("1"); // Focus event is fired - Assert.assertTrue(logContainsText("1. Focus Event")); + assertTrue(logContainsText("1. Focus Event")); $(CheckBoxGroupElement.class).first().selectByText("2"); // click on the second checkbox doesn't fire anything - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // move the cursor to the middle of the first element, // offset to the middle of the two and perform click @@ -59,32 +61,32 @@ public class CheckBoxGroupFocusBlurTest extends MultiBrowserTest { .click().build().perform(); // no new events - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // click to label of a checkbox $(CheckBoxGroupElement.class).first().findElements(By.tagName("label")) .get(2).click(); // no new events - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // click on log label => blur $(LabelElement.class).first().click(); // blur event is fired - Assert.assertTrue(logContainsText("2. Blur Event")); + assertTrue(logContainsText("2. Blur Event")); $(CheckBoxGroupElement.class).first().selectByText("4"); // Focus event is fired - Assert.assertTrue(logContainsText("3. Focus Event")); + assertTrue(logContainsText("3. Focus Event")); // move keyboard focus to the next checkbox checkBoxes.get(3).sendKeys(Keys.TAB); // no new events - Assert.assertFalse(logContainsText("4.")); + assertFalse(logContainsText("4.")); // select the next checkbox checkBoxes.get(4).sendKeys(Keys.SPACE); // no new events - Assert.assertFalse(logContainsText("4.")); + assertFalse(logContainsText("4.")); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java index 0aade000fd..73c688659e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.checkboxgroup; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.CheckBoxGroupElement; @@ -27,6 +28,6 @@ public class CheckBoxGroupInGridLayoutTest extends MultiBrowserTest { ok = (before == after + 4); } - Assert.assertTrue("GridLayout size changed when selecting a value", ok); + assertTrue("GridLayout size changed when selecting a value", ok); } } 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 adfe9dcc3a..356f544f2d 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 @@ -96,21 +96,21 @@ public class CheckBoxGroupTest extends MultiBrowserTest { selectMenuPath("Component", "Listeners", "Selection listener"); getSelect().selectByText("Item 4"); - Assert.assertEquals("1. Selected: [Item 4]", getLogRow(0)); + assertEquals("1. Selected: [Item 4]", getLogRow(0)); getSelect().selectByText("Item 2"); // Selection order (most recently selected is last) - Assert.assertEquals("2. Selected: [Item 4, Item 2]", getLogRow(0)); + assertEquals("2. Selected: [Item 4, Item 2]", getLogRow(0)); getSelect().selectByText("Item 4"); - Assert.assertEquals("3. Selected: [Item 2]", getLogRow(0)); + assertEquals("3. Selected: [Item 2]", getLogRow(0)); } @Test public void disabled_clickToSelect() { selectMenuPath("Component", "State", "Enabled"); - Assert.assertTrue(getSelect().findElements(By.tagName("input")).stream() + assertTrue(getSelect().findElements(By.tagName("input")).stream() .allMatch(element -> element.getAttribute("disabled") != null)); selectMenuPath("Component", "Listeners", "Selection listener"); @@ -118,14 +118,14 @@ public class CheckBoxGroupTest extends MultiBrowserTest { String lastLogRow = getLogRow(0); getSelect().selectByText("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); getSelect().selectByText("Item 2"); // Selection order (most recently selected is last) - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); getSelect().selectByText("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); } @Test @@ -138,13 +138,13 @@ public class CheckBoxGroupTest extends MultiBrowserTest { selectMenuPath("Component", "State", "Enabled"); getSelect().selectByText("Item 5"); - Assert.assertEquals("3. Selected: [Item 5]", getLogRow(0)); + assertEquals("3. Selected: [Item 5]", getLogRow(0)); getSelect().selectByText("Item 2"); - Assert.assertEquals("4. Selected: [Item 5, Item 2]", getLogRow(0)); + assertEquals("4. Selected: [Item 5, Item 2]", getLogRow(0)); getSelect().selectByText("Item 5"); - Assert.assertEquals("5. Selected: [Item 2]", getLogRow(0)); + assertEquals("5. Selected: [Item 2]", getLogRow(0)); } @Test @@ -159,7 +159,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { selectMenuPath("Component", "Item Generator", "Item Caption Generator", "Null Caption Generator"); for (String text : getSelect().getOptions()) { - Assert.assertEquals("", text); + assertEquals("", text); } } @@ -170,9 +170,9 @@ public class CheckBoxGroupTest extends MultiBrowserTest { assertItemSuffices(20); List<WebElement> icons = getSelect() .findElements(By.cssSelector(".v-select-optiongroup .v-icon")); - Assert.assertTrue(icons.size() > 0); + assertTrue(icons.size() > 0); for (int i = 0; i < icons.size(); i++) { - Assert.assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), + assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), icons.get(i).getText().charAt(0)); } } @@ -182,17 +182,17 @@ public class CheckBoxGroupTest extends MultiBrowserTest { selectMenuPath("Component", "Listeners", "Selection listener"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("2. Selected: [Item 5]", getLogRow(0)); + assertEquals("2. Selected: [Item 5]", getLogRow(0)); assertSelected("Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 1"); // Selection order (most recently selected is last) - Assert.assertEquals("4. Selected: [Item 5, Item 1]", getLogRow(0)); + assertEquals("4. Selected: [Item 5, Item 1]", getLogRow(0)); // DOM order assertSelected("Item 1", "Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("6. Selected: [Item 1]", getLogRow(0)); + assertEquals("6. Selected: [Item 1]", getLogRow(0)); assertSelected("Item 1"); } @@ -205,7 +205,7 @@ public class CheckBoxGroupTest extends MultiBrowserTest { label = (TestBenchElement) findElements(By.tagName("label")).get(5); label.showTooltip(); - Assert.assertEquals("Tooltip should contain the same text as caption", + assertEquals("Tooltip should contain the same text as caption", label.getText(), getTooltipElement().getText()); selectMenuPath("Component", "Item Description Generator", @@ -213,13 +213,13 @@ public class CheckBoxGroupTest extends MultiBrowserTest { label = (TestBenchElement) findElements(By.tagName("label")).get(5); label.showTooltip(); - Assert.assertEquals("Tooltip should contain caption + ' Description'", + assertEquals("Tooltip should contain caption + ' Description'", label.getText() + " Description", getTooltipElement().getText()); } private void assertSelected(String... expectedSelection) { - Assert.assertEquals(Arrays.asList(expectedSelection), + assertEquals(Arrays.asList(expectedSelection), getSelect().getValue()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java index f8fcbdda0f..59b0caaba5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.checkboxgroup; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.CheckBoxGroupElement; @@ -34,10 +35,10 @@ public class DisabledCheckBoxGroupTest extends MultiBrowserTest { openTestURL(); List<String> options = $(CheckBoxGroupElement.class).first() .getOptions(); - Assert.assertEquals(3, options.size()); - Assert.assertEquals("a", options.get(0)); - Assert.assertEquals("b", options.get(1)); - Assert.assertEquals("c", options.get(2)); + assertEquals(3, options.size()); + assertEquals("a", options.get(0)); + assertEquals("b", options.get(1)); + assertEquals("c", options.get(2)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerGridUITest.java b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerGridUITest.java index f1a44a1779..c6b3b70a4f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerGridUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/ColorPickerGridUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.colorpicker; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -36,8 +37,7 @@ public class ColorPickerGridUITest extends SingleBrowserTest { // check that the color picker does not have component error set if (hasCssClass(grid, "v-colorpicker-grid-error")) { - Assert.fail( - "ColorPickerGrid should not have an active component error"); + fail("ColorPickerGrid should not have an active component error"); } } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java index 1cce6b1827..a575e909d9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/colorpicker/DefaultCaptionWidthTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.colorpicker; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -56,10 +58,10 @@ public class DefaultCaptionWidthTest extends MultiBrowserTest { String clazz = $(ColorPickerElement.class).first() .getAttribute("class"); if (expectedStyle) { - Assert.assertTrue("Default caption style is not found", + assertTrue("Default caption style is not found", clazz.contains("v-default-caption-width")); } else { - Assert.assertFalse("Found unexpected default caption style", + assertFalse("Found unexpected default caption style", clazz.contains("v-default-caption-width")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAutoresetValueTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAutoresetValueTest.java index 42d28165a7..f803853e6a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAutoresetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAutoresetValueTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ComboBoxElement; @@ -29,31 +30,28 @@ public class ComboBoxAutoresetValueTest extends SingleBrowserTest { ComboBoxElement comboBox = $(ComboBoxElement.class).first(); - Assert.assertEquals("", comboBox.getValue()); + assertEquals("", comboBox.getValue()); comboBox.selectByText(ComboBoxAutoresetValue.RESET); assertLogChange(1, ComboBoxAutoresetValue.RESET, 1); assertLogChange(2, null, 0); - Assert.assertEquals("", comboBox.getValue()); + assertEquals("", comboBox.getValue()); comboBox.selectByText(ComboBoxAutoresetValue.CHANGE); assertLogChange(3, ComboBoxAutoresetValue.CHANGE, 1); assertLogChange(4, ComboBoxAutoresetValue.SOMETHING, 0); - Assert.assertEquals(ComboBoxAutoresetValue.SOMETHING, - comboBox.getValue()); + assertEquals(ComboBoxAutoresetValue.SOMETHING, comboBox.getValue()); comboBox.selectByText(ComboBoxAutoresetValue.SOMETHING); // No new log items assertLogChange(4, ComboBoxAutoresetValue.SOMETHING, 0); - Assert.assertEquals(ComboBoxAutoresetValue.SOMETHING, - comboBox.getValue()); + assertEquals(ComboBoxAutoresetValue.SOMETHING, comboBox.getValue()); } private void assertLogChange(int sequenceNumber, String expectedValue, int rowIndex) { - Assert.assertEquals( - sequenceNumber + ". Value changed to " + expectedValue, + assertEquals(sequenceNumber + ". Value changed to " + expectedValue, getLogRow(rowIndex)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxClickIconTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxClickIconTest.java index a20968986c..20fba51cba 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxClickIconTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxClickIconTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -41,7 +42,7 @@ public class ComboBoxClickIconTest extends MultiBrowserTest { clickElement(getDriver().findElement(By.className("v-filterselect")) .findElement(By.className("v-icon"))); - Assert.assertTrue("Unable to find menu items in combobox popup", + assertTrue("Unable to find menu items in combobox popup", isElementPresent(By.className("gwt-MenuItem"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcutTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcutTest.java index bff1b9843d..fb967819f9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcutTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Keys; @@ -29,9 +30,8 @@ public class ComboBoxCombinedWithEnterShortcutTest extends MultiBrowserTest { ComboBoxElement cb = $(ComboBoxElement.class).first(); cb.click(); cb.sendKeys(500, Keys.DOWN, Keys.DOWN, Keys.DOWN, Keys.ENTER); - Assert.assertEquals("", getLogRow(0).trim()); + assertEquals("", getLogRow(0).trim()); cb.sendKeys(Keys.ENTER); - Assert.assertEquals("1. Button clicked. ComboBox value: Berlin", - getLogRow(0)); + assertEquals("1. Button clicked. ComboBox value: Berlin", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxEmptyCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxEmptyCaptionTest.java index 0efea9cae9..54de29af0f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxEmptyCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxEmptyCaptionTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.combobox; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.Arrays; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.Keys; @@ -80,20 +81,19 @@ public class ComboBoxEmptyCaptionTest extends MultiBrowserTest { public void emptyItemCaptionInTextBox() { ComboBoxElement combo = $(ComboBoxElement.class).first(); - Assert.assertEquals("", combo.getInputField().getAttribute("value")); + assertEquals("", combo.getInputField().getAttribute("value")); // set some caption for the empty selection element $(ButtonElement.class).first().click(); - Assert.assertEquals("empty", - combo.getInputField().getAttribute("value")); + assertEquals("empty", combo.getInputField().getAttribute("value")); } private void ensureSuggestions(ComboBoxElement element, String... suggestions) { element.openPopup(); - Assert.assertEquals(Arrays.asList(suggestions), + assertEquals(Arrays.asList(suggestions), new ArrayList<>(element.getPopupSuggestions())); // Close popup new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemIconTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemIconTest.java index 7011a58179..e5df4ad827 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemIconTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemIconTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Keys; @@ -61,11 +62,11 @@ public class ComboBoxItemIconTest extends MultiBrowserTest { private void assertSelection(ComboBoxElement cb, String imageSuffix, String caption) { - Assert.assertEquals(caption, cb.getValue()); + assertEquals(caption, cb.getValue()); String imgSrc = cb.findElement(By.className("v-icon")) .getAttribute("src"); imgSrc = imgSrc.substring(imgSrc.lastIndexOf('/') + 1); - Assert.assertEquals(imageSuffix, imgSrc); + assertEquals(imageSuffix, imgSrc); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java index bb839eb591..668851ac3e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.combobox; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -40,13 +41,13 @@ public class ComboBoxItemStyleGeneratorTest extends SingleBrowserTest { List<WebElement> boldItems = findElements( By.className("v-filterselect-item-bold")); - Assert.assertEquals(1, boldItems.size()); - Assert.assertEquals("Item 5", boldItems.get(0).getText()); + assertEquals(1, boldItems.size()); + assertEquals("Item 5", boldItems.get(0).getText()); selectMenuPath("Component", "Features", "Item style generator", "-"); boldItems = findElements(By.className("v-filterselect-item-bold")); - Assert.assertEquals(0, boldItems.size()); + assertEquals(0, boldItems.size()); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java index 0f7d858e63..4979212070 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java @@ -15,14 +15,15 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; import com.vaadin.testbench.commands.TestBenchElementCommands; -import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class ComboBoxNoTextInputTest extends MultiBrowserTest { @@ -51,7 +52,7 @@ public class ComboBoxNoTextInputTest extends MultiBrowserTest { click(cb); // popup is opened lazily sleep(1000); - Assert.assertFalse(cb.isElementPresent(By.vaadin("#popup"))); + assertFalse(cb.isElementPresent(By.vaadin("#popup"))); } private void click(ComboBoxElement cb) throws Exception { diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java index 682712dcbb..ffe48912e1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupPositionEmbeddedInDivTest.java @@ -15,8 +15,9 @@ */ package com.vaadin.tests.components.combobox; +import static org.junit.Assert.assertTrue; + import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; @@ -43,10 +44,10 @@ public class ComboBoxPopupPositionEmbeddedInDivTest extends MultiBrowserTest { Point comboboxLocation = combobox.getLocation(); Point popupLocation = popup.getLocation(); - Assert.assertTrue("Popup should be below combobox", + assertTrue("Popup should be below combobox", popupLocation.getY() > comboboxLocation.getY()); - Assert.assertTrue("Popup should be left aligned with the combobox", + assertTrue("Popup should be left aligned with the combobox", popupLocation.getX() == comboboxLocation.getX()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrollsTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrollsTest.java index 9ff02b6f2d..7ca2c8f6dd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrollsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrollsTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -34,7 +35,6 @@ public class ComboBoxPopupWhenBodyScrollsTest extends MultiBrowserTest { int comboboxTop = combobox.getLocation().getY(); int popupTop = popup.getLocation().getY(); - Assert.assertTrue("Popup should be below combobox", - popupTop > comboboxTop); + assertTrue("Popup should be below combobox", popupTop > comboboxTop); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java index 616c9a8e82..dfb55e4a07 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingTest.java @@ -2,8 +2,8 @@ package com.vaadin.tests.components.combobox; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; @@ -34,7 +34,7 @@ public class ComboBoxSelectingTest extends MultiBrowserTest { int initialVisibleOptions = countVisibleOptions(); clearInputAndType("b11"); int visibleOptionsAfterFiltering = countVisibleOptions(); - Assert.assertEquals(1, visibleOptionsAfterFiltering); + assertEquals(1, visibleOptionsAfterFiltering); clickOnLabel(); sleep(1000); // no selection was made, clicking on arrow should show all options @@ -42,7 +42,7 @@ public class ComboBoxSelectingTest extends MultiBrowserTest { comboBoxElement.openPopup(); int visibleOptions = countVisibleOptions(); - Assert.assertEquals(initialVisibleOptions, visibleOptions); + assertEquals(initialVisibleOptions, visibleOptions); } private int countVisibleOptions() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java index 1d2aa64237..1d94993d89 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -41,7 +42,7 @@ public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest { openPopup(); MenuBarElement menuBar = selectMenuBar(); menuBar.click(); - Assert.assertFalse("Combobox popup items are visible", + assertFalse("Combobox popup items are visible", isElementPresent(By.className("gwt-MenuItem"))); openPopup(); @@ -52,7 +53,7 @@ public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest { Actions actions = new Actions(getDriver()); actions.moveToElement(menuBarItem).build().perform(); menuBar.click(); - Assert.assertFalse("Combobox popup items are visible", + assertFalse("Combobox popup items are visible", isElementPresent(By.className("gwt-MenuItem"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java index 3a94153eb8..d3ed5607ec 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Point; @@ -65,9 +67,9 @@ public class ComboboxPopupScrollingTest extends MultiBrowserTest { Point newComboLocation = cb.getLocation(); Point newPopupLocation = popup.getLocation(); - Assert.assertNotEquals("ComboBox didn't move on the page", 0, + assertNotEquals("ComboBox didn't move on the page", 0, newComboLocation.y - comboLocation.y); - Assert.assertEquals("Popup didn't move with the combo box", + assertEquals("Popup didn't move with the combo box", newComboLocation.y - comboLocation.y, newPopupLocation.y - popupLocation.y); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/FilteringTurkishLocaleTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/FilteringTurkishLocaleTest.java index c95894112d..0b88d55fe6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/FilteringTurkishLocaleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/FilteringTurkishLocaleTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.combobox; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.By; @@ -35,7 +36,7 @@ public class FilteringTurkishLocaleTest extends MultiBrowserTest { List<String> suggestions = getFilterSuggestions("i"); - Assert.assertEquals("Both suggestions should be present", 2, + assertEquals("Both suggestions should be present", 2, suggestions.size()); } @@ -47,9 +48,9 @@ public class FilteringTurkishLocaleTest extends MultiBrowserTest { List<String> suggestions = getFilterSuggestions("i"); - Assert.assertEquals("There should be only one suggestion", 1, + assertEquals("There should be only one suggestion", 1, suggestions.size()); - Assert.assertEquals("İ dotted", suggestions.get(0)); + assertEquals("İ dotted", suggestions.get(0)); } @Test @@ -60,9 +61,9 @@ public class FilteringTurkishLocaleTest extends MultiBrowserTest { List<String> suggestions = getFilterSuggestions("ı"); - Assert.assertEquals("There should be only one suggestion", 1, + assertEquals("There should be only one suggestion", 1, suggestions.size()); - Assert.assertEquals("I dotless", suggestions.get(0)); + assertEquals("I dotless", suggestions.get(0)); } private List<String> getFilterSuggestions(String string) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/composite/CompositeChainUITest.java b/uitest/src/test/java/com/vaadin/tests/components/composite/CompositeChainUITest.java index 228d20f058..98171bde98 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/composite/CompositeChainUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/composite/CompositeChainUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.composite; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -32,11 +33,11 @@ public class CompositeChainUITest extends SingleBrowserTest { LabelElement label = $(LabelElement.class).id("innermost"); WebElement labelGrandParent = label.findElement(By.xpath("../..")); - Assert.assertEquals("v-slot", labelGrandParent.getAttribute("class")); - Assert.assertEquals("Label caption", label.getCaption()); + assertEquals("v-slot", labelGrandParent.getAttribute("class")); + assertEquals("Label caption", label.getCaption()); $(ButtonElement.class).caption("Update caption").first().click(); - Assert.assertEquals("Label caption - updated", label.getCaption()); + assertEquals("Label caption - updated", label.getCaption()); } @@ -45,11 +46,11 @@ public class CompositeChainUITest extends SingleBrowserTest { openTestURL("debug"); LabelElement label = $(LabelElement.class).id("innermost"); $(ButtonElement.class).caption("Update caption").first().click(); - Assert.assertEquals("Label caption - updated", label.getCaption()); + assertEquals("Label caption - updated", label.getCaption()); $(ButtonElement.class).caption("Replace with another Composite").first() .click(); label = $(LabelElement.class).id("innermost"); - Assert.assertEquals("Label caption", label.getCaption()); + assertEquals("Label caption", label.getCaption()); assertNoErrorNotifications(); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutUpdateCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutUpdateCaptionTest.java index c74595d300..272355557a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutUpdateCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutUpdateCaptionTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.components.customlayout; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -18,13 +19,13 @@ public class CustomLayoutUpdateCaptionTest extends SingleBrowserTest { TextFieldElement tf1 = tfs.get(0); TextFieldElement tf2 = tfs.get(1); - Assert.assertEquals("initial", tf1.getCaption()); - Assert.assertEquals("initial", tf2.getCaption()); + assertEquals("initial", tf1.getCaption()); + assertEquals("initial", tf2.getCaption()); $(ButtonElement.class).first().click(); - Assert.assertEquals("updated", tf1.getCaption()); - Assert.assertEquals("updated", tf2.getCaption()); + assertEquals("updated", tf1.getCaption()); + assertEquals("updated", tf2.getCaption()); } -}
\ No newline at end of file +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlotTest.java b/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlotTest.java index 498c097237..0713a66c08 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlotTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/customlayout/CustomLayoutWithMissingSlotTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.customlayout; +import static org.junit.Assert.assertEquals; + import java.util.logging.Level; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -29,10 +30,10 @@ public class CustomLayoutWithMissingSlotTest extends SingleBrowserTest { public void ensureRenderedWithoutErrors() { setDebug(true); openTestURL(); - Assert.assertEquals("", getLogRow(0).trim()); + assertEquals("", getLogRow(0).trim()); $(ButtonElement.class).first().click(); assertNoDebugMessage(Level.SEVERE); - Assert.assertEquals("1. Button clicked", getLogRow(0)); + assertEquals("1. Button clicked", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java b/uitest/src/test/java/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java index 20fdb5dfe3..ddfa903194 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/customlayout/OverflowAutoFixTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.customlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -35,7 +36,7 @@ public class OverflowAutoFixTest extends MultiBrowserTest { private void assertElementCssValueEquals(String className, String propertyName, String expected) { - Assert.assertEquals( + assertEquals( String.format( "Unexpected value for property '%s' on element '%s',", propertyName, className), diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldElementTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldElementTest.java index 29a05187bc..de0cbaecd0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldElementTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldElementTest.java @@ -2,10 +2,11 @@ package com.vaadin.tests.components.datefield; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.time.LocalDate; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.DateFieldElement; @@ -29,32 +30,30 @@ public class DateFieldElementTest extends SingleBrowserTest { // No date set DateFieldElement defaultInitiallyEmpty = $(DateFieldElement.class) .first(); - Assert.assertNull(defaultInitiallyEmpty.getDate()); + assertNull(defaultInitiallyEmpty.getDate()); defaultInitiallyEmpty.setDate(DateFieldElementUI.TEST_DATE_TIME); - Assert.assertEquals(DateFieldElementUI.TEST_DATE_TIME, + assertEquals(DateFieldElementUI.TEST_DATE_TIME, defaultInitiallyEmpty.getDate()); assertServerValue("Default date field", DateFieldElementUI.TEST_DATE_TIME); DateFieldElement fi = $(DateFieldElement.class).id("fi"); - Assert.assertEquals(DateFieldElementUI.TEST_DATE_TIME, fi.getDate()); + assertEquals(DateFieldElementUI.TEST_DATE_TIME, fi.getDate()); fi.setDate(DateFieldElementUI.ANOTHER_TEST_DATE_TIME); - Assert.assertEquals(DateFieldElementUI.ANOTHER_TEST_DATE_TIME, - fi.getDate()); + assertEquals(DateFieldElementUI.ANOTHER_TEST_DATE_TIME, fi.getDate()); assertServerValue("Finnish date field", DateFieldElementUI.ANOTHER_TEST_DATE_TIME); DateFieldElement us = $(DateFieldElement.class).id("us"); - Assert.assertEquals(DateFieldElementUI.TEST_DATE_TIME, us.getDate()); + assertEquals(DateFieldElementUI.TEST_DATE_TIME, us.getDate()); us.setDate(DateFieldElementUI.ANOTHER_TEST_DATE_TIME); - Assert.assertEquals(DateFieldElementUI.ANOTHER_TEST_DATE_TIME, - us.getDate()); + assertEquals(DateFieldElementUI.ANOTHER_TEST_DATE_TIME, us.getDate()); assertServerValue("US date field", DateFieldElementUI.ANOTHER_TEST_DATE_TIME); } private void assertServerValue(String id, LocalDate testDateTime) { - Assert.assertEquals(id + " value set to " + testDateTime.toString(), + assertEquals(id + " value set to " + testDateTime.toString(), getLogRow(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFastForwardTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFastForwardTest.java index f794cfb904..d0c0be734d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFastForwardTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFastForwardTest.java @@ -16,8 +16,8 @@ package com.vaadin.tests.components.datefield; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -50,7 +50,7 @@ public class DateFieldFastForwardTest extends MultiBrowserTest { // Make browser context menu disappear, since it will crash IE $(VerticalLayoutElement.class).first().click(); - Assert.assertFalse("Month did not change during fast forward", + assertFalse("Month did not change during fast forward", firstMonth.equals(expectedMonth)); // Wait for a while. diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFaultyInputNotValidTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFaultyInputNotValidTest.java index 1fd335b671..3a3b6cd069 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFaultyInputNotValidTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFaultyInputNotValidTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.components.datefield; +import static org.junit.Assert.assertEquals; + import java.time.LocalDate; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.interactions.Actions; @@ -18,7 +19,7 @@ public class DateFieldFaultyInputNotValidTest extends SingleBrowserTest { public void testEmptyDateFieldOK() { openTestURL(); $(ButtonElement.class).first().click(); - Assert.assertEquals("Empty DateField should be ok", "OK", + assertEquals("Empty DateField should be ok", "OK", $(NotificationElement.class).first().getText()); } @@ -29,7 +30,7 @@ public class DateFieldFaultyInputNotValidTest extends SingleBrowserTest { dateField.setDate(LocalDate.now()); $(ButtonElement.class).first().click(); - Assert.assertEquals("Current date should be ok", "OK", + assertEquals("Current date should be ok", "OK", $(NotificationElement.class).first().getText()); $(NotificationElement.class).first().close(); @@ -37,7 +38,7 @@ public class DateFieldFaultyInputNotValidTest extends SingleBrowserTest { new Actions(getDriver()).sendKeys("asd").perform(); $(ButtonElement.class).first().click(); - Assert.assertEquals("Added 'asd' should make date not parse correctly.", + assertEquals("Added 'asd' should make date not parse correctly.", "Fail", $(NotificationElement.class).first().getText()); } @@ -48,14 +49,14 @@ public class DateFieldFaultyInputNotValidTest extends SingleBrowserTest { dateField.setDate(LocalDate.now()); $(ButtonElement.class).first().click(); - Assert.assertEquals("Current date should be ok", "OK", + assertEquals("Current date should be ok", "OK", $(NotificationElement.class).first().getText()); $(NotificationElement.class).first().close(); dateField.setDate(LocalDate.now().minusDays(7)); $(ButtonElement.class).first().click(); - Assert.assertEquals("Last week should not be ok", "Fail", + assertEquals("Last week should not be ok", "Fail", $(NotificationElement.class).first().getText()); } @@ -66,7 +67,7 @@ public class DateFieldFaultyInputNotValidTest extends SingleBrowserTest { $(DateFieldElement.class).first().setDate(LocalDate.now()); $(ButtonElement.class).first().click(); - Assert.assertEquals("Current date should be ok", "OK", + assertEquals("Current date should be ok", "OK", $(NotificationElement.class).first().getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldIsValidTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldIsValidTest.java index dacbae3db1..b259e6573b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldIsValidTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldIsValidTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -59,7 +60,7 @@ public class DateFieldIsValidTest extends MultiBrowserTest { private void assertLogText(String expected) throws Exception { String text = findElement(By.vaadin("PID_SLog_row_0")).getText(); - Assert.assertTrue("Expected '" + expected + "' found '" + text + "'", + assertTrue("Expected '" + expected + "' found '" + text + "'", text.equals(expected)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldTestTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldTestTest.java index a66018b7dd..d9d2a3e206 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldTestTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldTestTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -45,7 +47,7 @@ public class DateFieldTestTest extends MultiBrowserTest { private void assertNoErrorNotification() { if (isElementPresent(NotificationElement.class)) { - Assert.fail("Notification was present"); + fail("Notification was present"); } } @@ -76,7 +78,7 @@ public class DateFieldTestTest extends MultiBrowserTest { openPopup(); closePopup(); String actual = getInput().getAttribute("value"); - Assert.assertEquals(inputtedValue, actual); + assertEquals(inputtedValue, actual); assertNoErrorNotification(); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParentTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParentTest.java index 74b6825915..79c2431aa0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParentTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -68,11 +70,10 @@ public class DateFieldWhenChangingValueAndEnablingParentTest boolean hasClass = hasCssClass(id, "v-disabled"); boolean fieldEnabled = !hasClass; if (assertEnabled) { - Assert.assertTrue( - "Field " + id.getAttribute("id") + " should be enabled", + assertTrue("Field " + id.getAttribute("id") + " should be enabled", fieldEnabled); } else { - Assert.assertFalse( + assertFalse( "Field " + id.getAttribute("id") + " should be disabled", fieldEnabled); } @@ -86,12 +87,12 @@ public class DateFieldWhenChangingValueAndEnablingParentTest boolean textinputEnabled = (disabledAttr == null); if (enabled) { - Assert.assertTrue( + assertTrue( "Field " + id.getAttribute("id") + " text field should be enabled", textinputEnabled); } else { - Assert.assertFalse( + assertFalse( "Field " + id.getAttribute("id") + " text field should be disabled", textinputEnabled); diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldElementTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldElementTest.java index 2138fb5df0..dd0cc8d4f8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldElementTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldElementTest.java @@ -2,10 +2,11 @@ package com.vaadin.tests.components.datefield; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.time.LocalDateTime; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.DateTimeFieldElement; @@ -29,35 +30,33 @@ public class DateTimeFieldElementTest extends SingleBrowserTest { // No date set DateTimeFieldElement defaultInitiallyEmpty = $( DateTimeFieldElement.class).first(); - Assert.assertNull(defaultInitiallyEmpty.getDateTime()); + assertNull(defaultInitiallyEmpty.getDateTime()); defaultInitiallyEmpty .setDateTime(DateTimeFieldElementUI.TEST_DATE_TIME); - Assert.assertEquals(DateTimeFieldElementUI.TEST_DATE_TIME, + assertEquals(DateTimeFieldElementUI.TEST_DATE_TIME, defaultInitiallyEmpty.getDateTime()); assertServerValue("Default date field", DateTimeFieldElementUI.TEST_DATE_TIME); DateTimeFieldElement fi = $(DateTimeFieldElement.class).id("fi"); - Assert.assertEquals(DateTimeFieldElementUI.TEST_DATE_TIME, - fi.getDateTime()); + assertEquals(DateTimeFieldElementUI.TEST_DATE_TIME, fi.getDateTime()); fi.setDateTime(DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME); - Assert.assertEquals(DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME, + assertEquals(DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME, fi.getDateTime()); assertServerValue("Finnish date field", DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME); DateTimeFieldElement us = $(DateTimeFieldElement.class).id("us"); - Assert.assertEquals(DateTimeFieldElementUI.TEST_DATE_TIME, - us.getDateTime()); + assertEquals(DateTimeFieldElementUI.TEST_DATE_TIME, us.getDateTime()); us.setDateTime(DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME); - Assert.assertEquals(DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME, + assertEquals(DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME, us.getDateTime()); assertServerValue("US date field", DateTimeFieldElementUI.ANOTHER_TEST_DATE_TIME); } private void assertServerValue(String id, LocalDateTime testDateTime) { - Assert.assertEquals(id + " value set to " + testDateTime.toString(), + assertEquals(id + " value set to " + testDateTime.toString(), getLogRow(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldFastForwardTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldFastForwardTest.java index f42afe1779..90ca8b72fb 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldFastForwardTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldFastForwardTest.java @@ -16,8 +16,8 @@ package com.vaadin.tests.components.datefield; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -50,7 +50,7 @@ public class DateTimeFieldFastForwardTest extends MultiBrowserTest { // Make browser context menu disappear, since it will crash IE $(VerticalLayoutElement.class).first().click(); - Assert.assertFalse("Month did not change during fast forward", + assertFalse("Month did not change during fast forward", firstMonth.equals(expectedMonth)); // Wait for a while. diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldIsValidTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldIsValidTest.java index 06e8a146c0..8671b9d755 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldIsValidTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldIsValidTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -59,7 +60,7 @@ public class DateTimeFieldIsValidTest extends MultiBrowserTest { private void assertLogText(String expected) throws Exception { String text = findElement(By.vaadin("PID_SLog_row_0")).getText(); - Assert.assertTrue("Expected '" + expected + "' found '" + text + "'", + assertTrue("Expected '" + expected + "' found '" + text + "'", text.equals(expected)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldTestTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldTestTest.java index e835ac5158..30603c11f8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldTestTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldTestTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -49,7 +51,7 @@ public class DateTimeFieldTestTest extends MultiBrowserTest { private void assertNoErrorNotification() { if (isElementPresent(NotificationElement.class)) { - Assert.fail("Notification was present"); + fail("Notification was present"); } } @@ -80,7 +82,7 @@ public class DateTimeFieldTestTest extends MultiBrowserTest { openPopup(); closePopup(); String actual = getInput().getAttribute("value"); - Assert.assertEquals(inputtedValue, actual); + assertEquals(inputtedValue, actual); assertNoErrorNotification(); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldWeekDaysTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldWeekDaysTest.java index ebe6220a14..6e61140032 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldWeekDaysTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldWeekDaysTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -43,7 +45,8 @@ public class DateTimeFieldWeekDaysTest extends SingleBrowserTest { $(CheckBoxElement.class).first().click(); - Assert.assertFalse("Checkbox is selected even though should be unselected.", $(CheckBoxElement.class).first().isChecked()); + assertFalse("Checkbox is selected even though should be unselected.", + $(CheckBoxElement.class).first().isChecked()); openPopupAndValidateNoWeeknumbers(); } @@ -81,10 +84,10 @@ public class DateTimeFieldWeekDaysTest extends SingleBrowserTest { waitUntil(ExpectedConditions.visibilityOfElementLocated( org.openqa.selenium.By.className("v-datefield-popup"))); - Assert.assertFalse("No week numbers found for date field!", + assertFalse("No week numbers found for date field!", findElements( By.className("v-datefield-calendarpanel-weeknumber")) - .isEmpty()); + .isEmpty()); // Close popup popupButton.click(); } @@ -98,10 +101,10 @@ public class DateTimeFieldWeekDaysTest extends SingleBrowserTest { waitUntil(ExpectedConditions.visibilityOfElementLocated( org.openqa.selenium.By.className("v-datefield-popup"))); - Assert.assertTrue("Week numbers still found in calendar popup!", + assertTrue("Week numbers still found in calendar popup!", findElements( By.className("v-datefield-calendarpanel-weeknumber")) - .isEmpty()); + .isEmpty()); // Close popup popupButton.click(); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java index 26daf45a5d..9db0949daa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledDateFieldPopupTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.datefield; +import static org.junit.Assert.assertFalse; + import java.io.IOException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -44,7 +45,7 @@ public class DisabledDateFieldPopupTest extends MultiBrowserTest { new Actions(driver).moveToElement(button).click() .sendKeys(Keys.ARROW_DOWN).perform(); - Assert.assertFalse( + assertFalse( "Calendar popup should not be opened for disabled date field", isElementPresent(By.className("v-datefield-popup"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java index 84cb6f3e05..47c62b57c4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -39,7 +42,7 @@ public class DisabledParentLayoutTest extends MultiBrowserTest { .findElement(By.className("v-datefield-textfield")); textField.click(); - Assert.assertFalse( + assertFalse( "Date input text field shoud be disabled for disabled DateField", textField.isEnabled()); @@ -47,13 +50,12 @@ public class DisabledParentLayoutTest extends MultiBrowserTest { .findElement(By.className("v-datefield-button")); dataFieldButton.click(); - Assert.assertFalse( - "Disabled date popup is opened after click to its button", + assertFalse("Disabled date popup is opened after click to its button", isElementPresent(By.className("v-datefield-popup"))); button.click(); - Assert.assertTrue( + assertTrue( "Date input text field should be enabled for enabled DateField", textField.isEnabled()); @@ -61,15 +63,16 @@ public class DisabledParentLayoutTest extends MultiBrowserTest { String text = "text"; textField.sendKeys(text); - Assert.assertEquals("Unexpected text in date text field", text, + assertEquals("Unexpected text in date text field", text, textField.getAttribute("value")); dataFieldButton.click(); - dataFieldButton.click();//Requires two clicks because of error message. TODO fix - Assert.assertFalse("Unexpected disabled element found", + dataFieldButton.click();// Requires two clicks because of error message. + // TODO fix + assertFalse("Unexpected disabled element found", isElementPresent(By.className("v-disabled"))); - Assert.assertTrue("Date popup is not opened after click to its button", + assertTrue("Date popup is not opened after click to its button", isElementPresent(By.className("v-datefield-popup"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/ReindeerDateFieldPopupPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/ReindeerDateFieldPopupPositionTest.java index f264f99320..d676955b0e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/ReindeerDateFieldPopupPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/ReindeerDateFieldPopupPositionTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.openqa.selenium.WebElement; import com.vaadin.testbench.elements.DateFieldElement; @@ -36,7 +37,7 @@ public class ReindeerDateFieldPopupPositionTest int right = field.getLocation().getX() + field.getSize().getWidth(); WebElement popup = getPopup(); - Assert.assertTrue( + assertTrue( "Calendar popup has wrong X coordinate=" + popup.getLocation().getX() + " , right side of the field is " + right, diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/TimePopupSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/TimePopupSelectionTest.java index b10f2299c5..3b299f6308 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/TimePopupSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/TimePopupSelectionTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.datefield; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -38,7 +39,7 @@ public class TimePopupSelectionTest extends MultiBrowserTest { openTestURL(); DateTimeFieldElement field = $(DateTimeFieldElement.class).first(); - Assert.assertEquals("1/13/17 01:00:00 AM", field.getValue()); + assertEquals("1/13/17 01:00:00 AM", field.getValue()); field.openPopup(); @@ -47,13 +48,13 @@ public class TimePopupSelectionTest extends MultiBrowserTest { .findElements(By.tagName("select")); new Select(timeSelects.get(0)).selectByValue("09"); - Assert.assertEquals("1/13/17 09:00:00 AM", field.getValue()); + assertEquals("1/13/17 09:00:00 AM", field.getValue()); new Select(timeSelects.get(1)).selectByValue("35"); - Assert.assertEquals("1/13/17 09:35:00 AM", field.getValue()); + assertEquals("1/13/17 09:35:00 AM", field.getValue()); new Select(timeSelects.get(2)).selectByValue("41"); - Assert.assertEquals("1/13/17 09:35:41 AM", field.getValue()); + assertEquals("1/13/17 09:35:41 AM", field.getValue()); closePopup(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java index 19dcc636ce..434e8d7063 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.datefield; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.openqa.selenium.WebElement; import com.vaadin.testbench.elements.DateFieldElement; @@ -37,7 +38,7 @@ public class ValoDateFieldPopupPositionTest extends DateFieldPopupPositionTest { int popupRight = popup.getLocation().getX() + popup.getSize().getWidth(); - Assert.assertTrue( + assertTrue( "Calendar popup has wrong X coordinate=" + popupRight + " , left side of the field is " + left, popupRight <= left); diff --git a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java index d0aa567e20..0fb55a77c5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropFocusObtainTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.draganddropwrapper; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.AbstractTextFieldElement; @@ -39,13 +40,13 @@ public class DragAndDropFocusObtainTest extends MultiBrowserTest { .all()) { String caption = ta.getCaption(); ta.click(); - Assert.assertEquals(index + ". Field '" + caption + "' focused", + assertEquals(index + ". Field '" + caption + "' focused", getLogRow(0)); index++; } // Make sure we checked all fields - Assert.assertEquals(8 + 1, index); + assertEquals(8 + 1, index); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java index fee9d5de30..6ff7b31109 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.draganddropwrapper; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -48,9 +49,9 @@ public class DragAndDropRelativeWidthTest extends MultiBrowserTest { WebElement dragImage = getDriver() .findElement(By.className("v-drag-element")); - Assert.assertEquals("Drag image element height is unexpected", height, + assertEquals("Drag image element height is unexpected", height, dragImage.getSize().getHeight()); - Assert.assertEquals("Drag image element width is unexpected", width, + assertEquals("Drag image element width is unexpected", width, dragImage.getSize().getWidth()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropTextAreaTest.java b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropTextAreaTest.java index 349413f043..6374bd069b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropTextAreaTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropTextAreaTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.draganddropwrapper; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; @@ -54,8 +55,8 @@ public class DragAndDropTextAreaTest extends MultiBrowserTest { } } - Assert.assertTrue( - "Text value is not found in the DnD image of text area", found); + assertTrue("Text value is not found in the DnD image of text area", + found); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java b/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java index 6c24a05b6d..5ac85535d2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedAltTextTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.embedded; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; @@ -38,18 +40,18 @@ public class EmbeddedAltTextTest extends MultiBrowserTest { public void testEmbeddedAltText() { EmbeddedElement embedded = $(EmbeddedElement.class).first(); - Assert.assertEquals("Alt text of the image", getAltText(embedded)); + assertEquals("Alt text of the image", getAltText(embedded)); assertHtmlSource("Alt text of the object"); $(ButtonElement.class).first().click(); - Assert.assertEquals("New alt text of the image!", getAltText(embedded)); + assertEquals("New alt text of the image!", getAltText(embedded)); assertHtmlSource("New alt text of the object!"); } private void assertHtmlSource(String html) { String pageSource = driver.getPageSource(); - Assert.assertTrue("Page source does not contain '" + html + "'", + assertTrue("Page source does not contain '" + html + "'", pageSource.contains(html)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java b/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java index 64ab631655..6657102e5b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinatesTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.embedded; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -58,13 +60,13 @@ public class EmbeddedClickListenerRelativeCoordinatesTest int x = Integer.parseInt(xLabel.getText()); int y = Integer.parseInt(yLabel.getText()); - Assert.assertEquals( + assertEquals( "Reported X-coordinate from Embedded does not match click location", expectedX, x); // IE10 and IE11 sometimes click one pixel below the given position int tolerance = isIE() ? 1 : 0; - Assert.assertTrue( + assertTrue( "Reported Y-coordinate from Embedded does not match click location", Math.abs(expectedY - y) <= tolerance); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/flash/FlashExpansionTest.java b/uitest/src/test/java/com/vaadin/tests/components/flash/FlashExpansionTest.java index c21992941c..4650c9eeef 100755 --- a/uitest/src/test/java/com/vaadin/tests/components/flash/FlashExpansionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/flash/FlashExpansionTest.java @@ -1,8 +1,10 @@ package com.vaadin.tests.components.flash; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -29,11 +31,11 @@ public class FlashExpansionTest extends MultiBrowserTest { waitForElementPresent(locator); WebElement embed = $(FlashElement.class).first().findElement(locator); String width = embed.getAttribute("width"); - Assert.assertEquals("Width is not 400.0px initially", "400", width); + assertEquals("Width is not 400.0px initially", "400", width); $(ButtonElement.class).first().click(); embed = $(FlashElement.class).first().findElement(locator); String widthAfterExpansion = embed.getAttribute("width"); - Assert.assertNotEquals("Width is still 400.0px after expansion", "400", + assertNotEquals("Width is still 400.0px after expansion", "400", widthAfterExpansion); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java b/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java index 4985d0fcdb..1fb79b097c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.formlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -47,11 +48,11 @@ public class FormLayoutClickListenerTest extends MultiBrowserTest { element.getLocation().getY() + 2).click().build().perform(); waitForLogRowUpdate(); - Assert.assertEquals("Source component for click event must be form", + assertEquals("Source component for click event must be form", "3. Source component: form", getLogRow(0)); - Assert.assertEquals("Clicked component for click event must be null", + assertEquals("Clicked component for click event must be null", "2. Clicked component: null", getLogRow(1)); - Assert.assertEquals("Child component for click event must be null", + assertEquals("Child component for click event must be null", "1. Child component: null", getLogRow(2)); } @@ -60,11 +61,11 @@ public class FormLayoutClickListenerTest extends MultiBrowserTest { findElement(By.id("label")).click(); waitForLogRowUpdate(); - Assert.assertEquals("Source component for click event must be form", + assertEquals("Source component for click event must be form", "3. Source component: form", getLogRow(0)); - Assert.assertEquals("Clicked component for click event must be label", + assertEquals("Clicked component for click event must be label", "2. Clicked component: label", getLogRow(1)); - Assert.assertEquals("Child component for click event must be label", + assertEquals("Child component for click event must be label", "1. Child component: label", getLogRow(2)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutInVerticalLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutInVerticalLayoutTest.java index c8183bc9a1..a286de771c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutInVerticalLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutInVerticalLayoutTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.formlayout; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -39,7 +40,7 @@ public class FormLayoutInVerticalLayoutTest extends MultiBrowserTest { String formLabelMargin = labels.get(0).getCssValue("margin-top"); String verticalLayoutLabelMargin = labels.get(1) .getCssValue("margin-top"); - Assert.assertNotEquals( + assertNotEquals( "'margin-top' values for header label in vertical layout " + "and form layout are the same", verticalLayoutLabelMargin, formLabelMargin); diff --git a/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutResizingTest.java b/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutResizingTest.java index 9b800fa524..fa137cc1f1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutResizingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/formlayout/FormLayoutResizingTest.java @@ -15,16 +15,17 @@ */ package com.vaadin.tests.components.formlayout; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.FormLayoutElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.tests.tb3.MultiBrowserThemeTest; @@ -34,10 +35,10 @@ public class FormLayoutResizingTest extends MultiBrowserThemeTest { openTestURL(); List<TableElement> tables = $(TableElement.class).all(); - Assert.assertEquals("Sanity check", 2, tables.size()); + assertEquals("Sanity check", 2, tables.size()); List<FormLayoutElement> layouts = $(FormLayoutElement.class).all(); - Assert.assertEquals("Sanity check", 2, layouts.size()); + assertEquals("Sanity check", 2, layouts.size()); ButtonElement toggleButton = $(ButtonElement.class).first(); @@ -58,9 +59,9 @@ public class FormLayoutResizingTest extends MultiBrowserThemeTest { int[] expandedWidths = getWidths(tables); - Assert.assertEquals("Table should have grown ", originalWidths[0] + 200, + assertEquals("Table should have grown ", originalWidths[0] + 200, expandedWidths[0]); - Assert.assertEquals("Wrapped table should have grown ", + assertEquals("Wrapped table should have grown ", originalWidths[1] + 200, expandedWidths[1]); // Toggle size from 600 px to 400 px @@ -68,9 +69,9 @@ public class FormLayoutResizingTest extends MultiBrowserThemeTest { int[] collapsedWidths = getWidths(tables); - Assert.assertEquals("Table should return to original width ", + assertEquals("Table should return to original width ", originalWidths[0], collapsedWidths[0]); - Assert.assertEquals("Wrapped table should return to original width ", + assertEquals("Wrapped table should return to original width ", originalWidths[1], collapsedWidths[1]); // Verify that growing is not restricted after triggering the fix @@ -79,9 +80,9 @@ public class FormLayoutResizingTest extends MultiBrowserThemeTest { expandedWidths = getWidths(tables); - Assert.assertEquals("Table should have grown ", originalWidths[0] + 200, + assertEquals("Table should have grown ", originalWidths[0] + 200, expandedWidths[0]); - Assert.assertEquals("Wrapped table should have grown ", + assertEquals("Wrapped table should have grown ", originalWidths[1] + 200, expandedWidths[1]); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/formlayout/HtmlCaptionInFormLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/formlayout/HtmlCaptionInFormLayoutTest.java index 0032d8c6fd..ecf7df9f84 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/formlayout/HtmlCaptionInFormLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/formlayout/HtmlCaptionInFormLayoutTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.formlayout; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -33,11 +34,10 @@ public class HtmlCaptionInFormLayoutTest extends SingleBrowserTest { List<WebElement> captions = getDriver() .findElements(By.cssSelector(".v-formlayout-captioncell span")); - Assert.assertEquals("Should be two formlayout captions", 2, - captions.size()); + assertEquals("Should be two formlayout captions", 2, captions.size()); - Assert.assertEquals("Contains HTML", captions.get(0).getText()); - Assert.assertEquals("Contains <b>HTML</b>", captions.get(1).getText()); + assertEquals("Contains HTML", captions.get(0).getText()); + assertEquals("Contains <b>HTML</b>", captions.get(1).getText()); } @Test @@ -49,11 +49,10 @@ public class HtmlCaptionInFormLayoutTest extends SingleBrowserTest { List<WebElement> captions = getDriver() .findElements(By.cssSelector(".v-formlayout-captioncell span")); - Assert.assertEquals("Should be two formlayout captions", 2, - captions.size()); + assertEquals("Should be two formlayout captions", 2, captions.size()); - Assert.assertEquals("Contains <b>HTML</b>", captions.get(0).getText()); - Assert.assertEquals("Contains HTML", captions.get(1).getText()); + assertEquals("Contains <b>HTML</b>", captions.get(0).getText()); + assertEquals("Contains HTML", captions.get(1).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/formlayout/StylePrefixTest.java b/uitest/src/test/java/com/vaadin/tests/components/formlayout/StylePrefixTest.java index c9199c87e9..f297843289 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/formlayout/StylePrefixTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/formlayout/StylePrefixTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.formlayout; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -33,7 +34,7 @@ public class StylePrefixTest extends MultiBrowserTest { public void testStylePrefix() { openTestURL(); - Assert.assertTrue("Custom style has unexpected prefix", + assertTrue("Custom style has unexpected prefix", isElementPresent(By.className("v-formlayout-mystyle"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/DisallowedDeselectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/DisallowedDeselectionTest.java index 85d202d50d..6da0c0c260 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/DisallowedDeselectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/DisallowedDeselectionTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -34,26 +36,26 @@ public class DisallowedDeselectionTest extends MultiBrowserTest { openTestURL(); GridRowElement row = $(GridElement.class).first().getRow(0); - Assert.assertFalse(row.isSelected()); + assertFalse(row.isSelected()); select(row); - Assert.assertTrue(row.isSelected()); + assertTrue(row.isSelected()); // deselection is disallowed select(row); - Assert.assertTrue(row.isSelected()); + assertTrue(row.isSelected()); // select another row GridRowElement oldRow = row; row = $(GridElement.class).first().getRow(1); select(row); - Assert.assertTrue(row.isSelected()); - Assert.assertFalse(oldRow.isSelected()); + assertTrue(row.isSelected()); + assertFalse(oldRow.isSelected()); $(ButtonElement.class).first().click(); select(row); - Assert.assertFalse(row.isSelected()); + assertFalse(row.isSelected()); } private void select(GridRowElement row) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java index e3595e7674..283bc1ef36 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridAddColumnTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; @@ -60,9 +62,9 @@ public class GridAddColumnTest extends SingleBrowserTest { @Test public void initial_header_content() { GridCellElement firstHeader = grid.getHeaderCell(0, 0); - Assert.assertTrue("No label element in header", + assertTrue("No label element in header", firstHeader.isElementPresent(By.className("v-label"))); - Assert.assertEquals("Text in label does not match", "Label Header", + assertEquals("Text in label does not match", "Label Header", firstHeader.getText()); } @@ -71,8 +73,8 @@ public class GridAddColumnTest extends SingleBrowserTest { $(ButtonElement.class).first().click(); // Verify button got clicked - Assert.assertTrue(isElementPresent(NotificationElement.class)); - Assert.assertEquals("Columns replaced.", + assertTrue(isElementPresent(NotificationElement.class)); + assertEquals("Columns replaced.", $(NotificationElement.class).first().getText()); // Run default rendering test @@ -80,13 +82,13 @@ public class GridAddColumnTest extends SingleBrowserTest { } private void assertCellEquals(int rowIndex, int colIndex, String content) { - Assert.assertEquals("Cell text should equal", content, + assertEquals("Cell text should equal", content, grid.getCell(rowIndex, colIndex).getText()); } private void assertCellStartsWith(int rowIndex, int colIndex, String startsWith) { - Assert.assertTrue("Cell text should start with", grid + assertTrue("Cell text should start with", grid .getCell(rowIndex, colIndex).getText().startsWith(startsWith)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java index 7f667eea1d..0b5b5f10ee 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -32,11 +34,11 @@ public class GridApplyFilterWhenScrolledDownTest extends MultiBrowserTest { }); WebElement cell = gridBody.findElements(By.className("v-grid-cell")) .get(0); - Assert.assertEquals("Test", cell.getText()); + assertEquals("Test", cell.getText()); int gridHeight = grid.getSize().getHeight(); int scrollerHeight = grid.getVerticalScroller().getSize().getHeight(); - Assert.assertTrue( + assertTrue( "Scroller height is " + scrollerHeight + ", should be smaller than grid height: " + gridHeight, scrollerHeight < gridHeight); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java index 0a667ffcb6..b5988f8892 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -32,17 +33,16 @@ public class GridCheckBoxDisplayTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("First item had wrong value", "true", + assertEquals("First item had wrong value", "true", grid.getCell(0, 0).getText()); - Assert.assertEquals("Second item had wrong value", "false", + assertEquals("Second item had wrong value", "false", grid.getCell(1, 0).getText()); // First edit false item and see that the CheckBox is unchecked grid.getCell(1, 0).doubleClick(); CheckBoxElement checkbox = $(CheckBoxElement.class).first(); - Assert.assertEquals("CheckBox was checked", "unchecked", - checkbox.getValue()); + assertEquals("CheckBox was checked", "unchecked", checkbox.getValue()); closeEditor(); @@ -50,7 +50,7 @@ public class GridCheckBoxDisplayTest extends SingleBrowserTest { grid.getCell(0, 0).doubleClick(); checkbox = $(CheckBoxElement.class).first(); - Assert.assertEquals("CheckBox was not checked.", "checked", + assertEquals("CheckBox was not checked.", "checked", checkbox.getValue()); closeEditor(); @@ -59,8 +59,7 @@ public class GridCheckBoxDisplayTest extends SingleBrowserTest { grid.getCell(1, 0).doubleClick(); checkbox = $(CheckBoxElement.class).first(); - Assert.assertEquals("CheckBox was checked", "unchecked", - checkbox.getValue()); + assertEquals("CheckBox was checked", "unchecked", checkbox.getValue()); } /** diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java index 541851b8a1..81d038cfa8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -30,8 +32,8 @@ public class GridClickableRenderersTest extends MultiBrowserTest { @Test public void clickableRenderersPresent() { openTestURL(); - Assert.assertTrue(isElementPresent(By.className("v-nativebutton"))); - Assert.assertTrue(isElementPresent(By.className("gwt-Image"))); + assertTrue(isElementPresent(By.className("v-nativebutton"))); + assertTrue(isElementPresent(By.className("gwt-Image"))); } @Test @@ -41,23 +43,23 @@ public class GridClickableRenderersTest extends MultiBrowserTest { By.className("v-nativebutton")); WebElement firstRowTextButton = findElements.get(0); WebElement firstRowHtmlButton = findElements.get(1); - Assert.assertEquals("button 1 text", firstRowTextButton.getText()); + assertEquals("button 1 text", firstRowTextButton.getText()); // If it was rendered as text, getText() would return the markup also - Assert.assertEquals("button 1 html", firstRowHtmlButton.getText()); + assertEquals("button 1 html", firstRowHtmlButton.getText()); WebElement secondRowTextButton = findElements.get(3); WebElement secondRowHtmlButton = findElements.get(4); - Assert.assertEquals("button 2 text", secondRowTextButton.getText()); + assertEquals("button 2 text", secondRowTextButton.getText()); // If it was rendered as text, getText() would return the markup also - Assert.assertEquals("button 2 html", secondRowHtmlButton.getText()); + assertEquals("button 2 html", secondRowHtmlButton.getText()); LabelElement label = $(LabelElement.class).get(1); firstRowTextButton.click(); - Assert.assertEquals("first row clicked", label.getText()); + assertEquals("first row clicked", label.getText()); secondRowTextButton.click(); - Assert.assertEquals("second row clicked", label.getText()); + assertEquals("second row clicked", label.getText()); } @Test @@ -70,9 +72,9 @@ public class GridClickableRenderersTest extends MultiBrowserTest { LabelElement label = $(LabelElement.class).get(2); firstRowButton.click(); - Assert.assertEquals("first row false", label.getText()); + assertEquals("first row false", label.getText()); secondRowButton.click(); - Assert.assertEquals("second row true", label.getText()); + assertEquals("second row true", label.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java index e1b5939ead..6728b621dd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java @@ -16,10 +16,11 @@ package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; @@ -42,28 +43,28 @@ public class GridColumnHidingTest extends MultiBrowserTest { ButtonElement toggleAgeColumn = $(ButtonElement.class).get(1); ButtonElement toggleEmailColumn = $(ButtonElement.class).get(2); - Assert.assertEquals("Foo", grid.getCell(0, 0).getText()); - Assert.assertEquals("Maya", grid.getCell(1, 0).getText()); - Assert.assertEquals("46", grid.getCell(0, 1).getText()); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 2).getText()); + assertEquals("Foo", grid.getCell(0, 0).getText()); + assertEquals("Maya", grid.getCell(1, 0).getText()); + assertEquals("46", grid.getCell(0, 1).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 2).getText()); toggleAgeColumn.click(); - Assert.assertEquals("Foo", grid.getCell(0, 0).getText()); - Assert.assertEquals("Maya", grid.getCell(1, 0).getText()); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); + assertEquals("Foo", grid.getCell(0, 0).getText()); + assertEquals("Maya", grid.getCell(1, 0).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); toggleNameColumn.click(); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 0).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 0).getText()); toggleEmailColumn.click(); - Assert.assertFalse(isElementPresent(By.className("v-grid-cell"))); + assertFalse(isElementPresent(By.className("v-grid-cell"))); toggleAgeColumn.click(); toggleNameColumn.click(); toggleEmailColumn.click(); - Assert.assertEquals("Foo", grid.getCell(0, 0).getText()); - Assert.assertEquals("46", grid.getCell(0, 1).getText()); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 2).getText()); + assertEquals("Foo", grid.getCell(0, 0).getText()); + assertEquals("46", grid.getCell(0, 1).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 2).getText()); } @Test @@ -73,19 +74,19 @@ public class GridColumnHidingTest extends MultiBrowserTest { getSidebarOpenButton(grid).click(); getColumnHidingToggle(grid, "custom age column caption").click(); - Assert.assertEquals("Foo", grid.getCell(0, 0).getText()); - Assert.assertEquals("Maya", grid.getCell(1, 0).getText()); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); - Assert.assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); + assertEquals("Foo", grid.getCell(0, 0).getText()); + assertEquals("Maya", grid.getCell(1, 0).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); + assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); getColumnHidingToggle(grid, "Name").click(); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 0).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 0).getText()); getColumnHidingToggle(grid, "custom age column caption").click(); - Assert.assertEquals("46", grid.getCell(0, 0).getText()); - Assert.assertEquals("18", grid.getCell(1, 0).getText()); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); - Assert.assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); + assertEquals("46", grid.getCell(0, 0).getText()); + assertEquals("18", grid.getCell(1, 0).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); + assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); } @Test @@ -101,10 +102,10 @@ public class GridColumnHidingTest extends MultiBrowserTest { // Show from server $(ButtonElement.class).caption("server side toggle age column").first() .click(); - Assert.assertEquals("46", grid.getCell(0, 0).getText()); - Assert.assertEquals("18", grid.getCell(1, 0).getText()); - Assert.assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); - Assert.assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); + assertEquals("46", grid.getCell(0, 0).getText()); + assertEquals("18", grid.getCell(1, 0).getText()); + assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); + assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); } @Test @@ -115,19 +116,19 @@ public class GridColumnHidingTest extends MultiBrowserTest { ButtonElement toggleNameColumn = $(ButtonElement.class).get(0); ButtonElement toggleAgeColumn = $(ButtonElement.class).get(1); - Assert.assertEquals("visibility change label", isHiddenLabel.getText()); + assertEquals("visibility change label", isHiddenLabel.getText()); toggleNameColumn.click(); - Assert.assertEquals("true", isHiddenLabel.getText()); + assertEquals("true", isHiddenLabel.getText()); toggleAgeColumn.click(); - Assert.assertEquals("true", isHiddenLabel.getText()); + assertEquals("true", isHiddenLabel.getText()); toggleAgeColumn.click(); - Assert.assertEquals("false", isHiddenLabel.getText()); + assertEquals("false", isHiddenLabel.getText()); getSidebarOpenButton(grid).click(); getColumnHidingToggle(grid, "Name").click(); - Assert.assertEquals("false", isHiddenLabel.getText()); + assertEquals("false", isHiddenLabel.getText()); getColumnHidingToggle(grid, "custom age column caption").click(); - Assert.assertEquals("true", isHiddenLabel.getText()); + assertEquals("true", isHiddenLabel.getText()); getSidebarOpenButton(grid).click(); } @@ -137,9 +138,9 @@ public class GridColumnHidingTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); getSidebarOpenButton(grid).click(); List<WebElement> elements = getColumnHidingToggles(grid); - Assert.assertEquals(2, elements.size()); - Assert.assertTrue("Name".equals(elements.get(0).getText())); - Assert.assertTrue( + assertEquals(2, elements.size()); + assertTrue("Name".equals(elements.get(0).getText())); + assertTrue( "custom age column caption".equals(elements.get(1).getText())); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnResizingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnResizingTest.java index 3f2a08d979..a95992df23 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnResizingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnResizingTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -33,11 +35,11 @@ public class GridColumnResizingTest extends MultiBrowserTest { ButtonElement toggleResizableButton = $(ButtonElement.class).get(4); GridCellElement cell = getGrid().getHeaderCell(0, 0); - Assert.assertEquals(true, cell.isElementPresent( + assertEquals(true, cell.isElementPresent( By.cssSelector("div.v-grid-column-resize-handle"))); toggleResizableButton.click(); - Assert.assertEquals(false, cell.isElementPresent( + assertEquals(false, cell.isElementPresent( By.cssSelector("div.v-grid-column-resize-handle"))); } @@ -87,16 +89,13 @@ public class GridColumnResizingTest extends MultiBrowserTest { public void resizeEventListener() { openTestURL(); - Assert.assertEquals("not resized", - $(LabelElement.class).get(1).getText()); + assertEquals("not resized", $(LabelElement.class).get(1).getText()); serverSideSetWidth(150); - Assert.assertEquals("server resized", - $(LabelElement.class).get(1).getText()); + assertEquals("server resized", $(LabelElement.class).get(1).getText()); dragResizeColumn(0, 0, 100); - Assert.assertEquals("client resized", - $(LabelElement.class).get(1).getText()); + assertEquals("client resized", $(LabelElement.class).get(1).getText()); } private GridElement getGrid() { @@ -137,13 +136,13 @@ public class GridColumnResizingTest extends MultiBrowserTest { } private void assertColumnWidth(int width, int columnIndex) { - Assert.assertEquals(width, + assertEquals(width, getGrid().getCell(0, columnIndex).getSize().getWidth()); } private void assertColumnWidthWithThreshold(int width, int columnIndex, int threshold) { - Assert.assertTrue( + assertTrue( Math.abs(getGrid().getCell(0, columnIndex).getSize().getWidth() - width) <= threshold); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java index b85e6cb4d8..da767f3b4d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnWidthsWithoutDataTest.java @@ -15,13 +15,17 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; -import org.junit.Assert; import org.junit.Test; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.testbench.elements.NotificationElement; @@ -37,9 +41,9 @@ public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); int[] baseWidths = getColWidths(grid); - Assert.assertEquals("Sanity check", 2, baseWidths.length); + assertEquals("Sanity check", 2, baseWidths.length); - Assert.assertTrue("Columns should not have equal width", + assertTrue("Columns should not have equal width", Math.abs(baseWidths[0] - baseWidths[1]) > 2); removeData(); @@ -60,20 +64,20 @@ public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); int[] baseWidths = getColWidths(grid); - Assert.assertEquals("Sanity check", 2, baseWidths.length); + assertEquals("Sanity check", 2, baseWidths.length); - Assert.assertTrue("Columns should have roughly equal width", + assertTrue("Columns should have roughly equal width", Math.abs(baseWidths[0] - baseWidths[1]) < 10); - Assert.assertTrue("Columns should not have default widths", + assertTrue("Columns should not have default widths", baseWidths[0] > 140); - Assert.assertTrue("Columns should not have default widths", + assertTrue("Columns should not have default widths", baseWidths[1] > 140); addData(); assertSameWidths(baseWidths, getColWidths(grid)); - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(NotificationElement.class)); } @@ -89,7 +93,7 @@ public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest { int sum = sumUsedWidths(grid); // 295 instead of 300 to avoid rounding issues - Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295); + assertTrue("Only " + sum + " out of 300px was used", sum > 295); $(ButtonElement.class).caption("Recreate without data").first().click(); @@ -97,7 +101,7 @@ public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest { sum = sumUsedWidths(grid); // 295 instead of 300 to avoid rounding issues - Assert.assertTrue("Only " + sum + " out of 300px was used", sum > 295); + assertTrue("Only " + sum + " out of 300px was used", sum > 295); } private int sumUsedWidths(GridElement grid) { @@ -109,12 +113,12 @@ public class GridColumnWidthsWithoutDataTest extends SingleBrowserTest { } private static void assertSameWidths(int[] expected, int[] actual) { - Assert.assertEquals("Arrays have differing lengths", expected.length, + assertEquals("Arrays have differing lengths", expected.length, actual.length); for (int i = 0; i < expected.length; i++) { if (Math.abs(expected[i] - actual[i]) > 1) { - Assert.fail("Differing sizes at index " + i + ". Expected " + fail("Differing sizes at index " + i + ". Expected " + expected[i] + " but got " + actual[i]); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java index cd680d3804..88b218e6bf 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java @@ -1,9 +1,12 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.stream.IntStream; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -35,9 +38,9 @@ public class GridComponentsTest extends MultiBrowserTest { WebElement textField = grid.getCell(0, 1) .findElement(By.tagName("input")); - Assert.assertEquals("TextField value was reset", "Foo", + assertEquals("TextField value was reset", "Foo", textField.getAttribute("value")); - Assert.assertTrue("No mention in the log", + assertTrue("No mention in the log", logContainsText("1. Reusing old text field for: Row 0")); } @@ -51,9 +54,9 @@ public class GridComponentsTest extends MultiBrowserTest { WebElement textField = grid.getCell(1, 1) .findElement(By.tagName("input")); - Assert.assertEquals("TextField value was reset", "Foo", + assertEquals("TextField value was reset", "Foo", textField.getAttribute("value")); - Assert.assertTrue("No mention in the log", + assertTrue("No mention in the log", logContainsText("1. Reusing old text field for: Row 1")); } @@ -76,7 +79,7 @@ public class GridComponentsTest extends MultiBrowserTest { int padding = 18 * 2 + 1; int extraSpace = Math.abs(fieldWidth - cellWidth); - Assert.assertTrue("Too much unused space in cell. Expected: " + padding + assertTrue("Too much unused space in cell. Expected: " + padding + " Actual: " + extraSpace, extraSpace <= padding); } @@ -97,7 +100,7 @@ public class GridComponentsTest extends MultiBrowserTest { public void testRow0() { openTestURL(); assertRowExists(0, "Row 0"); - Assert.assertEquals("Grid row height is not what it should be", 40, + assertEquals("Grid row height is not what it should be", 40, $(GridElement.class).first().getRow(0).getSize().getHeight()); } @@ -126,31 +129,30 @@ public class GridComponentsTest extends MultiBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); GridCellElement headerCell = grid.getHeaderCell(0, 0); - Assert.assertTrue("First header should contain a Label", + assertTrue("First header should contain a Label", headerCell.isElementPresent(LabelElement.class)); - Assert.assertEquals("Label", + assertEquals("Label", headerCell.$(LabelElement.class).first().getText()); - Assert.assertFalse("Second header should not contain a component", + assertFalse("Second header should not contain a component", grid.getHeaderCell(0, 1).isElementPresent(LabelElement.class)); - Assert.assertEquals("Other Components", - grid.getHeaderCell(0, 1).getText()); + assertEquals("Other Components", grid.getHeaderCell(0, 1).getText()); } private void assertRowExists(int i, String string) { GridRowElement row = $(GridElement.class).first().getRow(i); - Assert.assertEquals("Label text did not match", string, + assertEquals("Label text did not match", string, row.getCell(0).getText()); row.findElement(By.id(string.replace(' ', '_').toLowerCase())).click(); // IE 11 is slow, need to wait for the notification. waitUntil(driver -> isElementPresent(NotificationElement.class), 10); - Assert.assertTrue("Notification should contain given text", + assertTrue("Notification should contain given text", $(NotificationElement.class).first().getText() .contains(string)); } private void assertNoButton(int i) { GridRowElement row = $(GridElement.class).first().getRow(i); - Assert.assertFalse("Row " + i + " should not have a button", + assertFalse("Row " + i + " should not have a button", row.getCell(2).isElementPresent(ButtonElement.class)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java index 2967d210ab..17f0f00a9a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsDetachTest.java @@ -15,15 +15,16 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -64,11 +65,11 @@ public class GridDetailsDetachTest extends MultiBrowserTest { assertNoErrorNotifications(); List<WebElement> spacers = findElements(By.className("v-grid-spacer")); - Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size()); - Assert.assertEquals("Spacer content not visible", - "Extra data for Bean 1", spacers.get(0).getText()); - Assert.assertEquals("Spacer content not visible", - "Extra data for Bean 3", spacers.get(1).getText()); + assertEquals("Not enough spacers in DOM", 2, spacers.size()); + assertEquals("Spacer content not visible", "Extra data for Bean 1", + spacers.get(0).getText()); + assertEquals("Spacer content not visible", "Extra data for Bean 3", + spacers.get(1).getText()); } @Test @@ -87,11 +88,11 @@ public class GridDetailsDetachTest extends MultiBrowserTest { assertNoErrorNotifications(); List<WebElement> spacers = findElements(By.className("v-grid-spacer")); - Assert.assertEquals("Not enough spacers in DOM", 2, spacers.size()); - Assert.assertEquals("Spacer content not visible", - "Extra data for Bean 1", spacers.get(0).getText()); - Assert.assertEquals("Spacer content not visible", - "Extra data for Bean 3", spacers.get(1).getText()); + assertEquals("Not enough spacers in DOM", 2, spacers.size()); + assertEquals("Spacer content not visible", "Extra data for Bean 1", + spacers.get(0).getText()); + assertEquals("Spacer content not visible", "Extra data for Bean 3", + spacers.get(1).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLocationTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLocationTest.java index 530d7ddda5..81b75385f6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLocationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsLocationTest.java @@ -1,10 +1,12 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -140,7 +142,7 @@ public class GridDetailsLocationTest extends MultiBrowserTest { int visibleIndexOfSpacer) { waitForDetailsVisible(); WebElement details = getDetailsElement(visibleIndexOfSpacer); - Assert.assertEquals("Wrong details row height", expectedHeight, + assertEquals("Wrong details row height", expectedHeight, details.getSize().getHeight()); } @@ -151,11 +153,10 @@ public class GridDetailsLocationTest extends MultiBrowserTest { visibleIndexOfDeco); GridElement.GridRowElement rowElement = getGrid().getRow(row); - Assert.assertEquals( - "Details deco top position does not match row top pos", + assertEquals("Details deco top position does not match row top pos", rowElement.getLocation().getY(), detailsDecoElement.getLocation().getY()); - Assert.assertEquals( + assertEquals( "Details deco bottom position does not match details bottom pos", detailsElement.getLocation().getY() + detailsElement.getSize().getHeight(), @@ -164,7 +165,7 @@ public class GridDetailsLocationTest extends MultiBrowserTest { } private void verifyLocation(Param param) { - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(By.className("v-Notification"))); TestBenchElement headerRow = getGrid().getHeaderRow(0); @@ -189,11 +190,13 @@ public class GridDetailsLocationTest extends MultiBrowserTest { + bottomBoundary + " decoratorBotton:" + detailsBottom, detailsBottom, bottomBoundary); - verifyDetailsRowHeight(param.getRowIndex(), param.useGenerator() - ? detailsDefinedHeight : detailsDefaultHeight, 0); + verifyDetailsRowHeight(param.getRowIndex(), + param.useGenerator() ? detailsDefinedHeight + : detailsDefaultHeight, + 0); verifyDetailsDecoratorLocation(param.getRowIndex(), 0, 0); - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(By.className("v-Notification"))); } @@ -220,7 +223,8 @@ public class GridDetailsLocationTest extends MultiBrowserTest { WebElement detailsElement = getDetailsElement(); return detailsElement.isDisplayed() && detailsElement.getSize().getHeight() > 3 - ? detailsElement : null; + ? detailsElement + : null; } catch (StaleElementReferenceException e) { return null; } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsReattachTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsReattachTest.java index 5f0ebc6178..9ddee5b68f 100755 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsReattachTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsReattachTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -20,9 +21,10 @@ public class GridDetailsReattachTest extends MultiBrowserTest { @Test public void clickToAddCaption() { openTestURL(); - Assert.assertTrue("Grid details don't exist", hasDetailsElement()); + assertTrue("Grid details don't exist", hasDetailsElement()); $(ButtonElement.class).first().click(); - Assert.assertTrue("Grid details don't exist after deattach and reattach",hasDetailsElement() ); + assertTrue("Grid details don't exist after deattach and reattach", + hasDetailsElement()); } private final By locator = By.className("v-grid-spacer"); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java index b82ad3b363..d6b3174beb 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDetailsWidthTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -58,10 +60,10 @@ public class GridDetailsWidthTest extends SingleBrowserTest { private void checkSpacersHaveNoWidths(int expectedCount) { List<WebElement> spacers = findElements(By.className("v-grid-spacer")); - Assert.assertEquals("Wrong amount of spacers visible.", expectedCount, + assertEquals("Wrong amount of spacers visible.", expectedCount, spacers.size()); for (WebElement spacer : spacers) { - Assert.assertFalse("Spacer element had an unexpected width set.", + assertFalse("Spacer element had an unexpected width set.", spacer.findElement(By.tagName("td")).getAttribute("style") .contains("width")); } @@ -81,9 +83,9 @@ public class GridDetailsWidthTest extends SingleBrowserTest { cell = grid.getCell(2, 0); WebElement spacer = findElement(By.className("v-grid-spacer")); - Assert.assertEquals("Grid was not sorted correctly", "Hello 0", + assertEquals("Grid was not sorted correctly", "Hello 0", cell.getText()); - Assert.assertEquals("Details row was not in correct location", + assertEquals("Details row was not in correct location", cell.getLocation().getY() + cell.getSize().getHeight(), spacer.getLocation().getY(), 2); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisallowUserSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisallowUserSelectionTest.java index c8e6e39f2b..b2e1650bb4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisallowUserSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridDisallowUserSelectionTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -46,6 +47,6 @@ public class GridDisallowUserSelectionTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); grid.getCell(index, 0).click(); - Assert.assertFalse(grid.getRow(0).isSelected()); + assertFalse(grid.getRow(0).isSelected()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java index a53a822a97..1bf8f943f6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorCustomFieldTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Keys; @@ -33,7 +34,7 @@ public class GridEditorCustomFieldTest extends MultiBrowserTest { public void testCustomFieldWorksInEditorRow() { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Stockholm", grid.getCell(0, 2).getText()); + assertEquals("Stockholm", grid.getCell(0, 2).getText()); grid.getCell(0, 1).doubleClick(); GridEditorElement editor = grid.getEditor(); TestBenchElement customField = editor.getField(2); @@ -41,7 +42,7 @@ public class GridEditorCustomFieldTest extends MultiBrowserTest { ComboBoxElement comboBox = customField.$(ComboBoxElement.class).first(); comboBox.selectByText("Oslo"); editor.save(); - Assert.assertEquals("Oslo", grid.getCell(0, 2).getText()); + assertEquals("Oslo", grid.getCell(0, 2).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorEventsTest.java index 753bd656d6..989b0a52d5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorEventsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorEventsTest.java @@ -41,17 +41,17 @@ public class GridEditorEventsTest extends MultiBrowserTest { GridEditorElement editor = updateField(index, grid, "foo"); editor.save(); - Assert.assertEquals((index * 4 + 1) + ". editor is opened", + assertEquals((index * 4 + 1) + ". editor is opened", getLogRow(1)); - Assert.assertEquals((index * 4 + 2) + ". editor is saved", + assertEquals((index * 4 + 2) + ". editor is saved", getLogRow(0)); editor = updateField(index, grid, "bar"); editor.cancel(); - Assert.assertEquals((index * 4 + 3) + ". editor is opened", + assertEquals((index * 4 + 3) + ". editor is opened", getLogRow(1)); - Assert.assertEquals((index * 4 + 4) + ". editor is canceled", + assertEquals((index * 4 + 4) + ". editor is canceled", getLogRow(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java index 95581505ee..3d68fc5800 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java @@ -1,8 +1,10 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -41,7 +43,7 @@ public class GridEditorMultiselectTest extends MultiBrowserTest { private GridElement openEditor() { GridElement grid = $(GridElement.class).first(); grid.getRow(0).doubleClick(); - Assert.assertTrue("Grid editor should be displayed.", + assertTrue("Grid editor should be displayed.", grid.getEditor().isDisplayed()); return grid; } @@ -50,7 +52,7 @@ public class GridEditorMultiselectTest extends MultiBrowserTest { List<WebElement> checkboxes = grid .findElements(By.xpath("//input[@type='checkbox']")); for (WebElement checkbox : checkboxes) { - Assert.assertEquals( + assertEquals( "Select checkboxes should be " + (isEnabled ? "enabled" : "disabled"), isEnabled, checkbox.isEnabled()); 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 f6f1ff05d5..db0ad112a6 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 @@ -15,9 +15,13 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -42,19 +46,19 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); int filterRow = 2; - Assert.assertNull(getHeaderElement(grid, filterRow, 1)); - Assert.assertNotNull(getHeaderElement(grid, filterRow, 2)); - Assert.assertNotNull(getHeaderElement(grid, filterRow, 3)); + assertNull(getHeaderElement(grid, filterRow, 1)); + assertNotNull(getHeaderElement(grid, filterRow, 2)); + assertNotNull(getHeaderElement(grid, filterRow, 3)); // Show (1,2) grid.getHeaderCell(1, 1).$(ButtonElement.class).first().click(); TextFieldElement textfield = getHeaderElement(grid, filterRow, 1); - Assert.assertNotNull(textfield); - Assert.assertEquals("Filter: string", textfield.getValue()); + assertNotNull(textfield); + assertEquals("Filter: string", textfield.getValue()); textfield.setValue("foo"); - Assert.assertEquals("1. value change for field in string to foo", + assertEquals("1. value change for field in string to foo", getLogRow(0)); assertNoErrorNotifications(); @@ -80,19 +84,19 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); int filterRow = 0; - Assert.assertNull(getFooterElement(grid, filterRow, 1)); - Assert.assertNotNull(getFooterElement(grid, filterRow, 2)); - Assert.assertNotNull(getFooterElement(grid, filterRow, 3)); + assertNull(getFooterElement(grid, filterRow, 1)); + assertNotNull(getFooterElement(grid, filterRow, 2)); + assertNotNull(getFooterElement(grid, filterRow, 3)); // Show (1,2) grid.getFooterCell(1, 1).$(ButtonElement.class).first().click(); TextFieldElement textfield = getFooterElement(grid, filterRow, 1); - Assert.assertNotNull(textfield); - Assert.assertEquals("Filter: string", textfield.getValue()); + assertNotNull(textfield); + assertEquals("Filter: string", textfield.getValue()); textfield.setValue("foo"); - Assert.assertEquals("1. value change for field in string to foo", + assertEquals("1. value change for field in string to foo", getLogRow(0)); assertNoErrorNotifications(); @@ -121,14 +125,14 @@ public class GridHeaderFooterComponentsTest extends SingleBrowserTest { // Remove Header $(GridElement.class).first().getHeaderCell(i, 0) .$(ButtonElement.class).first().click(); - Assert.assertFalse("Header " + i + " should not be present.", + assertFalse("Header " + i + " should not be present.", $(GridElement.class).first() .isElementPresent(By.vaadin("#header[" + i + "]"))); // Remove Footer $(GridElement.class).first().getFooterCell(i, 0) .$(ButtonElement.class).first().click(); - Assert.assertFalse("Footer " + i + " should not be present.", + assertFalse("Footer " + i + " should not be present.", $(GridElement.class).first() .isElementPresent(By.vaadin("#footer[" + i + "]"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java index ef69679d98..2771617aee 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderFormatChangeTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -33,30 +35,28 @@ public class GridHeaderFormatChangeTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); // Assert that we do not have the select all checkbox - Assert.assertTrue( - "Found input in header even though none should exist.", + assertTrue("Found input in header even though none should exist.", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // Set grid into multiselection mode toggleSelectionMode(); // Assert that we now have a select all checkbox in the header - Assert.assertFalse("Expected one input field in header", + assertFalse("Expected one input field in header", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // Hide the firstName column from the grid. toggleFirstName(); // Assert that we still have the select all checkbox in the header. - Assert.assertFalse("Header was missing checkbox after hiding column", + assertFalse("Header was missing checkbox after hiding column", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // Show the firstName column. toggleFirstName(); // Assert that we still have the select all checkbox in the header. - Assert.assertFalse( - "Header was missing checkbox after bringing back column", + assertFalse("Header was missing checkbox after bringing back column", grid.getHeader().findElements(By.tagName("input")).isEmpty()); } @@ -66,30 +66,28 @@ public class GridHeaderFormatChangeTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); // Assert that we do not have the select all checkbox - Assert.assertTrue( - "Found input in header even though none should exist.", + assertTrue("Found input in header even though none should exist.", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // Set grid into multiselection mode toggleSelectionMode(); // Assert that we now have a select all checkbox in the header - Assert.assertFalse("Expected one input field in header", + assertFalse("Expected one input field in header", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // Add Join columns header toggleJoin(); // Assert that we still have the select all checkbox in the header. - Assert.assertFalse("Header was missing checkbox after hiding column", + assertFalse("Header was missing checkbox after hiding column", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // remove Join Columns header toggleJoin(); // Assert that we still have the select all checkbox in the header. - Assert.assertFalse( - "Header was missing checkbox after bringing back column", + assertFalse("Header was missing checkbox after bringing back column", grid.getHeader().findElements(By.tagName("input")).isEmpty()); } @@ -99,15 +97,14 @@ public class GridHeaderFormatChangeTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); // Assert that we do not have the select all checkbox - Assert.assertTrue( - "Found input in header even though none should exist.", + assertTrue("Found input in header even though none should exist.", grid.getHeader().findElements(By.tagName("input")).isEmpty()); // Set grid into multiselection mode toggleSelectionMode(); // Assert that we now have a select all checkbox in the header - Assert.assertFalse("Should not be selected after adding", + assertFalse("Should not be selected after adding", grid.getHeader().findElement(By.tagName("input")).isSelected()); grid.getHeader().findElement(By.tagName("input")).click(); @@ -133,7 +130,7 @@ public class GridHeaderFormatChangeTest extends MultiBrowserTest { } private void assertSelectAllChecked(String message, GridElement grid) { - Assert.assertTrue(message, + assertTrue(message, grid.getHeader().findElement(By.tagName("input")).isSelected()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java index 0297b30876..bee5780aa5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeaderStyleNamesTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -144,14 +145,14 @@ public class GridHeaderStyleNamesTest extends SingleBrowserTest { private void assertHasStyleName(String message, WebElement element, String stylename) { if (!hasCssClass(element, stylename)) { - Assert.fail(message); + fail(message); } } private void assertHasNotStyleName(String message, WebElement element, String stylename) { if (hasCssClass(element, stylename)) { - Assert.fail(message); + fail(message); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java index 6571d92f11..09df98583e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridHeightTest.java @@ -18,12 +18,12 @@ package com.vaadin.tests.components.grid; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.number.IsCloseTo.closeTo; +import static org.junit.Assert.fail; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.openqa.selenium.By; @@ -95,7 +95,7 @@ public class GridHeightTest extends MultiBrowserTest { } catch (AssertionError e) { errors.put(e, new Object[] { gridHeight, gridWidth, detailsRowHeight, "initial" }); - Assert.fail(); + fail(); } grid.getRow(2).click(5, 5); @@ -139,7 +139,7 @@ public class GridHeightTest extends MultiBrowserTest { } sb.append(entry.getKey().getMessage()); } - Assert.fail(sb.toString()); + fail(sb.toString()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java index f371d949e3..079149ecb8 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInWindowResizeTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertTrue; + import java.util.Collections; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.remote.DesiredCapabilities; @@ -43,6 +44,6 @@ public class GridInWindowResizeTest extends MultiBrowserTest { $(ButtonElement.class).caption("resize").first().click(); int col1WidthAfter = grid.getCell(0, 0).getSize().getWidth(); - Assert.assertTrue(col1WidthAfter < col1WidthBefore); + assertTrue(col1WidthAfter < col1WidthBefore); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java index 1a909e7a32..5464e70c8f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridInitiallyHiddenColumnsTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -33,20 +34,20 @@ public class GridInitiallyHiddenColumnsTest extends SingleBrowserTest { public void ensureCorrectlyRendered() { openTestURL("debug"); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Rowling", grid.getCell(0, 0).getText()); - Assert.assertEquals("Barks", grid.getCell(1, 0).getText()); + assertEquals("Rowling", grid.getCell(0, 0).getText()); + assertEquals("Barks", grid.getCell(1, 0).getText()); getSidebarOpenButton(grid).click(); getColumnHidingToggle(grid, "First Name").click(); getColumnHidingToggle(grid, "Age").click(); getSidebarOpenButton(grid).click(); - Assert.assertEquals("Umberto", grid.getCell(0, 0).getText()); - Assert.assertEquals("Rowling", grid.getCell(0, 1).getText()); - Assert.assertEquals("40", grid.getCell(0, 2).getText()); - Assert.assertEquals("Alex", grid.getCell(1, 0).getText()); - Assert.assertEquals("Barks", grid.getCell(1, 1).getText()); - Assert.assertEquals("25", grid.getCell(1, 2).getText()); + assertEquals("Umberto", grid.getCell(0, 0).getText()); + assertEquals("Rowling", grid.getCell(0, 1).getText()); + assertEquals("40", grid.getCell(0, 2).getText()); + assertEquals("Alex", grid.getCell(1, 0).getText()); + assertEquals("Barks", grid.getCell(1, 1).getText()); + assertEquals("25", grid.getCell(1, 2).getText()); } @@ -61,12 +62,12 @@ public class GridInitiallyHiddenColumnsTest extends SingleBrowserTest { getColumnHidingToggle(grid, "Age").click(); getSidebarOpenButton(grid).click(); - Assert.assertEquals("Umberto", grid.getCell(0, 0).getText()); - Assert.assertEquals("Rowling", grid.getCell(0, 1).getText()); - Assert.assertEquals("40", grid.getCell(0, 2).getText()); - Assert.assertEquals("Alex", grid.getCell(1, 0).getText()); - Assert.assertEquals("Barks", grid.getCell(1, 1).getText()); - Assert.assertEquals("25", grid.getCell(1, 2).getText()); + assertEquals("Umberto", grid.getCell(0, 0).getText()); + assertEquals("Rowling", grid.getCell(0, 1).getText()); + assertEquals("40", grid.getCell(0, 2).getText()); + assertEquals("Alex", grid.getCell(1, 0).getText()); + assertEquals("Barks", grid.getCell(1, 1).getText()); + assertEquals("25", grid.getCell(1, 2).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridPopupViewTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridPopupViewTest.java index 658ed8e1d5..d01a6b47d7 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridPopupViewTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridPopupViewTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -47,8 +48,8 @@ public class GridPopupViewTest extends MultiBrowserTest { pv.click(); GridElement grid = $(GridElement.class).first(); Dimension rect = grid.getCell(0, 0).getSize(); - Assert.assertEquals(500, rect.width); - Assert.assertEquals(38, rect.height); + assertEquals(500, rect.width); + assertEquals(38, rect.height); findElement(By.className("v-ui")).click(); waitForElementNotPresent(By.className("v-grid")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridRefreshRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRefreshRowTest.java index 3b1e2b9c88..7c9aab1738 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridRefreshRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRefreshRowTest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -22,37 +25,37 @@ public class GridRefreshRowTest extends SingleBrowserTest { style(1); style(2); - Assert.assertEquals("Lisa", grid.getCell(0, 1).getText()); - Assert.assertEquals("Joshua", grid.getCell(1, 1).getText()); - Assert.assertEquals("Marge", grid.getCell(2, 1).getText()); + assertEquals("Lisa", grid.getCell(0, 1).getText()); + assertEquals("Joshua", grid.getCell(1, 1).getText()); + assertEquals("Marge", grid.getCell(2, 1).getText()); - Assert.assertFalse(hasCssClass(grid.getRow(0), "rowstyle")); - Assert.assertFalse(hasCssClass(grid.getRow(1), "rowstyle")); - Assert.assertFalse(hasCssClass(grid.getRow(2), "rowstyle")); - Assert.assertFalse(hasCssClass(grid.getCell(0, 0), "cellstyle")); - Assert.assertFalse(hasCssClass(grid.getCell(1, 0), "cellstyle")); - Assert.assertFalse(hasCssClass(grid.getCell(2, 0), "cellstyle")); + assertFalse(hasCssClass(grid.getRow(0), "rowstyle")); + assertFalse(hasCssClass(grid.getRow(1), "rowstyle")); + assertFalse(hasCssClass(grid.getRow(2), "rowstyle")); + assertFalse(hasCssClass(grid.getCell(0, 0), "cellstyle")); + assertFalse(hasCssClass(grid.getCell(1, 0), "cellstyle")); + assertFalse(hasCssClass(grid.getCell(2, 0), "cellstyle")); refresh(1); - Assert.assertEquals("Lisa", grid.getCell(0, 1).getText()); - Assert.assertEquals("!Joshua", grid.getCell(1, 1).getText()); - Assert.assertEquals("Marge", grid.getCell(2, 1).getText()); + assertEquals("Lisa", grid.getCell(0, 1).getText()); + assertEquals("!Joshua", grid.getCell(1, 1).getText()); + assertEquals("Marge", grid.getCell(2, 1).getText()); - Assert.assertFalse(hasCssClass(grid.getRow(0), "rowstyle")); - Assert.assertTrue(hasCssClass(grid.getRow(1), "rowstyle")); - Assert.assertFalse(hasCssClass(grid.getRow(2), "rowstyle")); - Assert.assertFalse(hasCssClass(grid.getCell(0, 0), "cellstyle")); - Assert.assertTrue(hasCssClass(grid.getCell(1, 0), "cellstyle")); - Assert.assertFalse(hasCssClass(grid.getCell(2, 0), "cellstyle")); + assertFalse(hasCssClass(grid.getRow(0), "rowstyle")); + assertTrue(hasCssClass(grid.getRow(1), "rowstyle")); + assertFalse(hasCssClass(grid.getRow(2), "rowstyle")); + assertFalse(hasCssClass(grid.getCell(0, 0), "cellstyle")); + assertTrue(hasCssClass(grid.getCell(1, 0), "cellstyle")); + assertFalse(hasCssClass(grid.getCell(2, 0), "cellstyle")); // Assert refreshing works many times and for many rows at the same time update(0); update(1); update(2); refresh10First(); - Assert.assertEquals("!!Lisa", grid.getCell(0, 1).getText()); - Assert.assertEquals("!!Joshua", grid.getCell(1, 1).getText()); - Assert.assertEquals("!!Marge", grid.getCell(2, 1).getText()); + assertEquals("!!Lisa", grid.getCell(0, 1).getText()); + assertEquals("!!Joshua", grid.getCell(1, 1).getText()); + assertEquals("!!Marge", grid.getCell(2, 1).getText()); } private void refresh10First() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererSwitchTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererSwitchTest.java index a2ac8e1043..ce81eb796a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererSwitchTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridRendererSwitchTest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.By; @@ -17,17 +20,17 @@ public class GridRendererSwitchTest extends SingleBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Unexpected content in first grid cell", "Foo 0", + assertEquals("Unexpected content in first grid cell", "Foo 0", grid.getCell(0, 0).getAttribute("innerHTML")); ButtonElement button = $(ButtonElement.class).first(); button.click(); - Assert.assertFalse("No button in cell", grid.getCell(0, 0) + assertFalse("No button in cell", grid.getCell(0, 0) .findElements(By.tagName("button")).isEmpty()); grid.getCell(0, 0).findElement(By.tagName("button")).click(); - Assert.assertTrue("Notification not shown", + assertTrue("Notification not shown", isElementPresent(NotificationElement.class)); button.click(); - Assert.assertEquals("Cell should be back to text content.", "Foo 0", + assertEquals("Cell should be back to text content.", "Foo 0", grid.getCell(0, 0).getAttribute("innerHTML")); assertNoErrorNotifications(); @@ -39,26 +42,24 @@ public class GridRendererSwitchTest extends SingleBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Unexpected content in first grid cell", "Foo 0", + assertEquals("Unexpected content in first grid cell", "Foo 0", grid.getCell(0, 0).getAttribute("innerHTML")); ButtonElement button = $(ButtonElement.class).caption("Switch").first(); button.click(); ButtonElement reverse = $(ButtonElement.class).caption("Reverse") .first(); reverse.click(); - Assert.assertEquals( - "Unexpected content in first grid cell after reorder", "Bar 0", - grid.getCell(0, 0).getAttribute("innerHTML")); + assertEquals("Unexpected content in first grid cell after reorder", + "Bar 0", grid.getCell(0, 0).getAttribute("innerHTML")); - Assert.assertFalse("No button in cell after reversing order", grid + assertFalse("No button in cell after reversing order", grid .getCell(0, 1).findElements(By.tagName("button")).isEmpty()); grid.getCell(0, 1).findElement(By.tagName("button")).click(); - Assert.assertTrue("Notification not shown", + assertTrue("Notification not shown", isElementPresent(NotificationElement.class)); reverse.click(); - Assert.assertFalse("No button in cell after restoring original order", - grid.getCell(0, 0).findElements(By.tagName("button")) - .isEmpty()); + assertFalse("No button in cell after restoring original order", grid + .getCell(0, 0).findElements(By.tagName("button")).isEmpty()); assertNoErrorNotifications(); } @@ -69,29 +70,28 @@ public class GridRendererSwitchTest extends SingleBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Unexpected content in first grid cell", "Foo 0", + assertEquals("Unexpected content in first grid cell", "Foo 0", grid.getCell(0, 0).getAttribute("innerHTML")); ButtonElement reverse = $(ButtonElement.class).caption("Reverse") .first(); reverse.click(); - Assert.assertEquals( - "Unexpected content in first grid cell after reorder", "Bar 0", - grid.getCell(0, 0).getAttribute("innerHTML")); + assertEquals("Unexpected content in first grid cell after reorder", + "Bar 0", grid.getCell(0, 0).getAttribute("innerHTML")); ButtonElement button = $(ButtonElement.class).caption("Switch").first(); button.click(); - Assert.assertFalse( + assertFalse( "No button in cell after reversing order and changing renderer", grid.getCell(0, 1).findElements(By.tagName("button")) .isEmpty()); grid.getCell(0, 1).findElement(By.tagName("button")).click(); - Assert.assertTrue("Notification not shown", + assertTrue("Notification not shown", isElementPresent(NotificationElement.class)); button.click(); - Assert.assertEquals("Cell should be back to text content.", "Foo 0", + assertEquals("Cell should be back to text content.", "Foo 0", grid.getCell(0, 1).getAttribute("innerHTML")); assertNoErrorNotifications(); @@ -103,15 +103,14 @@ public class GridRendererSwitchTest extends SingleBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Unexpected content in first grid cell", "Foo 0", + assertEquals("Unexpected content in first grid cell", "Foo 0", grid.getCell(0, 0).getAttribute("innerHTML")); ButtonElement reverse = $(ButtonElement.class).caption("Reverse") .first(); reverse.click(); - Assert.assertEquals( - "Unexpected content in first grid cell after reorder", "Bar 0", - grid.getCell(0, 0).getAttribute("innerHTML")); + assertEquals("Unexpected content in first grid cell after reorder", + "Bar 0", grid.getCell(0, 0).getAttribute("innerHTML")); grid.toggleColumnHidden("Bar"); @@ -120,12 +119,12 @@ public class GridRendererSwitchTest extends SingleBrowserTest { assertNoErrorNotifications(); - Assert.assertFalse( + assertFalse( "No button in cell after reversing order and changing renderer", grid.getCell(0, 0).findElements(By.tagName("button")) .isEmpty()); grid.getCell(0, 0).findElement(By.tagName("button")).click(); - Assert.assertTrue("Notification not shown", + assertTrue("Notification not shown", isElementPresent(NotificationElement.class)); } @@ -135,12 +134,12 @@ public class GridRendererSwitchTest extends SingleBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Unexpected content in first grid cell", "Foo 0", + assertEquals("Unexpected content in first grid cell", "Foo 0", grid.getCell(0, 0).getAttribute("innerHTML")); grid.toggleColumnHidden("Foo"); - Assert.assertEquals("Unexpected content in first grid cell after hide", + assertEquals("Unexpected content in first grid cell after hide", "Bar 0", grid.getCell(0, 0).getAttribute("innerHTML")); ButtonElement button = $(ButtonElement.class).caption("Switch").first(); @@ -148,7 +147,7 @@ public class GridRendererSwitchTest extends SingleBrowserTest { assertNoErrorNotifications(); - Assert.assertEquals( + assertEquals( "Unexpected content in first grid cell after hidden renderer change", "Bar 0", grid.getCell(0, 0).getAttribute("innerHTML")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java index 6e1536c6a2..9aa932a70c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReplaceContainerTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -29,11 +31,11 @@ public class GridReplaceContainerTest extends SingleBrowserTest { openTestURL(); GridElement grid = $(GridElement.class).first(); grid.getCell(0, 0).click(); - Assert.assertTrue(grid.getRow(0).isSelected()); + assertTrue(grid.getRow(0).isSelected()); $(ButtonElement.class).first().click(); - Assert.assertFalse(grid.getRow(0).isSelected()); + assertFalse(grid.getRow(0).isSelected()); grid.getCell(0, 0).click(); - Assert.assertTrue(grid.getRow(0).isSelected()); + assertTrue(grid.getRow(0).isSelected()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java index f226710313..d8ee725c36 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeAndScrollTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -37,7 +38,7 @@ public class GridResizeAndScrollTest extends MultiBrowserTest { String textBefore = cell.getText(); cell.click(); - Assert.assertEquals("String contents changed on click", textBefore, + assertEquals("String contents changed on click", textBefore, cell.getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java index 3e28c846de..c5a5b8834e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridResizeHiddenColumnTest.java @@ -15,9 +15,12 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -44,9 +47,9 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest { // Check if column 'Last Name' hidden List<GridCellElement> headerCells = grid.getHeaderCells(0); - Assert.assertEquals("There should be two visible columns", 2, + assertEquals("There should be two visible columns", 2, headerCells.size()); - Assert.assertFalse("'Last Name' column should be hidden", + assertFalse("'Last Name' column should be hidden", containsText("Last Name", headerCells)); // Resize first column @@ -58,8 +61,7 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest { // (might be an issue with the feature that doesn't start resizing until // the cursor moved a few pixels) double delta = BrowserUtil.isIE8(getDesiredCapabilities()) ? 5d : 0; - Assert.assertEquals( - "Column width should've changed by " + dragOffset + "px", + assertEquals("Column width should've changed by " + dragOffset + "px", headerCellWidth + dragOffset, headerCells.get(0).getSize().getWidth(), delta); @@ -77,9 +79,9 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest { // Check if column "Last Name" is visible headerCells = grid.getHeaderCells(0); - Assert.assertEquals("There should be three visible columns", 3, + assertEquals("There should be three visible columns", 3, headerCells.size()); - Assert.assertTrue("'Last Name' column should be visible", + assertTrue("'Last Name' column should be visible", containsText("Last Name", headerCells)); // Check if column "Last Name" has expanded width @@ -87,8 +89,7 @@ public class GridResizeHiddenColumnTest extends MultiBrowserTest { for (GridCellElement e : headerCells) { widthSum += e.getSize().getWidth(); } - Assert.assertEquals( - "'Last Name' column should take up the remaining space", + assertEquals("'Last Name' column should take up the remaining space", grid.getHeader().getSize().getWidth(), widthSum, 1d); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToTest.java index a3c3002e91..d2635034bb 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridScrollToTest.java @@ -1,8 +1,12 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.Optional; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -13,10 +17,6 @@ import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.SingleBrowserTest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - @TestCategory("grid") public class GridScrollToTest extends SingleBrowserTest { @@ -79,22 +79,32 @@ public class GridScrollToTest extends SingleBrowserTest { waitForElementPresent(By.className("v-grid-spacer")); waitForElementPresent(By.className("v-label")); - assertTrue("Details not visible", getGrid().findElements(By.className("v-label")).stream() - .filter(element -> element.getText().contains("Name 199 details")).findFirst().get().isDisplayed()); + assertTrue("Details not visible", + getGrid().findElements(By.className("v-label")).stream() + .filter(element -> element.getText() + .contains("Name 199 details")) + .findFirst().get().isDisplayed()); // scroll away $(ButtonElement.class).id("top").click(); assertEquals("Found final element even though should be at top of list", 0, cellsContaining("199")); - assertFalse("Found final element details even though should be at top of list", getGrid().findElements(By.className("v-label")).stream() - .filter(element -> element.getText().contains("Name 199 details")).findFirst().isPresent()); + assertFalse( + "Found final element details even though should be at top of list", + getGrid().findElements(By.className("v-label")).stream() + .filter(element -> element.getText() + .contains("Name 199 details")) + .findFirst().isPresent()); // Scroll to end $(ButtonElement.class).id("end").click(); - assertTrue("Details not visible", getGrid().findElements(By.className("v-label")).stream() - .filter(element -> element.getText().contains("Name 199 details")).findFirst().get().isDisplayed()); + assertTrue("Details not visible", + getGrid().findElements(By.className("v-label")).stream() + .filter(element -> element.getText() + .contains("Name 199 details")) + .findFirst().get().isDisplayed()); } @Test @@ -110,22 +120,32 @@ public class GridScrollToTest extends SingleBrowserTest { waitForElementPresent(By.className("v-grid-spacer")); waitForElementPresent(By.className("v-label")); - assertTrue("Details not visible", getGrid().findElements(By.className("v-label")).stream() - .filter(element -> element.getText().contains("Name 50 details")).findFirst().get().isDisplayed()); + assertTrue("Details not visible", + getGrid().findElements(By.className("v-label")).stream() + .filter(element -> element.getText() + .contains("Name 50 details")) + .findFirst().get().isDisplayed()); // scroll away $(ButtonElement.class).id("top").click(); assertEquals("Found final element even though should be at top of list", 0, cellsContaining("50")); - assertFalse("Found final element details even though should be at top of list", getGrid().findElements(By.className("v-label")).stream() - .filter(element -> element.getText().contains("Name 50 details")).findFirst().isPresent()); + assertFalse( + "Found final element details even though should be at top of list", + getGrid().findElements(By.className("v-label")).stream() + .filter(element -> element.getText() + .contains("Name 50 details")) + .findFirst().isPresent()); // Scroll to end $(ButtonElement.class).id("row").click(); - assertTrue("Details not visible", getGrid().findElements(By.className("v-label")).stream() - .filter(element -> element.getText().contains("Name 50 details")).findFirst().get().isDisplayed()); + assertTrue("Details not visible", + getGrid().findElements(By.className("v-label")).stream() + .filter(element -> element.getText() + .contains("Name 50 details")) + .findFirst().get().isDisplayed()); } private GridElement getGrid() { @@ -145,6 +165,6 @@ public class GridScrollToTest extends SingleBrowserTest { if (first.isPresent()) first.get().click(); else - Assert.fail("Cell not present"); + fail("Cell not present"); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java index 45f7d54ebf..93575e26ac 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java @@ -455,10 +455,10 @@ public class GridSelectionTest extends GridBasicsTest { for (int i = 0; i < 10; i++) { boolean rowSelected = grid.getRow(i).isSelected(); if (expected.contains(i)) { - Assert.assertTrue("Expected row " + i + " to be selected", + assertTrue("Expected row " + i + " to be selected", rowSelected); } else { - Assert.assertFalse("Expected row " + i + " not to be selected", + assertFalse("Expected row " + i + " not to be selected", rowSelected); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java index 4b3fe2057a..6227e4b7c5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSidebarPositionTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -38,8 +39,7 @@ public class GridSidebarPositionTest extends MultiBrowserTest { Dimension popupSize = getSidebarPopup().getSize(); Dimension browserWindowSize = getDriver().manage().window().getSize(); - Assert.assertTrue( - popupSize.getHeight() <= browserWindowSize.getHeight()); + assertTrue(popupSize.getHeight() <= browserWindowSize.getHeight()); } @Test @@ -54,7 +54,7 @@ public class GridSidebarPositionTest extends MultiBrowserTest { int popupBottom = popupLocation.getY() + popupSize.getHeight(); Dimension browserWindowSize = getDriver().manage().window().getSize(); - Assert.assertTrue(popupBottom <= browserWindowSize.getHeight()); + assertTrue(popupBottom <= browserWindowSize.getHeight()); } @Test @@ -69,7 +69,7 @@ public class GridSidebarPositionTest extends MultiBrowserTest { Point popupLocation = sidebarPopup.getLocation(); int popupBottom = popupLocation.getY() + popupSize.getHeight(); int sideBarButtonTop = sidebarOpenButton.getLocation().getY(); - Assert.assertTrue(popupBottom <= sideBarButtonTop); + assertTrue(popupBottom <= sideBarButtonTop); } protected WebElement getSidebarOpenButton(GridElement grid) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java index 01355e8801..d1b80bc5a6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSingleColumnTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -32,7 +34,7 @@ public class GridSingleColumnTest extends MultiBrowserTest { openTestURL(); GridCellElement cell = $(GridElement.class).first().getHeaderCell(0, 0); - Assert.assertTrue("No header available", + assertTrue("No header available", cell.getText().equalsIgnoreCase("header")); } @@ -41,7 +43,7 @@ public class GridSingleColumnTest extends MultiBrowserTest { setDebug(true); openTestURL(); - Assert.assertFalse("Exception when scrolling on init", + assertFalse("Exception when scrolling on init", isElementPresent(NotificationElement.class)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java index 2f623e1c51..aae5d367ac 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSortIndicatorTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -32,30 +35,31 @@ public class GridSortIndicatorTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); $(ButtonElement.class).caption("Sort both").first().click(); - Assert.assertTrue("First column should be sorted ascending", + assertTrue("First column should be sorted ascending", grid.getHeaderCell(0, 0).getAttribute("class") .contains("sort-asc")); - Assert.assertEquals("First column should have aria-sort other", "other", + assertEquals("First column should have aria-sort other", "other", grid.getHeaderCell(0, 0).getAttribute("aria-sort")); - Assert.assertEquals("First column should be first in sort order", "1", + assertEquals("First column should be first in sort order", "1", grid.getHeaderCell(0, 0).getAttribute("sort-order")); - Assert.assertTrue("Second column should be sorted ascending", + assertTrue("Second column should be sorted ascending", grid.getHeaderCell(0, 1).getAttribute("class") .contains("sort-asc")); - Assert.assertEquals("Second column should have aria-sort other", "other", + assertEquals("Second column should have aria-sort other", "other", grid.getHeaderCell(0, 1).getAttribute("aria-sort")); - Assert.assertEquals("Second column should be also sorted", "2", + assertEquals("Second column should be also sorted", "2", grid.getHeaderCell(0, 1).getAttribute("sort-order")); $(ButtonElement.class).caption("Sort first").first().click(); - Assert.assertEquals("First column should have aria-sort ascending", "ascending", + assertEquals("First column should have aria-sort ascending", + "ascending", grid.getHeaderCell(0, 0).getAttribute("aria-sort")); - Assert.assertTrue("First column should be sorted ascending", + assertTrue("First column should be sorted ascending", grid.getHeaderCell(0, 0).getAttribute("class") .contains("sort-asc")); - Assert.assertEquals("Second column should have aria-sort none", "none", + assertEquals("Second column should have aria-sort none", "none", grid.getHeaderCell(0, 1).getAttribute("aria-sort")); - Assert.assertFalse("Second column should not be sorted", + assertFalse("Second column should not be sorted", grid.getHeaderCell(0, 1).getAttribute("class") .contains("sort-asc")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java index 07ccf6a95b..120c1cc955 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUndefinedHeightTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -25,7 +26,7 @@ public class GridUndefinedHeightTest extends SingleBrowserTest { int gridHeight = grid.getSize().getHeight(); int rows = 4; // Header Row + 3 Body Rows - Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight); + assertEquals("Grid height mismatch", oneRow * rows, gridHeight); assertNoErrorNotifications(); } @@ -37,7 +38,7 @@ public class GridUndefinedHeightTest extends SingleBrowserTest { int gridHeight = grid.getSize().getHeight(); int rows = 4; // Header Row + 3 Body Rows - Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight); + assertEquals("Grid height mismatch", oneRow * rows, gridHeight); assertNoErrorNotifications(); } @@ -52,7 +53,7 @@ public class GridUndefinedHeightTest extends SingleBrowserTest { int gridHeight = grid.getSize().getHeight(); int rows = 5; // 2 Header Rows + 3 Body Rows - Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight); + assertEquals("Grid height mismatch", oneRow * rows, gridHeight); assertNoErrorNotifications(); } @@ -67,7 +68,7 @@ public class GridUndefinedHeightTest extends SingleBrowserTest { int gridHeight = grid.getSize().getHeight(); int rows = 5; // 2 Header Rows + 3 Body Rows - Assert.assertEquals("Grid height mismatch", oneRow * rows, gridHeight); + assertEquals("Grid height mismatch", oneRow * rows, gridHeight); assertNoErrorNotifications(); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/HorizontalScrollAfterResizeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/HorizontalScrollAfterResizeTest.java index fa612b1a28..0ec0768e38 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/HorizontalScrollAfterResizeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/HorizontalScrollAfterResizeTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Dimension; import org.openqa.selenium.Point; @@ -57,10 +59,10 @@ public class HorizontalScrollAfterResizeTest extends GridBasicFeaturesTest { // With the bug scrolling doesn't happen. Location should be around of // the initial scrolling - Assert.assertEquals(locationAfterFirstScroll.getY(), + assertEquals(locationAfterFirstScroll.getY(), locationAfterSecondScrollcation.getY()); int delta = 5; - Assert.assertTrue(Math.abs(locationAfterFirstScroll.getX() + assertTrue(Math.abs(locationAfterFirstScroll.getX() - locationAfterSecondScrollcation.getX()) < delta); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java index 58abe75731..c20e7900d2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java @@ -15,11 +15,11 @@ */ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.logging.Level; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -35,7 +35,7 @@ public class InitialFrozenColumnsTest extends MultiBrowserTest { setDebug(true); openTestURL(); - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(NotificationElement.class)); WebElement cell = $(GridElement.class).first().getCell(0, 0); @@ -47,7 +47,7 @@ public class InitialFrozenColumnsTest extends MultiBrowserTest { setDebug(true); openTestURL("frozen=3"); - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(NotificationElement.class)); assertNoDebugMessage(Level.SEVERE); WebElement cell = $(GridElement.class).first().getCell(0, 2); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java index b1f3cba508..d24ad87472 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java @@ -1,14 +1,16 @@ package com.vaadin.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -21,8 +23,8 @@ public class InitiallyDisabledGridTest extends SingleBrowserTest { List<WebElement> cells = findElements(By.className("v-grid-cell")); WebElement col0 = cells.get(0); WebElement col1 = cells.get(1); - Assert.assertTrue(col0.getSize().getWidth() > 250); - Assert.assertTrue(col1.getSize().getWidth() > 250); + assertTrue(col0.getSize().getWidth() > 250); + assertTrue(col1.getSize().getWidth() > 250); } @Test @@ -33,6 +35,6 @@ public class InitiallyDisabledGridTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); grid.scrollToRow(80); GridCellElement col0 = grid.getCell(80, 0); - Assert.assertEquals("First 80", col0.getText()); + assertEquals("First 80", col0.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java index 6707e6097d..951889c304 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/JavaScriptRenderersTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -40,17 +42,16 @@ public class JavaScriptRenderersTest extends MultiBrowserTest { GridCellElement cell_2_2 = grid.getCell(2, 2); // Verify render functionality - Assert.assertEquals("Bean(2, 0)", cell_1_1.getText()); + assertEquals("Bean(2, 0)", cell_1_1.getText()); - Assert.assertEquals("string2", cell_2_2.getText()); + assertEquals("string2", cell_2_2.getText()); // Verify init functionality - Assert.assertEquals("1", cell_1_1.getAttribute("column")); + assertEquals("1", cell_1_1.getAttribute("column")); // Verify onbrowserevent cell_1_1.click(); - Assert.assertTrue( - cell_1_1.getText().startsWith("Clicked 1 with key 2 at")); + assertTrue(cell_1_1.getText().startsWith("Clicked 1 with key 2 at")); } @Test @@ -65,9 +66,9 @@ public class JavaScriptRenderersTest extends MultiBrowserTest { WebElement log = findElement(By.id("clientLog")); String text = log.getText(); - Assert.assertTrue(text.contains("destory: 19/3")); - Assert.assertTrue(text.contains("destroy: 19/2")); - Assert.assertTrue(text.contains("destroy: 0/2")); - Assert.assertTrue(text.contains("destory: 0/3")); + assertTrue(text.contains("destory: 19/3")); + assertTrue(text.contains("destroy: 19/2")); + assertTrue(text.contains("destroy: 0/2")); + assertTrue(text.contains("destory: 0/3")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/LocalDateRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/LocalDateRenderersTest.java index 76f17edb63..1bafdbaab2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/LocalDateRenderersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/LocalDateRenderersTest.java @@ -1,11 +1,12 @@ 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.Assert; import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -20,19 +21,20 @@ public class LocalDateRenderersTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); LocalDate epochDate = LocalDate.ofEpochDay(0); - Assert.assertEquals( + assertEquals( epochDate.format( DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG) .withLocale(new Locale("en"))), grid.getCell(0, 0).getText()); - Assert.assertEquals("1. tammikuuta 1970", grid.getCell(0, 1).getText()); - Assert.assertEquals( + assertEquals("1. tammikuuta 1970", grid.getCell(0, 1).getText()); + assertEquals( epochDate.atTime(0, 0) - .format(DateTimeFormatter.ofLocalizedDateTime( - FormatStyle.LONG, FormatStyle.SHORT) + .format(DateTimeFormatter + .ofLocalizedDateTime(FormatStyle.LONG, + FormatStyle.SHORT) .withLocale(new Locale("en"))), grid.getCell(0, 2).getText()); - Assert.assertEquals("1. tammikuuta 1970 klo 0.00.00", + assertEquals("1. tammikuuta 1970 klo 0.00.00", grid.getCell(0, 3).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java index c6d9aa394a..abff073ebe 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -15,7 +16,7 @@ public class MoveGridAndAddRowTest extends SingleBrowserTest { $(ButtonElement.class).id("add").click(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("1", grid.getCell(0, 0).getText()); - Assert.assertEquals("2", grid.getCell(1, 0).getText()); + assertEquals("1", grid.getCell(0, 0).getText()); + assertEquals("2", grid.getCell(1, 0).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java index 908c8c3cec..bb8655bd35 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.grid.basicfeatures; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -74,7 +75,7 @@ public class GridColumnResizeModeTest extends GridBasicsTest { // See that we got a resize event sleep(500); - Assert.assertTrue("Log shows resize event", getLogRow(0) + assertTrue("Log shows resize event", getLogRow(0) .contains("ColumnResizeEvent: isUserOriginated? true")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java index 974ac559e0..0f0202e8ac 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java @@ -15,11 +15,11 @@ */ package com.vaadin.tests.components.grid.basicfeatures.escalator; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.IOException; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -75,7 +75,7 @@ public class EscalatorRemoveAndAddRowsTest private void verifyRow(int escalatorIndex, int rowIndexInText) { // the format of text in cells is // Row: <index_when_updated>: <cell_index>,<index_when_inserted> - Assert.assertEquals("Invalid row present in index " + escalatorIndex, + assertEquals("Invalid row present in index " + escalatorIndex, "Row " + escalatorIndex + ": 0," + rowIndexInText, getBodyCell(escalatorIndex, 0).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicDetailsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicDetailsTest.java index 32b7cf4b92..614de92071 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicDetailsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicDetailsTest.java @@ -56,7 +56,7 @@ public class GridBasicDetailsTest extends GridBasicsTest { try { selectMenuPath(OPEN_FIRST_ITEM_DETAILS); } catch (NoSuchElementException e) { - Assert.fail("Unable to set up details."); + fail("Unable to set up details."); } getGridElement().getDetails(0); @@ -77,7 +77,7 @@ public class GridBasicDetailsTest extends GridBasicsTest { selectMenuPath(OPEN_FIRST_ITEM_DETAILS); selectMenuPath(OPEN_FIRST_ITEM_DETAILS); } catch (NoSuchElementException e) { - Assert.fail("Unable to set up details."); + fail("Unable to set up details."); } getGridElement().getDetails(0); } @@ -100,7 +100,7 @@ public class GridBasicDetailsTest extends GridBasicsTest { selectMenuPath(OPEN_FIRST_ITEM_DETAILS); getGridElement().scroll(0); } catch (NoSuchElementException e) { - Assert.fail("Unable to set up details."); + fail("Unable to set up details."); } getGridElement().getDetails(0); } @@ -135,7 +135,7 @@ public class GridBasicDetailsTest extends GridBasicsTest { // scroll somewhere to hit uncached rows getGridElement().scrollToRow(101); } catch (NoSuchElementException e) { - Assert.fail("Unable to set up details."); + fail("Unable to set up details."); } // this should throw diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicStyleGeneratorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicStyleGeneratorTest.java index b9b93fa884..da4eae84d1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicStyleGeneratorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridBasicStyleGeneratorTest.java @@ -16,8 +16,8 @@ package com.vaadin.tests.components.grid.basics; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; @@ -37,8 +37,8 @@ public class GridBasicStyleGeneratorTest extends GridBasicsTest { GridRowElement row = getGridElement().getRow(2); GridCellElement cell = getGridElement().getCell(3, 2); - Assert.assertTrue(hasCssClass(row, "row2")); - Assert.assertTrue(hasCssClass(cell, "Column_2")); + assertTrue(hasCssClass(row, "row2")); + assertTrue(hasCssClass(cell, "Column_2")); // Scroll down and verify that the old elements don't have the // stylename any more @@ -47,8 +47,8 @@ public class GridBasicStyleGeneratorTest extends GridBasicsTest { row = getGridElement().getRow(352); cell = getGridElement().getCell(353, 2); - Assert.assertFalse(hasCssClass(row, "row352")); - Assert.assertFalse(hasCssClass(cell, "Column_2")); + assertFalse(hasCssClass(row, "row352")); + assertFalse(hasCssClass(cell, "Column_2")); } @Test @@ -63,8 +63,8 @@ public class GridBasicStyleGeneratorTest extends GridBasicsTest { GridRowElement row = getGridElement().getRow(2); GridCellElement cell = getGridElement().getCell(3, 2); - Assert.assertTrue(hasCssClass(row, "row2")); - Assert.assertTrue(hasCssClass(cell, "Column_2")); + assertTrue(hasCssClass(row, "row2")); + assertTrue(hasCssClass(cell, "Column_2")); // Disable the generator and check again selectRowStyleNameGenerator(GridBasics.ROW_STYLE_GENERATOR_NONE); @@ -73,8 +73,8 @@ public class GridBasicStyleGeneratorTest extends GridBasicsTest { row = getGridElement().getRow(2); cell = getGridElement().getCell(3, 2); - Assert.assertFalse(hasCssClass(row, "row2")); - Assert.assertFalse(hasCssClass(cell, "Column_2")); + assertFalse(hasCssClass(row, "row2")); + assertFalse(hasCssClass(cell, "Column_2")); } @Test @@ -89,8 +89,8 @@ public class GridBasicStyleGeneratorTest extends GridBasicsTest { GridRowElement row = getGridElement().getRow(2); GridCellElement cell = getGridElement().getCell(3, 2); - Assert.assertTrue(hasCssClass(row, "row2")); - Assert.assertTrue(hasCssClass(cell, "Column_2")); + assertTrue(hasCssClass(row, "row2")); + assertTrue(hasCssClass(cell, "Column_2")); // Change the generator and check again selectRowStyleNameGenerator(GridBasics.ROW_STYLE_GENERATOR_NONE); @@ -101,11 +101,11 @@ public class GridBasicStyleGeneratorTest extends GridBasicsTest { cell = getGridElement().getCell(3, 2); // Old styles removed? - Assert.assertFalse(hasCssClass(row, "row2")); - Assert.assertFalse(hasCssClass(cell, "Column_2")); + assertFalse(hasCssClass(row, "row2")); + assertFalse(hasCssClass(cell, "Column_2")); // New style present? - Assert.assertTrue(hasCssClass(cell, "Column-2")); + assertTrue(hasCssClass(cell, "Column-2")); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridContentTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridContentTest.java index ba7187a5ec..55fd4f90c0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridContentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridContentTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.grid.basics; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; public class GridContentTest extends GridBasicsTest { @@ -8,10 +9,10 @@ public class GridContentTest extends GridBasicsTest { @Test public void testHtmlRenderer() { DataObject first = getTestData().findFirst().orElse(null); - Assert.assertEquals("Text content should match row number", + assertEquals("Text content should match row number", first.getRowNumber().toString(), getGridElement().getCell(0, 5).getText()); - Assert.assertEquals("HTML content did not match", first.getHtmlString(), + assertEquals("HTML content did not match", first.getHtmlString(), getGridElement().getCell(0, 5).getAttribute("innerHTML")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java index c99c31d4f7..7ec0bfb477 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridRowHeightTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.grid.basics; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; public class GridRowHeightTest extends GridBasicsTest { @@ -11,7 +13,7 @@ public class GridRowHeightTest extends GridBasicsTest { int initialHeaderHeight = getHeaderHeight(); - Assert.assertNotEquals("Header height should not be 50px initially", 50, + assertNotEquals("Header height should not be 50px initially", 50, initialHeaderHeight); selectMenuPath("Component", "Body rows", "Body Row Height", "" + 100); @@ -50,11 +52,11 @@ public class GridRowHeightTest extends GridBasicsTest { private void checkRowHeights(int expectedHeaderHeight, int expectedBodyRowHeight, int expectedFooterHeight) { - Assert.assertEquals("Header height does not match expected value", + assertEquals("Header height does not match expected value", expectedHeaderHeight, getHeaderHeight()); - Assert.assertEquals("Body row height does not match expected value", + assertEquals("Body row height does not match expected value", expectedBodyRowHeight, getBodyRowHeight()); - Assert.assertEquals("Footer height does not match expected value", + assertEquals("Footer height does not match expected value", expectedFooterHeight, getFooterHeight()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java index 4a6ddc4f61..42641ab7de 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridSortingTest.java @@ -1,12 +1,14 @@ package com.vaadin.tests.components.grid.basics; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.remote.DesiredCapabilities; @@ -35,8 +37,7 @@ public class GridSortingTest extends GridBasicsTest { for (Integer rowNumber : getTestData().sorted(BIG_RANDOM) .map(DataObject::getRowNumber).limit(5) .collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", rowNumber.toString(), getGridElement().getCell(i++, 3).getText()); } @@ -52,8 +53,7 @@ public class GridSortingTest extends GridBasicsTest { .sorted(SMALL_RANDOM.thenComparing(BIG_RANDOM)) .map(DataObject::getRowNumber).limit(5) .collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", rowNumber.toString(), getGridElement().getCell(i++, 3).getText()); } @@ -63,31 +63,27 @@ public class GridSortingTest extends GridBasicsTest { public void serverSideOrderByColumn0() { selectMenuPath("Component", "Columns", "Column 0", "Sort ASC"); - Assert.assertEquals("1. SortEvent: isUserOriginated? false", - getLogRow(0)); + assertEquals("1. SortEvent: isUserOriginated? false", getLogRow(0)); Comparator<String> comparator = Comparator.naturalOrder(); int i = 0; for (String coord : getTestData().map(DataObject::getCoordinates) .sorted(comparator).limit(5).collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", coord, getGridElement().getCell(i++, 0).getText()); } // self-verification - Assert.assertTrue(i > 0); + assertTrue(i > 0); selectMenuPath("Component", "Columns", "Column 0", "Sort DESC"); - Assert.assertEquals("2. SortEvent: isUserOriginated? false", - getLogRow(0)); + assertEquals("2. SortEvent: isUserOriginated? false", getLogRow(0)); i = 0; for (String coord : getTestData().map(DataObject::getCoordinates) .sorted(comparator.reversed()).limit(5) .collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", coord, getGridElement().getCell(i++, 0).getText()); } } @@ -96,32 +92,28 @@ public class GridSortingTest extends GridBasicsTest { public void serverSideOrderByDate() { selectMenuPath("Component", "Columns", "Date", "Sort ASC"); - Assert.assertEquals("1. SortEvent: isUserOriginated? false", - getLogRow(0)); + assertEquals("1. SortEvent: isUserOriginated? false", getLogRow(0)); Comparator<Date> comparator = Comparator.naturalOrder(); int i = 0; for (Date date : getTestData().map(DataObject::getDate) .sorted(comparator).limit(5).collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", date.toString(), getGridElement().getCell(i++, 4).getText()); } // self-verification - Assert.assertTrue(i > 0); + assertTrue(i > 0); selectMenuPath("Component", "Columns", "Date", "Sort DESC"); - Assert.assertEquals("2. SortEvent: isUserOriginated? false", - getLogRow(0)); + assertEquals("2. SortEvent: isUserOriginated? false", getLogRow(0)); i = 0; for (Date date : getTestData().map(DataObject::getDate) .sorted(comparator.reversed()).limit(5) .collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", date.toString(), getGridElement().getCell(i++, 4).getText()); } @@ -132,18 +124,16 @@ public class GridSortingTest extends GridBasicsTest { selectMenuPath("Component", "Columns", "Column 0", "Sort ASC"); selectMenuPath("Component", "Columns", "Clear sort"); - Assert.assertEquals("2. SortEvent: isUserOriginated? false", - getLogRow(0)); + assertEquals("2. SortEvent: isUserOriginated? false", getLogRow(0)); int i = 0; for (String coord : getTestData().map(DataObject::getCoordinates) .limit(5).collect(Collectors.toList())) { - Assert.assertEquals( - "Grid was not sorted as expected, row number mismatch", + assertEquals("Grid was not sorted as expected, row number mismatch", coord, getGridElement().getCell(i++, 0).getText()); } // self-verification - Assert.assertTrue(i > 0); + assertTrue(i > 0); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java index 7c60bb9572..a3eccef4a4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.grid.basics; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -34,8 +36,7 @@ public class RefreshDataProviderTest extends MultiBrowserTest { findElement(By.id("update")).click(); WebElement first = findElement(By.tagName("td")); - Assert.assertEquals( - "UI component is not refreshed after update in data", + assertEquals("UI component is not refreshed after update in data", "Updated coordinates", first.getText()); } @@ -46,7 +47,7 @@ public class RefreshDataProviderTest extends MultiBrowserTest { findElement(By.id("add")).click(); WebElement first = findElement(By.tagName("td")); - Assert.assertEquals("UI component is not refreshed after add new data", + assertEquals("UI component is not refreshed after add new data", "Added", first.getText()); } @@ -57,8 +58,8 @@ public class RefreshDataProviderTest extends MultiBrowserTest { WebElement first = findElement(By.tagName("td")); String old = first.getText(); first = findElement(By.id("remove")); - Assert.assertNotEquals("UI component is not refreshed after removal", - old, first.getText()); + assertNotEquals("UI component is not refreshed after removal", old, + first.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java index fafcfbd77e..a4f91e516f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/ComponentAlignmentsTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.gridlayout; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -42,14 +43,14 @@ public class ComponentAlignmentsTest extends MultiBrowserTest { int rightSpaceSize = parent.getLocation().getX() + parent.getSize().getWidth() - checkbox.getLocation().getX() - checkbox.getSize().getWidth(); - Assert.assertTrue("No space on the left for centered element", + assertTrue("No space on the left for centered element", leftSpaceSize > 0); - Assert.assertTrue("No space on the right for centered element", + assertTrue("No space on the right for centered element", rightSpaceSize > 0); int diff = Math.abs(rightSpaceSize - leftSpaceSize); - Assert.assertTrue("Element is not in the center, diff:" + diff, - diff <= 2); // IE11 2pixels + assertTrue("Element is not in the center, diff:" + diff, diff <= 2); // IE11 + // 2pixels } @Test @@ -64,14 +65,14 @@ public class ComponentAlignmentsTest extends MultiBrowserTest { int rightSpaceSize = parent.getLocation().getX() + parent.getSize().getWidth() - checkbox.getLocation().getX() - checkbox.getSize().getWidth(); - Assert.assertTrue("No space on the left for centered element", + assertTrue("No space on the left for centered element", leftSpaceSize > 0); - Assert.assertTrue("There is some space on the right for the element", + assertTrue("There is some space on the right for the element", rightSpaceSize <= 1); int sizeDiff = parent.getSize().getWidth() - checkbox.getSize().getWidth(); - Assert.assertTrue("Element is not in aligned to the right", + assertTrue("Element is not in aligned to the right", Math.abs(sizeDiff - leftSpaceSize) <= 1); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutAlignmentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutAlignmentsTest.java index c677dcb1ce..26f4c7f771 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutAlignmentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutAlignmentsTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.gridlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Point; @@ -79,8 +80,8 @@ public class GridLayoutAlignmentsTest extends MultiBrowserTest { x++; y++; - Assert.assertEquals("X offset incorrect", x, offsetX); - Assert.assertEquals("Y offset incorrect", y, offsetY); + assertEquals("X offset incorrect", x, offsetX); + assertEquals("Y offset incorrect", y, offsetY); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java index d489cd9614..0bdd0c653b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutCellSizesUITest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.gridlayout; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -41,7 +43,7 @@ public class GridLayoutCellSizesUITest extends MultiBrowserTest { // items in positions 0,1,2,3,4,5 should have the same height int firstSlotHeight = getSlotHeight(0); for (int i = 1; i < 6; i++) { - Assert.assertEquals("Cell height didn't match for cell: " + i, + assertEquals("Cell height didn't match for cell: " + i, firstSlotHeight, getSlotHeight(i)); } } @@ -59,12 +61,12 @@ public class GridLayoutCellSizesUITest extends MultiBrowserTest { @Test public void expandedRowsShouldHaveCorrectHeight() { // Slots expanding over 2 rows should have the same height. - Assert.assertEquals("1x2 and 2x2 cell heights didn't match", - getSlotHeight(7), getSlotHeight(8)); + assertEquals("1x2 and 2x2 cell heights didn't match", getSlotHeight(7), + getSlotHeight(8)); // Slots on same row as the 1x2 label should have the same combined // height. - Assert.assertEquals( + assertEquals( "1x2 and combined row two and row three cell heights didn't match", getSlotHeight(7), getSlotHeight(6) + getSlotHeight(9)); } @@ -72,17 +74,16 @@ public class GridLayoutCellSizesUITest extends MultiBrowserTest { @Test public void expandedRowsShouldHaveCorrectWidth() { // Col 2 slot should be the dame width as 1x2 cell slot - Assert.assertEquals( - "Col 2 slot was not the same width as slot for 1x2 cell", + assertEquals("Col 2 slot was not the same width as slot for 1x2 cell", getSlotWidth(1), getSlotWidth(7)); // Row one col 3 & 4 should be as wide as the 2x2 date field - Assert.assertEquals( + assertEquals( "2x2 date field width didn't match col 3 & col 4 combined width", getSlotWidth(8), getSlotWidth(2) + getSlotWidth(3)); // 3x1 button should be as wide as 1x2cell + 2x2 data field - Assert.assertEquals( + assertEquals( "3x1 slot width wasn't the same as the combined slot widths of 1x2 cell and 2x2 date field", getSlotWidth(5), getSlotWidth(7) + getSlotWidth(8)); @@ -90,8 +91,7 @@ public class GridLayoutCellSizesUITest extends MultiBrowserTest { private void assertNotMatchesSmallHeight(int firstSlotHeight, int i, String id) { - Assert.assertNotEquals( - "Big slot '" + id + "' matched small slots in height", + assertNotEquals("Big slot '" + id + "' matched small slots in height", firstSlotHeight, getSlotHeight(i)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExpandWithManyRowsTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExpandWithManyRowsTest.java index 39648a5083..42566a37ea 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExpandWithManyRowsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExpandWithManyRowsTest.java @@ -1,8 +1,10 @@ package com.vaadin.tests.components.gridlayout; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -23,16 +25,15 @@ public class GridLayoutExpandWithManyRowsTest extends SingleBrowserTest { // lower than the first row List<WebElement> slots = gridlayout .findElements(By.className("v-gridlayout-slot")); - Assert.assertEquals(GridLayoutExpandWithManyRows.POPULATED_ROWS, - slots.size()); + assertEquals(GridLayoutExpandWithManyRows.POPULATED_ROWS, slots.size()); int firstRowHeight = slots.get(0).getSize().height; int lastRowHeight = firstRowHeight; for (int i = 1; i < GridLayoutExpandWithManyRows.POPULATED_ROWS; i++) { int rowHeight = slots.get(i).getSize().height; - Assert.assertTrue(rowHeight <= firstRowHeight); - Assert.assertTrue(rowHeight >= firstRowHeight - 2); - Assert.assertTrue(rowHeight <= lastRowHeight); + assertTrue(rowHeight <= firstRowHeight); + assertTrue(rowHeight >= firstRowHeight - 2); + assertTrue(rowHeight <= lastRowHeight); lastRowHeight = rowHeight; } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java index 4d884da3c1..15b4f9c507 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacingTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.gridlayout; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -85,7 +87,7 @@ public class GridLayoutExtraSpacingTest extends MultiBrowserTest { assertHeight(component, 500 - spacing, 1); int offset = component.getLocation().getY() - gridLayout.getLocation().getY(); - Assert.assertEquals(spacing, offset); + assertEquals(spacing, offset); } @@ -95,12 +97,12 @@ public class GridLayoutExtraSpacingTest extends MultiBrowserTest { int offset = component.getLocation().getY() - gridLayout.getLocation().getY(); - Assert.assertEquals(0, offset); + assertEquals(0, offset); } private void assertHeight(WebElement component, int height, int tolerance) { - Assert.assertTrue(Math + assertTrue(Math .abs(height - component.getSize().getHeight()) <= tolerance); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java index c8bce3a7aa..59e3c074c2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutFocusOrderAfterShowChildTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.gridlayout; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; @@ -38,13 +39,12 @@ public class GridLayoutFocusOrderAfterShowChildTest extends MultiBrowserTest { $(ButtonElement.class).first().click(); - Assert.assertEquals("First", - grid.$(LabelElement.class).first().getText()); + assertEquals("First", grid.$(LabelElement.class).first().getText()); grid.$(TextFieldElement.class).first().focus(); grid.$(TextFieldElement.class).first().sendKeys(Keys.TAB); - Assert.assertEquals("t2", + assertEquals("t2", driver.switchTo().activeElement().getAttribute("id")); } @@ -57,13 +57,12 @@ public class GridLayoutFocusOrderAfterShowChildTest extends MultiBrowserTest { $(ButtonElement.class).get(1).click(); - Assert.assertEquals("Third", - grid.$(LabelElement.class).get(1).getText()); + assertEquals("Third", grid.$(LabelElement.class).get(1).getText()); grid.$(TextFieldElement.class).first().focus(); grid.$(TextFieldElement.class).first().sendKeys(Keys.TAB); - Assert.assertEquals("t3", + assertEquals("t3", driver.switchTo().activeElement().getAttribute("id")); } @@ -76,13 +75,12 @@ public class GridLayoutFocusOrderAfterShowChildTest extends MultiBrowserTest { $(ButtonElement.class).get(2).click(); - Assert.assertEquals("Fifth", - grid.$(LabelElement.class).get(2).getText()); + assertEquals("Fifth", grid.$(LabelElement.class).get(2).getText()); grid.$(TextFieldElement.class).get(1).focus(); grid.$(TextFieldElement.class).get(1).sendKeys(Keys.TAB); - Assert.assertEquals("t5", + assertEquals("t5", driver.switchTo().activeElement().getAttribute("id")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutRequiredIndicatorLocationTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutRequiredIndicatorLocationTest.java index a1afe0edb3..366eacd44b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutRequiredIndicatorLocationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutRequiredIndicatorLocationTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.gridlayout; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -90,7 +91,7 @@ public class GridLayoutRequiredIndicatorLocationTest extends MultiBrowserTest { + field.getSize().getWidth(); int actualIndicatorPosition = caption.getLocation().getX(); - Assert.assertEquals("Required indicator has wrong position", + assertEquals("Required indicator has wrong position", desiredIndicatorPosition, actualIndicatorPosition, 1d); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java index b8caac693d..714ac6a6d6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/gridlayout/GridLayoutWithLabelTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.gridlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.CheckBoxElement; @@ -21,7 +22,7 @@ public class GridLayoutWithLabelTest extends MultiBrowserTest { cb.click(); // Turn off int after = gridLayout.getSize().getWidth(); - Assert.assertEquals( + assertEquals( "layout width should not have changed after checkbox was toggled", before, after); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java index 7aa5575696..4597015a72 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponentTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.javascriptcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -14,44 +16,42 @@ public class BasicJavaScriptComponentTest extends MultiBrowserTest { public void javascriptCommunication() throws Exception { openTestURL(); int idx = 0; - Assert.assertEquals( - "12. Got callback message: Callback message processed", + assertEquals("12. Got callback message: Callback message processed", getLogRow(idx++)); - Assert.assertEquals("11. Got RPC message: RPC message processed", + assertEquals("11. Got RPC message: RPC message processed", getLogRow(idx++)); - Assert.assertEquals("10. Parent ids checked", getLogRow(idx++)); + assertEquals("10. Parent ids checked", getLogRow(idx++)); // Data types in JS functions String expected = "1970-01-01T00:00:00.111Z"; - Assert.assertEquals( + assertEquals( "9. Argument[4][aDate] type: elemental.json.impl.JreJsonString, value: " + expected, getLogRow(idx++)); - Assert.assertEquals( + assertEquals( "8. Argument[4][aBoolean] type: elemental.json.impl.JreJsonBoolean, value: false", getLogRow(idx++)); - Assert.assertEquals( + assertEquals( "7. Argument[4][anInt] type: elemental.json.impl.JreJsonNumber, value: 556", getLogRow(idx++)); - Assert.assertEquals( + assertEquals( "6. Argument[4][aString] type: elemental.json.impl.JreJsonString, value: value1", getLogRow(idx++)); - Assert.assertEquals( - "5. Argument[4] type: elemental.json.impl.JreJsonObject", + assertEquals("5. Argument[4] type: elemental.json.impl.JreJsonObject", getLogRow(idx++)); - Assert.assertEquals( + assertEquals( "4. Argument[3] type: elemental.json.impl.JreJsonBoolean, value: true", getLogRow(idx++)); - Assert.assertEquals( + assertEquals( "3. Argument[2] type: elemental.json.impl.JreJsonNumber, value: 556", getLogRow(idx++)); - Assert.assertEquals( + assertEquals( "2. Argument[1] type: elemental.json.impl.JreJsonString, value: a string", getLogRow(idx++)); expected = "1970-01-01T00:00:00.123Z"; - Assert.assertEquals( + assertEquals( "1. Argument[0] type: elemental.json.impl.JreJsonString, value: " + expected, getLogRow(idx++)); @@ -59,14 +59,14 @@ public class BasicJavaScriptComponentTest extends MultiBrowserTest { // Component attributes AbstractJavaScriptComponentElement jsComponent = $( AbstractJavaScriptComponentElement.class).first(); - Assert.assertEquals("Component caption", getCaption(jsComponent)); + assertEquals("Component caption", getCaption(jsComponent)); // app://APP/connector/[uiid]/[cid]/[key]/[filename] - Assert.assertTrue(getChildText(jsComponent, 0) + assertTrue(getChildText(jsComponent, 0) .matches("4. Url: .*/run/APP/connector/0/\\d+/test")); - Assert.assertEquals("3. State message: Second state message", + assertEquals("3. State message: Second state message", getChildText(jsComponent, 1)); - Assert.assertEquals("2. State message: First state message", + assertEquals("2. State message: First state message", getChildText(jsComponent, 2)); // Can't/shouldn't check parent class name as we used to because it @@ -76,8 +76,7 @@ public class BasicJavaScriptComponentTest extends MultiBrowserTest { // Modifications ButtonElement button = $(ButtonElement.class).first(); button.click(); - Assert.assertEquals("Remove component\nDon't mess with me", - button.getText()); + assertEquals("Remove component\nDon't mess with me", button.getText()); } private String getCaption(AbstractComponentElement c) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/DuplicateJavascriptDependenciesTest.java b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/DuplicateJavascriptDependenciesTest.java index 652cd75e03..015d9b2b83 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/DuplicateJavascriptDependenciesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/DuplicateJavascriptDependenciesTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.javascriptcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -28,7 +29,6 @@ public class DuplicateJavascriptDependenciesTest extends SingleBrowserTest { public void duplicateJavascriptsDoNotCauseProblems() { openTestURL(); $(ButtonElement.class).first().click(); - Assert.assertEquals("It works", - $(LabelElement.class).id("result").getText()); + assertEquals("It works", $(LabelElement.class).id("result").getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JSComponentLoadingIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JSComponentLoadingIndicatorTest.java index a1c5edd095..23335d58b0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JSComponentLoadingIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JSComponentLoadingIndicatorTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.javascriptcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -18,12 +19,12 @@ public class JSComponentLoadingIndicatorTest extends SingleBrowserTest { js.click(); waitUntilLoadingIndicatorVisible(); waitUntilLoadingIndicatorNotVisible(); - Assert.assertEquals(1, findElements(By.className("pong")).size()); + assertEquals(1, findElements(By.className("pong")).size()); js.click(); waitUntilLoadingIndicatorVisible(); waitUntilLoadingIndicatorNotVisible(); - Assert.assertEquals(2, findElements(By.className("pong")).size()); + assertEquals(2, findElements(By.className("pong")).size()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUITest.java b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUITest.java index 623442a7ce..4dd6ff1387 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptNoLayoutHandlingUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.javascriptcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -29,9 +30,9 @@ public class JavaScriptNoLayoutHandlingUITest extends MultiBrowserTest { public void stateUpdate() { openTestURL("debug"); WebElement js = findElement(By.id("js")); - Assert.assertEquals("state: 1", js.getText()); + assertEquals("state: 1", js.getText()); $(ButtonElement.class).first().click(); - Assert.assertEquals("state: 2", js.getText()); + assertEquals("state: 2", js.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptStateTrackingTest.java b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptStateTrackingTest.java index 760ec04af6..c277d9e754 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptStateTrackingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptStateTrackingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.javascriptcomponent; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.By; @@ -46,11 +47,11 @@ public class JavaScriptStateTrackingTest extends SingleBrowserTest { private void assertValues(int expectedCounter, String expectedField1, String expectedField2) { - Assert.assertEquals(String.valueOf(expectedCounter), + assertEquals(String.valueOf(expectedCounter), findElement(By.id("counter")).getText()); - Assert.assertEquals(String.valueOf(expectedField1), + assertEquals(String.valueOf(expectedField1), findElement(By.id("field1")).getText()); - Assert.assertEquals(String.valueOf(expectedField2), + assertEquals(String.valueOf(expectedField2), findElement(By.id("field2")).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/StateChangeCounterTest.java b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/StateChangeCounterTest.java index 0dd88ef75a..08938632a9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/StateChangeCounterTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/javascriptcomponent/StateChangeCounterTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.tests.components.javascriptcomponent; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -54,6 +55,6 @@ public class StateChangeCounterTest extends SingleBrowserTest { private void assertMessages(String... expectedMessages) { List<String> actualMessages = findElements(By.className("logRow")) .stream().map(WebElement::getText).collect(Collectors.toList()); - Assert.assertEquals(Arrays.asList(expectedMessages), actualMessages); + assertEquals(Arrays.asList(expectedMessages), actualMessages); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/label/LabelTooltipTest.java b/uitest/src/test/java/com/vaadin/tests/components/label/LabelTooltipTest.java index c88a16387d..8a963e0b83 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/label/LabelTooltipTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/label/LabelTooltipTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.label; +import static org.junit.Assert.assertEquals; + import java.io.IOException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; @@ -53,8 +54,7 @@ public class LabelTooltipTest extends MultiBrowserTest { private void assertTooltips() throws IOException { $(LabelElement.class).get(2).showTooltip(); - Assert.assertEquals("Default tooltip content", - getTooltipElement().getText()); + assertEquals("Default tooltip content", getTooltipElement().getText()); /* * Some cases tooltip doesn't disappear without some extra mouse events @@ -64,11 +64,10 @@ public class LabelTooltipTest extends MultiBrowserTest { .click().perform(); $(LabelElement.class).get(4).showTooltip(); - Assert.assertEquals( + assertEquals( "Error inside tooltip together with the regular tooltip message.", getTooltipErrorElement().getText()); - Assert.assertEquals("Default tooltip content", - getTooltipElement().getText()); + assertEquals("Default tooltip content", getTooltipElement().getText()); /* Visual comparison */ compareScreen("tooltipVisible"); diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItemsTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItemsTest.java index ee655c40af..b51f6e473b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItemsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItemsTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.listselect; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -53,7 +54,7 @@ public class ListSelectAddRemoveItemsTest extends SingleBrowserTest { } private void assertOptions(String... options) { - Assert.assertEquals(Arrays.asList(options), + assertEquals(Arrays.asList(options), $(ListSelectElement.class).first().getOptions()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectNoDomRebuildTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectNoDomRebuildTest.java index e63f10f987..1133bb0c1a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectNoDomRebuildTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectNoDomRebuildTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.listselect; +import static org.junit.Assert.assertNotNull; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -63,7 +64,7 @@ public class ListSelectNoDomRebuildTest extends SingleBrowserTest { for (WebElement element : options) { // We really don't expect the text to be null, mainly doing this // since getText() will throw if the element is detached. - Assert.assertNotNull(element.getText()); + assertNotNull(element.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java index f6137387d7..f819dcc396 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.listselect; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.HashSet; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; @@ -86,7 +87,7 @@ public class ListSelectStyleNamesTest extends SingleBrowserTest { private void assertStyleNames(TestBenchElement element, String... styleNames) { - Assert.assertEquals(new HashSet<>(Arrays.asList(styleNames)), + assertEquals(new HashSet<>(Arrays.asList(styleNames)), element.getClassNames()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java index e256a9c525..a95b52f6fb 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java @@ -1,7 +1,9 @@ package com.vaadin.tests.components.listselect; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Arrays; import java.util.List; @@ -9,7 +11,6 @@ import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -49,24 +50,23 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { selectMenuPath("Component", "Listeners", "Selection listener"); selectItem("Item 4"); - Assert.assertEquals("1. Selected: [Item 4]", getLogRow(0)); + assertEquals("1. Selected: [Item 4]", getLogRow(0)); selectItem("Item 2"); - Assert.assertEquals("3. Selected: [Item 2]", getLogRow(0)); + assertEquals("3. Selected: [Item 2]", getLogRow(0)); addItemsToSelection("Item 4"); - Assert.assertEquals("4. Selected: [Item 2, Item 4]", getLogRow(0)); + assertEquals("4. Selected: [Item 2, Item 4]", getLogRow(0)); addItemsToSelection("Item 10", "Item 0", "Item 9"); // will cause 3 // events - Assert.assertEquals( - "7. Selected: [Item 2, Item 4, Item 10, Item 0, Item 9]", + assertEquals("7. Selected: [Item 2, Item 4, Item 10, Item 0, Item 9]", getLogRow(0)); removeItemsFromSelection("Item 0", "Item 2", "Item 9"); // will cause 3 // events - Assert.assertEquals("10. Selected: [Item 4, Item 10]", getLogRow(0)); + assertEquals("10. Selected: [Item 4, Item 10]", getLogRow(0)); } @Test @@ -74,15 +74,17 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { selectMenuPath("Component", "Listeners", "Selection listener"); selectItem("Item 4"); - Assert.assertEquals("1. Selected: [Item 4]", getLogRow(0)); + assertEquals("1. Selected: [Item 4]", getLogRow(0)); - getListSelect().findElement(By.tagName("select")).sendKeys(Keys.ARROW_UP); + getListSelect().findElement(By.tagName("select")) + .sendKeys(Keys.ARROW_UP); - Assert.assertEquals("2. Selected: [Item 3]", getLogRow(0)); + assertEquals("2. Selected: [Item 3]", getLogRow(0)); - getListSelect().findElement(By.tagName("select")).sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN); + getListSelect().findElement(By.tagName("select")) + .sendKeys(Keys.ARROW_DOWN, Keys.ARROW_DOWN); - Assert.assertEquals("4. Selected: [Item 5]", getLogRow(0)); + assertEquals("4. Selected: [Item 5]", getLogRow(0)); } @@ -92,23 +94,23 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { List<WebElement> select = getListSelect() .findElements(By.tagName("select")); - Assert.assertEquals(1, select.size()); - Assert.assertNotNull(select.get(0).getAttribute("disabled")); + assertEquals(1, select.size()); + assertNotNull(select.get(0).getAttribute("disabled")); selectMenuPath("Component", "Listeners", "Selection listener"); String lastLogRow = getLogRow(0); selectItem("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); addItemsToSelection("Item 2"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); removeItemsFromSelection("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); } @@ -119,13 +121,13 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { List<WebElement> select = getListSelect() .findElements(By.tagName("select")); - Assert.assertEquals(1, select.size()); - Assert.assertNotNull(select.get(0).getAttribute("disabled")); + assertEquals(1, select.size()); + assertNotNull(select.get(0).getAttribute("disabled")); String lastLogRow = getLogRow(0); selectItem("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); } @@ -136,8 +138,8 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { List<WebElement> select = getListSelect() .findElements(By.tagName("select")); - Assert.assertEquals(1, select.size()); - Assert.assertNotNull(select.get(0).getAttribute("disabled")); + assertEquals(1, select.size()); + assertNotNull(select.get(0).getAttribute("disabled")); addItemsToSelection("Item 2"); } @@ -152,8 +154,8 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { List<WebElement> select = getListSelect() .findElements(By.tagName("select")); - Assert.assertEquals(1, select.size()); - Assert.assertNotNull(select.get(0).getAttribute("disabled")); + assertEquals(1, select.size()); + assertNotNull(select.get(0).getAttribute("disabled")); removeItemsFromSelection("Item 4"); } @@ -169,16 +171,16 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { selectMenuPath("Component", "State", "Enabled"); selectItem("Item 5"); - Assert.assertEquals("3. Selected: [Item 5]", getLogRow(0)); + assertEquals("3. Selected: [Item 5]", getLogRow(0)); selectItem("Item 1"); - Assert.assertEquals("5. Selected: [Item 1]", getLogRow(0)); + assertEquals("5. Selected: [Item 1]", getLogRow(0)); addItemsToSelection("Item 2"); - Assert.assertEquals("6. Selected: [Item 1, Item 2]", getLogRow(0)); + assertEquals("6. Selected: [Item 1, Item 2]", getLogRow(0)); removeItemsFromSelection("Item 1"); - Assert.assertEquals("7. Selected: [Item 2]", getLogRow(0)); + assertEquals("7. Selected: [Item 2]", getLogRow(0)); } @Test @@ -192,16 +194,16 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { selectMenuPath("Component", "State", "Readonly"); selectItem("Item 5"); - Assert.assertEquals("3. Selected: [Item 5]", getLogRow(0)); + assertEquals("3. Selected: [Item 5]", getLogRow(0)); selectItem("Item 1"); - Assert.assertEquals("5. Selected: [Item 1]", getLogRow(0)); + assertEquals("5. Selected: [Item 1]", getLogRow(0)); addItemsToSelection("Item 2"); - Assert.assertEquals("6. Selected: [Item 1, Item 2]", getLogRow(0)); + assertEquals("6. Selected: [Item 1, Item 2]", getLogRow(0)); removeItemsFromSelection("Item 1"); - Assert.assertEquals("7. Selected: [Item 2]", getLogRow(0)); + assertEquals("7. Selected: [Item 2]", getLogRow(0)); } @Test @@ -216,17 +218,17 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { selectMenuPath("Component", "Listeners", "Selection listener"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("2. Selected: [Item 5]", getLogRow(0)); + assertEquals("2. Selected: [Item 5]", getLogRow(0)); assertSelected("Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 1"); // Selection order (most recently selected is last) - Assert.assertEquals("4. Selected: [Item 5, Item 1]", getLogRow(0)); + assertEquals("4. Selected: [Item 5, Item 1]", getLogRow(0)); // DOM order assertSelected("Item 1", "Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("6. Selected: [Item 1]", getLogRow(0)); + assertEquals("6. Selected: [Item 1]", getLogRow(0)); assertSelected("Item 1"); } @@ -238,8 +240,7 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { } private void assertSelected(String... expectedSelection) { - Assert.assertEquals(Arrays.asList(expectedSelection), - getSelectedValues()); + assertEquals(Arrays.asList(expectedSelection), getSelectedValues()); } @Override @@ -264,7 +265,7 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { if (first.isPresent()) { first.get().click(); } else { - Assert.fail("No element present with text " + text); + fail("No element present with text " + text); } } @@ -282,7 +283,7 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { } private void assertNothingSelected() { - Assert.assertEquals(0, getSelectedValues().size()); + assertEquals(0, getSelectedValues().size()); } protected void assertItems(int count, String suffix) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/loginform/CustomizedLoginFormUITest.java b/uitest/src/test/java/com/vaadin/tests/components/loginform/CustomizedLoginFormUITest.java index 4db7fb658b..02d3b20245 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/loginform/CustomizedLoginFormUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/loginform/CustomizedLoginFormUITest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.loginform; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.By; @@ -12,9 +13,9 @@ public class CustomizedLoginFormUITest extends LoginFormUITest { @Test public void captionsCorrect() { openTestURL(); - Assert.assertEquals("Identifiant", getUsernameCaption()); - Assert.assertEquals("Mot de passe", getPasswordCaption()); - Assert.assertEquals("Se connecter", getLoginCaption()); + assertEquals("Identifiant", getUsernameCaption()); + assertEquals("Mot de passe", getPasswordCaption()); + assertEquals("Se connecter", getLoginCaption()); } private String getLoginCaption() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/loginform/LoginFormUITest.java b/uitest/src/test/java/com/vaadin/tests/components/loginform/LoginFormUITest.java index 4648b750f1..171f341852 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/loginform/LoginFormUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/loginform/LoginFormUITest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.loginform; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -17,7 +18,7 @@ public class LoginFormUITest extends SingleBrowserTest { getUsername().sendKeys("user123"); getPassword().sendKeys("pass123"); getLogin().click(); - Assert.assertEquals("User 'user123', password='pass123' logged in", + assertEquals("User 'user123', password='pass123' logged in", getInfo().getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java index 7213d2d466..4da01aabaa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarIconsTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.menubar; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -69,13 +71,13 @@ public class MenuBarIconsTest extends SingleBrowserTest { private void assertImage(String image, WebElement menuItem) { WebElement imageElement = menuItem.findElement(By.className("v-icon")); - Assert.assertTrue(imageElement.getAttribute("src").endsWith(image)); + assertTrue(imageElement.getAttribute("src").endsWith(image)); } private void assertFontIcon(FontAwesome expected, WebElement menuItem) { WebElement mainIcon = menuItem.findElement(By.className("v-icon")); - Assert.assertEquals(expected.getCodepoint(), + assertEquals(expected.getCodepoint(), mainIcon.getText().codePointAt(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java index 8737ba054e..2f8c4f2e46 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java @@ -1,9 +1,9 @@ package com.vaadin.tests.components.menubar; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -36,34 +36,34 @@ public class MenuBarNavigationKeyboardTest extends MultiBrowserTest { openMenu("File"); getMenuBar().sendKeys(Keys.DOWN, Keys.DOWN, Keys.DOWN, Keys.DOWN, Keys.RIGHT, Keys.ENTER); - Assert.assertEquals("1. MenuItem File/Export../As PDF... selected", + assertEquals("1. MenuItem File/Export../As PDF... selected", getLogRow(0)); openMenu("File"); getMenuBar().sendKeys(Keys.RIGHT, Keys.RIGHT, Keys.RIGHT, Keys.ENTER); - Assert.assertEquals("2. MenuItem Help selected", getLogRow(0)); + assertEquals("2. MenuItem Help selected", getLogRow(0)); openMenu("Edit"); getMenuBar().sendKeys(Keys.LEFT, Keys.DOWN, Keys.DOWN, Keys.ENTER); - Assert.assertEquals("3. MenuItem Edit/Cut selected", getLogRow(0)); + assertEquals("3. MenuItem Edit/Cut selected", getLogRow(0)); openMenu("Edit"); getMenuBar().sendKeys(Keys.ENTER); - Assert.assertEquals("3. MenuItem Edit/Cut selected", getLogRow(0)); + assertEquals("3. MenuItem Edit/Cut selected", getLogRow(0)); getMenuBar().sendKeys(Keys.ENTER); - Assert.assertEquals("4. MenuItem Edit/Copy selected", getLogRow(0)); + assertEquals("4. MenuItem Edit/Copy selected", getLogRow(0)); /* Enter while menubar has focus but no selection should focus "File" */ getMenuBar().sendKeys(Keys.ENTER); - Assert.assertEquals("4. MenuItem Edit/Copy selected", getLogRow(0)); + assertEquals("4. MenuItem Edit/Copy selected", getLogRow(0)); /* Enter again should open File and focus Open */ getMenuBar().sendKeys(Keys.ENTER); - Assert.assertEquals("4. MenuItem Edit/Copy selected", getLogRow(0)); + assertEquals("4. MenuItem Edit/Copy selected", getLogRow(0)); getMenuBar().sendKeys(Keys.ENTER); - Assert.assertEquals("5. MenuItem File/Open selected", getLogRow(0)); + assertEquals("5. MenuItem File/Open selected", getLogRow(0)); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java index 98651b2759..a88fc47f6d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationMouseTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.menubar; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.MenuBarElement; @@ -18,13 +19,13 @@ public class MenuBarNavigationMouseTest extends MultiBrowserTest { openTestURL(); MenuBarElement menuBar = $(MenuBarElement.class).first(); menuBar.clickItem("File", "Export..", "As PDF..."); - Assert.assertEquals("1. MenuItem File/Export../As PDF... selected", + assertEquals("1. MenuItem File/Export../As PDF... selected", getLogRow(0)); menuBar.clickItem("Edit", "Copy"); - Assert.assertEquals("2. MenuItem Edit/Copy selected", getLogRow(0)); + assertEquals("2. MenuItem Edit/Copy selected", getLogRow(0)); menuBar.clickItem("Help"); - Assert.assertEquals("3. MenuItem Help selected", getLogRow(0)); + assertEquals("3. MenuItem Help selected", getLogRow(0)); menuBar.clickItem("File", "Exit"); - Assert.assertEquals("4. MenuItem File/Exit selected", getLogRow(0)); + assertEquals("4. MenuItem File/Exit selected", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java index 7ba79ed7ff..4de9b37c26 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.menubar; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -46,7 +47,7 @@ public class MenuBarSubmenusClosingValoTest extends MultiBrowserTest { menu.sendKeys(Keys.ARROW_RIGHT); int count = driver.findElements(By.className("v-menubar-popup")).size(); - Assert.assertTrue("The count of open popups should be one", count == 1); + assertTrue("The count of open popups should be one", count == 1); } @Test @@ -67,6 +68,6 @@ public class MenuBarSubmenusClosingValoTest extends MultiBrowserTest { waitForElementPresent(By.className("v-menubar-popup")); int count = driver.findElements(By.className("v-menubar-popup")).size(); - Assert.assertTrue("The count of open popups should be one", count == 1); + assertTrue("The count of open popups should be one", count == 1); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleRemovedTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleRemovedTest.java index 2487aa3863..e984558838 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleRemovedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuItemStyleRemovedTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.components.menubar; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -22,11 +23,11 @@ public class MenuItemStyleRemovedTest extends MultiBrowserTest { MenuBarElement menu = $(MenuBarElement.class).first(); List<WebElement> elements = menu .findElements(By.className("custom-menu-item")); - Assert.assertEquals(2, elements.size()); + assertEquals(2, elements.size()); menu.clickItem("first"); menu.clickItem("second"); elements = menu.findElements(By.className("custom-menu-item")); - Assert.assertEquals(2, elements.size()); + assertEquals(2, elements.size()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java index 0604840669..0caf786304 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.menubar; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -51,11 +52,11 @@ public class SpaceMenuBarNavigationTest extends MultiBrowserTest { found = true; } } - Assert.assertTrue("Sub menu is not opened on ENTER key", found); + assertTrue("Sub menu is not opened on ENTER key", found); menu.sendKeys(Keys.SPACE); - Assert.assertTrue("No result of action triggered by SPACE key", + assertTrue("No result of action triggered by SPACE key", isElementPresent(By.className("action-result"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonClickTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonClickTest.java index 80bba12f7e..2a49691c3e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonClickTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.nativebutton; -import org.junit.Assert; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -42,11 +43,11 @@ public class NativeButtonClickTest extends MultiBrowserTest { clickFirstButton(); String eventCoordinates = getFirstLabelValue(); - Assert.assertNotEquals("0,0", eventCoordinates); + assertNotEquals("0,0", eventCoordinates); clickSecondButton(); eventCoordinates = getSecondLabelValue(); - Assert.assertNotEquals("0,0", eventCoordinates); + assertNotEquals("0,0", eventCoordinates); } private void clickFirstButton() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java index af077f6d13..1aa516ef1f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java @@ -23,10 +23,10 @@ import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.N import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT_ICON; import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT_ICON_ALT; import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.UPDATED_ALTERNATE_TEXT; +import static org.junit.Assert.assertEquals; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -88,7 +88,7 @@ public class NativeButtonIconAndTextTest extends MultiBrowserTest { alt = ""; } - Assert.assertEquals(expected, alt); + assertEquals(expected, alt); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectCaptionGenerationTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectCaptionGenerationTest.java index 2e7accac48..a66dc87a06 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectCaptionGenerationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectCaptionGenerationTest.java @@ -1,19 +1,20 @@ package com.vaadin.tests.components.nativeselect; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.tests.tb3.SingleBrowserTest; public class NativeSelectCaptionGenerationTest extends SingleBrowserTest { - private static final String[] value = { "Foo", "Bar", "Baz", - "Spam", "Eggs" }; + private static final String[] value = { "Foo", "Bar", "Baz", "Spam", + "Eggs" }; @Test public void testDefaultDeclarativeCaptions() { @@ -21,7 +22,7 @@ public class NativeSelectCaptionGenerationTest extends SingleBrowserTest { List<TestBenchElement> options = $(NativeSelectElement.class).first() .getOptions(); for (int i = 0; i < options.size(); ++i) { - Assert.assertEquals("Captions don't match.", value[i], + assertEquals("Captions don't match.", value[i], options.get(i).getText()); } } @@ -33,7 +34,7 @@ public class NativeSelectCaptionGenerationTest extends SingleBrowserTest { List<TestBenchElement> options = $(NativeSelectElement.class).first() .getOptions(); for (int i = 0; i < options.size(); ++i) { - Assert.assertEquals("Captions don't match.", "Option " + (i + 1), + assertEquals("Captions don't match.", "Option " + (i + 1), options.get(i).getText()); } } @@ -45,7 +46,7 @@ public class NativeSelectCaptionGenerationTest extends SingleBrowserTest { List<TestBenchElement> options = $(NativeSelectElement.class).first() .getOptions(); for (int i = 0; i < options.size(); ++i) { - Assert.assertEquals("Captions don't match.", "" + (i + 1), + assertEquals("Captions don't match.", "" + (i + 1), options.get(i).getText()); } } @@ -58,7 +59,7 @@ public class NativeSelectCaptionGenerationTest extends SingleBrowserTest { List<TestBenchElement> options = $(NativeSelectElement.class).first() .getOptions(); for (int i = 0; i < options.size(); ++i) { - Assert.assertEquals("Captions don't match.", value[i], + assertEquals("Captions don't match.", value[i], options.get(i).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectEmptySelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectEmptySelectionTest.java index 102b504605..4578d261c2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectEmptySelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectEmptySelectionTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.components.nativeselect; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.TestBenchElement; @@ -60,12 +62,12 @@ public class NativeSelectEmptySelectionTest extends MultiBrowserTest { Set<String> options = select.getOptions().stream() .map(TestBenchElement::getText).collect(Collectors.toSet()); if (emptyCaption == null) { - Assert.assertEquals(49, options.size()); - Assert.assertTrue(options.containsAll(originalOptions)); + assertEquals(49, options.size()); + assertTrue(options.containsAll(originalOptions)); } else { options.contains(emptyCaption); - Assert.assertEquals(50, options.size()); - Assert.assertTrue(options.containsAll(originalOptions)); + assertEquals(50, options.size()); + assertTrue(options.containsAll(originalOptions)); } } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectFocusBlurTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectFocusBlurTest.java index f6bb38c6f4..5d9e3cc540 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectFocusBlurTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectFocusBlurTest.java @@ -15,15 +15,17 @@ */ package com.vaadin.tests.components.nativeselect; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -40,24 +42,24 @@ public class NativeSelectFocusBlurTest extends MultiBrowserTest { nativeSelect.click(); // Focus event is fired - Assert.assertTrue(logContainsText("1. Focus Event")); + assertTrue(logContainsText("1. Focus Event")); List<TestBenchElement> options = nativeSelect.getOptions(); options.get(1).click(); // No any new event - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // click on log label => blur $(LabelElement.class).first().click(); // blur event is fired - Assert.assertTrue(logContainsText("2. Blur Event")); + assertTrue(logContainsText("2. Blur Event")); nativeSelect.click(); // Focus event is fired - Assert.assertTrue(logContainsText("3. Focus Event")); + assertTrue(logContainsText("3. Focus Event")); nativeSelect.sendKeys(Keys.ARROW_UP, Keys.ENTER); // No any new event - Assert.assertFalse(logContainsText("4.")); + assertFalse(logContainsText("4.")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectInitTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectInitTest.java index 8fefd2af5d..4f48d7a1ce 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectInitTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectInitTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.nativeselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.NativeSelectElement; @@ -32,7 +33,7 @@ public class NativeSelectInitTest extends MultiBrowserTest { openTestURL(); String selected = $(NativeSelectElement.class).first().getValue(); - Assert.assertEquals("Bar", selected); + assertEquals("Bar", selected); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectStyleNamesTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectStyleNamesTest.java index 28defc1a58..344dbe9853 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectStyleNamesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectStyleNamesTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.tests.components.nativeselect; +import static org.junit.Assert.assertEquals; + import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.NativeSelectElement; @@ -38,7 +39,7 @@ public class NativeSelectStyleNamesTest extends SingleBrowserTest { Set<String> expected = Stream.of("v-select", "v-widget") .collect(Collectors.toSet()); - Assert.assertEquals(expected, + assertEquals(expected, $(NativeSelectElement.class).first().getClassNames()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java index 95af50e55d..da2c6a7629 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.nativeselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -30,9 +31,9 @@ public class NativeSelectVisibleItemCountTest extends SingleBrowserTest { openTestURL(); WebElement select = $(NativeSelectElement.class).first() .findElement(By.xpath("select")); - Assert.assertEquals("1", select.getAttribute("size")); + assertEquals("1", select.getAttribute("size")); selectMenuPath("Component", "Size", "Visible item count", "5"); - Assert.assertEquals("5", select.getAttribute("size")); + assertEquals("5", select.getAttribute("size")); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java index 759bd13185..3a95bda5ff 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.components.notification; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; @@ -42,22 +45,21 @@ public class MiddleNotificationPositionTest extends MultiBrowserTest { WebElement notification = driver .findElement(By.className("v-Notification")); - Assert.assertNotNull(notification); + assertNotNull(notification); String left = notification.getCssValue("left"); - Assert.assertEquals( - "Left position of notification element should be 0px", "0px", - left); + assertEquals("Left position of notification element should be 0px", + "0px", left); Point location = notification.getLocation(); - Assert.assertEquals("X coordinate of notifiation element should be 0", - 0, location.getX()); + assertEquals("X coordinate of notifiation element should be 0", 0, + location.getX()); WebElement body = driver.findElement(By.tagName("body")); int height = body.getSize().height; - Assert.assertTrue("Y coordinate of notification element is too small", + assertTrue("Y coordinate of notification element is too small", height / 2 - notification.getSize().height / 2 - 1 <= location .getY()); - Assert.assertTrue("Y coordinate of notification element is too big", + assertTrue("Y coordinate of notification element is too big", height / 2 + 1 >= location.getY()); } @@ -72,26 +74,25 @@ public class MiddleNotificationPositionTest extends MultiBrowserTest { WebElement notification = driver .findElement(By.className("v-Notification")); - Assert.assertNotNull(notification); + assertNotNull(notification); String right = notification.getCssValue("right"); - Assert.assertEquals( - "Right position of notification element should be 0px", "0px", - right); + assertEquals("Right position of notification element should be 0px", + "0px", right); WebElement body = driver.findElement(By.tagName("body")); int height = body.getSize().height; int width = body.getSize().width; Point location = notification.getLocation(); - Assert.assertTrue( + assertTrue( "Notification right border should be in the rightmost position", width - 1 <= location.getX() + notification.getSize().getWidth()); - Assert.assertTrue("Y coordinate of notification element is too small", + assertTrue("Y coordinate of notification element is too small", height / 2 - notification.getSize().height / 2 - 1 <= location .getY()); - Assert.assertTrue("Y coordinate of notification element is too big", + assertTrue("Y coordinate of notification element is too big", height / 2 + 1 >= location.getY()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java b/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java index 40bca3d6c3..e2cc28db7d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.notification; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -35,7 +36,7 @@ public class NotificationDelayTest extends MultiBrowserTest { public void testDelay() throws InterruptedException { openTestURL(); - Assert.assertTrue("No notification found", hasNotification()); + assertTrue("No notification found", hasNotification()); waitUntil(new ExpectedCondition<Boolean>() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java b/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java index 362dcaffcd..5d37a919b0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.notification; -import org.junit.Assert; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -67,18 +69,16 @@ public class NotificationsWaiAriaTest extends MultiBrowserTest { NotificationElement notification = $(NotificationElement.class).first(); String text = notification.getAttribute("role"); - Assert.assertTrue( - "Expected attribute 'role' to equal 'alert', found " + text, + assertTrue("Expected attribute 'role' to equal 'alert', found " + text, text.equals("alert")); text = getHiddenText(notification .findElements(By.className("v-assistive-device-only")).get(0)); - Assert.assertTrue("Expected 'Prefix:', found " + text, - text.equals("Prefix:")); + assertTrue("Expected 'Prefix:', found " + text, text.equals("Prefix:")); text = getHiddenText(notification .findElements(By.className("v-assistive-device-only")).get(1)); - Assert.assertTrue("Expected '- press ESC to close', found " + text, + assertTrue("Expected '- press ESC to close', found " + text, text.equals("- press ESC to close")); notification.close(); @@ -92,8 +92,7 @@ public class NotificationsWaiAriaTest extends MultiBrowserTest { notification = $(NotificationElement.class).first(); text = notification.getAttribute("role"); - Assert.assertTrue( - "Expected attribute 'role' to equal 'status', found " + text, + assertTrue("Expected attribute 'role' to equal 'status', found " + text, text.equals("status")); notification.close(); @@ -111,8 +110,7 @@ public class NotificationsWaiAriaTest extends MultiBrowserTest { } catch (Exception e) { element = null; } - Assert.assertNull( - "Notification shouldn't have assistive-device-only spans", + assertNull("Notification shouldn't have assistive-device-only spans", element); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/optiongroup/ReadOnlyOptionGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/optiongroup/ReadOnlyOptionGroupTest.java index 760f333936..d921cd1bbc 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/optiongroup/ReadOnlyOptionGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/optiongroup/ReadOnlyOptionGroupTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.optiongroup; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -40,7 +41,7 @@ public class ReadOnlyOptionGroupTest extends MultiBrowserTest { assertNoErrorNotifications(); - Assert.assertFalse( + assertFalse( "Radio button in option group is still disabled " + "after unset reaonly", isElementPresent(By.className("v-radiobutton-disabled"))); diff --git a/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java b/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java index d39ab871d4..4b69bbb1aa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.orderedlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Point; @@ -38,11 +39,11 @@ public class HorizontalLayoutFullsizeContentWithErrorMsgTest errorToggleButton.click(); - Assert.assertEquals(location, element.getLocation()); + assertEquals(location, element.getLocation()); errorToggleButton.click(); - Assert.assertEquals(location, element.getLocation()); + assertEquals(location, element.getLocation()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java b/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java index 3617c00c08..aed6d718ea 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.orderedlayout; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; @@ -42,8 +43,8 @@ public class VerticalLayoutFocusWithDOMChangesTest extends MultiBrowserTest { new Actions(getDriver()).moveToElement(tf2).click().build().perform(); WebElement activeElement = getFocusedElement(); - Assert.assertEquals("input", activeElement.getTagName()); - Assert.assertEquals("", activeElement.getAttribute("value")); + assertEquals("input", activeElement.getTagName()); + assertEquals("", activeElement.getAttribute("value")); tf1.sendKeys(incrementalText); new Actions(getDriver()) @@ -51,11 +52,10 @@ public class VerticalLayoutFocusWithDOMChangesTest extends MultiBrowserTest { getDriver().findElement(By.className("v-button"))) .click().build().perform(); activeElement = getFocusedElement(); - Assert.assertEquals("Just a button", activeElement.getText()); + assertEquals("Just a button", activeElement.getText()); DesiredCapabilities capabilities = getDesiredCapabilities(); - Assert.assertEquals(initialText + incrementalText, - tf1.getAttribute("value")); + assertEquals(initialText + incrementalText, tf1.getAttribute("value")); } @Test @@ -74,11 +74,11 @@ public class VerticalLayoutFocusWithDOMChangesTest extends MultiBrowserTest { new Actions(getDriver()).moveToElement(tf2).click().build().perform(); WebElement activeElement = getFocusedElement(); - Assert.assertEquals("input", activeElement.getTagName()); - Assert.assertEquals(firstText, activeElement.getAttribute("value")); + assertEquals("input", activeElement.getTagName()); + assertEquals(firstText, activeElement.getAttribute("value")); new Actions(getDriver()).sendKeys(secondText).build().perform(); DesiredCapabilities capabilities = getDesiredCapabilities(); - Assert.assertEquals(firstText + secondText, tf2.getAttribute("value")); + assertEquals(firstText + secondText, tf2.getAttribute("value")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/page/PageTitleTest.java b/uitest/src/test/java/com/vaadin/tests/components/page/PageTitleTest.java index 766f42a378..5c82e9a8a6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/page/PageTitleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/page/PageTitleTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.page; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -25,12 +26,12 @@ public class PageTitleTest extends MultiBrowserTest { @Test public void nullTitle() { driver.get(getTestUrl()); - Assert.assertEquals(PageTitle.class.getName(), driver.getTitle()); + assertEquals(PageTitle.class.getName(), driver.getTitle()); } @Test public void fooTitle() { driver.get(getTestUrl() + "?title=foo"); - Assert.assertEquals("foo", driver.getTitle()); + assertEquals("foo", driver.getTitle()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/panel/PanelChangeContentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/panel/PanelChangeContentsTest.java index 8b20a4d889..0730ebdb71 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/panel/PanelChangeContentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/panel/PanelChangeContentsTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.panel; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -27,24 +28,21 @@ public class PanelChangeContentsTest extends MultiBrowserTest { setPush(true); openTestURL(); - Assert.assertEquals("stats", - vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]") - .getText()); + assertEquals("stats", vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]") + .getText()); vaadinElement( "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]") .click(); - Assert.assertEquals("companies", - vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]") - .getText()); + assertEquals("companies", vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]") + .getText()); vaadinElement( "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]") .click(); - Assert.assertEquals("stats", - vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]") - .getText()); + assertEquals("stats", vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]") + .getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java index 80dbb26320..cf373f27d0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.popupview; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -35,7 +37,7 @@ public class PopupViewCaptionTest extends MultiBrowserTest { openTestURL(); WebElement caption = driver.findElement(By.className("v-caption")); - Assert.assertNotNull(caption); + assertNotNull(caption); List<WebElement> elements = caption.findElements(By.xpath("*")); @@ -46,7 +48,7 @@ public class PopupViewCaptionTest extends MultiBrowserTest { break; } } - Assert.assertTrue("Unable to find caption text", foundCaptionText); + assertTrue("Unable to find caption text", foundCaptionText); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java b/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java index 63a0d71caa..8e8e0244c6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.popupview; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -44,7 +45,7 @@ public class PopupViewShortcutActionHandlerTest extends MultiBrowserTest { .findElement(By.className("v-textfield")); textField.sendKeys("a", Keys.ENTER); - Assert.assertTrue( + assertTrue( "Unable to find label component which is the result of" + " shortcut action handling.", isElementPresent(By.className("shortcut-result"))); diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java index 67867eff11..71e4843814 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.radiobuttongroup; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.RadioButtonGroupElement; @@ -34,10 +35,10 @@ public class DisabledRadioButtonGroupTest extends MultiBrowserTest { openTestURL(); List<String> options = $(RadioButtonGroupElement.class).first() .getOptions(); - Assert.assertEquals(3, options.size()); - Assert.assertEquals("a", options.get(0)); - Assert.assertEquals("b", options.get(1)); - Assert.assertEquals("c", options.get(2)); + assertEquals(3, options.size()); + assertEquals("a", options.get(0)); + assertEquals("b", options.get(1)); + assertEquals("c", options.get(2)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupFocusBlurTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupFocusBlurTest.java index 8ee0932e88..d9ce2d649e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupFocusBlurTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupFocusBlurTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.radiobuttongroup; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -46,11 +48,11 @@ public class RadioButtonGroupFocusBlurTest extends MultiBrowserTest { radioButtonGroup.selectByText("1"); // Focus event is fired - Assert.assertTrue(logContainsText("1. Focus Event")); + assertTrue(logContainsText("1. Focus Event")); radioButtonGroup.selectByText("2"); // click on the second radio button doesn't fire anything - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // move the cursor to the middle of the first element, // offset to the middle of the two and perform click @@ -60,26 +62,26 @@ public class RadioButtonGroupFocusBlurTest extends MultiBrowserTest { - radioButtons.get(0).getLocation().y) / 2) .click().build().perform(); // no new events - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // click to label of a radio button radioButtonGroup.findElements(By.tagName("label")).get(2).click(); // no new events - Assert.assertFalse(logContainsText("2.")); + assertFalse(logContainsText("2.")); // click on log label => blur $(LabelElement.class).first().click(); // blur event is fired - Assert.assertTrue(logContainsText("2. Blur Event")); + assertTrue(logContainsText("2. Blur Event")); radioButtonGroup.selectByText("4"); // Focus event is fired - Assert.assertTrue(logContainsText("3. Focus Event")); + assertTrue(logContainsText("3. Focus Event")); // move keyboard focus to the next radio button radioButtons.get(3).sendKeys(Keys.ARROW_DOWN); // no new events - Assert.assertFalse(logContainsText("4.")); + assertFalse(logContainsText("4.")); // select the next radio button radioButtons.get(4).sendKeys(Keys.TAB); diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java index 5d7aa373f4..a10e858377 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.radiobuttongroup; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.GridLayoutElement; @@ -27,6 +28,6 @@ public class RadioButtonGroupInGridLayoutTest extends MultiBrowserTest { ok = (before == after + 4); } - Assert.assertTrue("GridLayout size changed when selecting a value", ok); + assertTrue("GridLayout size changed when selecting a value", ok); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java index 503d2d7692..81fd4904fd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java @@ -90,20 +90,20 @@ public class RadioButtonGroupTest extends MultiBrowserTest { selectMenuPath("Component", "Listeners", "Selection listener"); getSelect().selectByText("Item 4"); - Assert.assertEquals("1. Selected: Optional[Item 4]", getLogRow(0)); + assertEquals("1. Selected: Optional[Item 4]", getLogRow(0)); getSelect().selectByText("Item 2"); - Assert.assertEquals("2. Selected: Optional[Item 2]", getLogRow(0)); + assertEquals("2. Selected: Optional[Item 2]", getLogRow(0)); getSelect().selectByText("Item 4"); - Assert.assertEquals("3. Selected: Optional[Item 4]", getLogRow(0)); + assertEquals("3. Selected: Optional[Item 4]", getLogRow(0)); } @Test public void disabled_clickToSelect() { selectMenuPath("Component", "State", "Enabled"); - Assert.assertTrue(getSelect().findElements(By.tagName("input")).stream() + assertTrue(getSelect().findElements(By.tagName("input")).stream() .allMatch(element -> element.getAttribute("disabled") != null)); selectMenuPath("Component", "Listeners", "Selection listener"); @@ -111,13 +111,13 @@ public class RadioButtonGroupTest extends MultiBrowserTest { String lastLogRow = getLogRow(0); getSelect().selectByText("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); getSelect().selectByText("Item 2"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); getSelect().selectByText("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); } @Test @@ -132,7 +132,7 @@ public class RadioButtonGroupTest extends MultiBrowserTest { assertEquals(20, icons.size()); for (int i = 0; i < icons.size(); i++) { - Assert.assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), + assertEquals(VaadinIcons.values()[i + 1].getCodepoint(), icons.get(i).getText().charAt(0)); } } @@ -147,13 +147,13 @@ public class RadioButtonGroupTest extends MultiBrowserTest { selectMenuPath("Component", "State", "Enabled"); getSelect().selectByText("Item 5"); - Assert.assertEquals("3. Selected: Optional[Item 5]", getLogRow(0)); + assertEquals("3. Selected: Optional[Item 5]", getLogRow(0)); getSelect().selectByText("Item 2"); - Assert.assertEquals("4. Selected: Optional[Item 2]", getLogRow(0)); + assertEquals("4. Selected: Optional[Item 2]", getLogRow(0)); getSelect().selectByText("Item 4"); - Assert.assertEquals("5. Selected: Optional[Item 4]", getLogRow(0)); + assertEquals("5. Selected: Optional[Item 4]", getLogRow(0)); } @Test @@ -168,7 +168,7 @@ public class RadioButtonGroupTest extends MultiBrowserTest { selectMenuPath("Component", "Item Caption Generator", "Item Caption Generator", "Null Caption Generator"); for (String text : getSelect().getOptions()) { - Assert.assertEquals("", text); + assertEquals("", text); } } @@ -177,16 +177,16 @@ public class RadioButtonGroupTest extends MultiBrowserTest { selectMenuPath("Component", "Listeners", "Selection listener"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("2. Selected: Optional[Item 5]", getLogRow(0)); + assertEquals("2. Selected: Optional[Item 5]", getLogRow(0)); assertSelected("Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 1"); - Assert.assertEquals("4. Selected: Optional[Item 1]", getLogRow(0)); + assertEquals("4. Selected: Optional[Item 1]", getLogRow(0)); // DOM order assertSelected("Item 1"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("6. Selected: Optional[Item 5]", getLogRow(0)); + assertEquals("6. Selected: Optional[Item 5]", getLogRow(0)); assertSelected("Item 5"); } @@ -199,7 +199,7 @@ public class RadioButtonGroupTest extends MultiBrowserTest { label = (TestBenchElement) findElements(By.tagName("label")).get(5); label.showTooltip(); - Assert.assertEquals("Tooltip should contain the same text as caption", + assertEquals("Tooltip should contain the same text as caption", label.getText(), getTooltipElement().getText()); selectMenuPath("Component", "Item Description Generator", @@ -207,13 +207,13 @@ public class RadioButtonGroupTest extends MultiBrowserTest { label = (TestBenchElement) findElements(By.tagName("label")).get(5); label.showTooltip(); - Assert.assertEquals("Tooltip should contain caption + ' Description'", + assertEquals("Tooltip should contain caption + ' Description'", label.getText() + " Description", getTooltipElement().getText()); } private void assertSelected(String expectedSelection) { - Assert.assertEquals(expectedSelection, getSelect().getValue()); + assertEquals(expectedSelection, getSelect().getValue()); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java b/uitest/src/test/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java index edeeec96fc..f086031820 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.richtextarea; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.By; @@ -45,9 +47,9 @@ public class RichTextAreaRelativeHeightResizeTest extends MultiBrowserTest { // Check that the component height changed and that the editor height // changed equally as much - Assert.assertTrue("RichTextArea height didn't change", + assertTrue("RichTextArea height didn't change", newHeight != originalHeight); - Assert.assertEquals( + assertEquals( "Editor height change didn't match the Component height change", newHeight - originalHeight, newEditorHeight - originalEditorHeight); diff --git a/uitest/src/test/java/com/vaadin/tests/components/select/EnumSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/select/EnumSelectTest.java index 0e64b0c9f9..9a15ace088 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/select/EnumSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/select/EnumSelectTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.select; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.By; @@ -33,8 +34,8 @@ public class EnumSelectTest extends SingleBrowserTest { openTestURL(); NativeSelectElement ns = $(NativeSelectElement.class).first(); List<TestBenchElement> options = ns.getOptions(); - Assert.assertEquals("Some value", options.get(1).getText()); - Assert.assertEquals("Some other value", options.get(2).getText()); + assertEquals("Some value", options.get(1).getText()); + assertEquals("Some other value", options.get(2).getText()); } @Test @@ -43,8 +44,8 @@ public class EnumSelectTest extends SingleBrowserTest { ComboBoxElement cb = $(ComboBoxElement.class).first(); cb.openPopup(); List<String> options = cb.getPopupSuggestions(); - Assert.assertEquals("Some value", options.get(1)); - Assert.assertEquals("Some other value", options.get(2)); + assertEquals("Some value", options.get(1)); + assertEquals("Some other value", options.get(2)); } @Test @@ -53,9 +54,8 @@ public class EnumSelectTest extends SingleBrowserTest { ComboBoxElement cb = $(ComboBoxElement.class).first(); cb.findElement(By.vaadin("#textbox")).sendKeys(" other "); List<String> options = cb.getPopupSuggestions(); - Assert.assertEquals("Only one item should match filter", 1, - options.size()); - Assert.assertEquals("Invalid option matched filter", "Some other value", + assertEquals("Only one item should match filter", 1, options.size()); + assertEquals("Invalid option matched filter", "Some other value", options.get(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/select/SelectWithIntegersTest.java b/uitest/src/test/java/com/vaadin/tests/components/select/SelectWithIntegersTest.java index b2b9a3e153..b0f175258e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/select/SelectWithIntegersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/select/SelectWithIntegersTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.select; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ListSelectElement; @@ -31,7 +32,7 @@ public class SelectWithIntegersTest extends SingleBrowserTest { ListSelectElement toStringSelect = $(ListSelectElement.class) .caption("ID_TOSTRING").first(); - Assert.assertEquals("2,014", defaultSelect.getOptions().get(0)); - Assert.assertEquals("2014", toStringSelect.getOptions().get(0)); + assertEquals("2,014", defaultSelect.getOptions().get(0)); + assertEquals("2014", toStringSelect.getOptions().get(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java index 1e0363717d..7a983d3677 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.splitpanel; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; @@ -65,10 +66,10 @@ public class GridLayoutWithCheckboxTest extends MultiBrowserTest { cbSize = cb.getSize(); cbSlotSize = cbSlot.getSize(); } else { - Assert.assertEquals(tfSize, tf.getSize()); - Assert.assertEquals(tfSlotSize, tfSlot.getSize()); - Assert.assertEquals(cbSize, cb.getSize()); - Assert.assertEquals(cbSlotSize, cbSlot.getSize()); + assertEquals(tfSize, tf.getSize()); + assertEquals(tfSlotSize, tfSlot.getSize()); + assertEquals(cbSize, cb.getSize()); + assertEquals(cbSlotSize, cbSlot.getSize()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelHeightTest.java index 3ea404f104..c8398e3504 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/HorizontalSplitPanelHeightTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.splitpanel; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -60,13 +62,13 @@ public class HorizontalSplitPanelHeightTest extends MultiBrowserTest { private void testSplitPanel(String id) { WebElement splitPanel = findElement(By.id(id)); WebElement label = splitPanel.findElement(By.className("target")); - Assert.assertTrue( + assertTrue( id + ": split panel height (" + splitPanel.getSize().getHeight() + ") is less than " + "height of second component (" + label.getSize().getHeight() + ")", splitPanel.getSize().getHeight() >= label.getSize() .getHeight()); - Assert.assertEquals("Label text in the second panel is not visible", - "Label", label.getText()); + assertEquals("Label text in the second panel is not visible", "Label", + label.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java index 8fe71c4623..8ab9b8c8c5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.splitpanel; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -29,11 +30,11 @@ public class SplitPanelMoveComponentTest extends MultiBrowserTest { @Test public void moveComponent() { openTestURL(); - Assert.assertEquals(BUTTON_TEXT, getFirstChild().getText()); + assertEquals(BUTTON_TEXT, getFirstChild().getText()); getFirstChild().click(); - Assert.assertEquals(BUTTON_TEXT, getSecondChild().getText()); + assertEquals(BUTTON_TEXT, getSecondChild().getText()); getSecondChild().click(); - Assert.assertEquals(BUTTON_TEXT, getFirstChild().getText()); + assertEquals(BUTTON_TEXT, getFirstChild().getText()); } private WebElement getFirstChild() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPositionChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPositionChangeTest.java index c194ee69db..89fba2a13b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPositionChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/splitpanel/SplitPositionChangeTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.splitpanel; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -66,7 +68,7 @@ public class SplitPositionChangeTest extends MultiBrowserTest { } private void assertPosition(int original, int current) { - Assert.assertFalse("Position didn't change", original == current); + assertFalse("Position didn't change", original == current); } private void assertLogText(boolean horizontal) { @@ -74,7 +76,7 @@ public class SplitPositionChangeTest extends MultiBrowserTest { "1. Split position changed: %s, position: .*", horizontal ? "horizontal" : "vertical"); String actual = getLogRow(0); - Assert.assertTrue(String.format( + assertTrue(String.format( "Log content didn't match the expected format.\nexpected: '%s'\nwas: '%s'", expected, actual), actual.matches(expected)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java index 67d8d3bfb8..e01696a4b6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/AddSelectionToRemovedRangeTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.table; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.NoSuchElementException; @@ -61,7 +62,7 @@ public class AddSelectionToRemovedRangeTest extends MultiBrowserTest { driver.findElement(By.className("v-button")).click(); try { driver.findElement(By.vaadin("Root/VNotification[0]")); - Assert.fail("Notification is shown"); + fail("Notification is shown"); } catch (NoSuchElementException e) { // All is well. } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/AsyncPushUpdatesTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/AsyncPushUpdatesTest.java index 38beca87aa..96e2d0fe17 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/AsyncPushUpdatesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/AsyncPushUpdatesTest.java @@ -15,13 +15,14 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -40,7 +41,7 @@ public class AsyncPushUpdatesTest extends MultiBrowserTest { button.click(); $(TableElement.class).first().getCell(12, 0); - Assert.fail("Duplicates are present."); + fail("Duplicates are present."); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansionTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansionTest.java index d7d0b1c201..7e5c731442 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansionTest.java @@ -15,16 +15,17 @@ */ package com.vaadin.tests.components.table; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.TableElement.ContextMenuElement; import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -83,22 +84,22 @@ public class ColumnCollapsingAndColumnExpansionTest extends MultiBrowserTest { // Through menu table.openCollapseMenu().getItem(0).click(); - Assert.assertEquals("1. Collapse state for Col1 changed to true", + assertEquals("1. Collapse state for Col1 changed to true", getLogRow(0)); // Through button $(ButtonElement.class).caption("Collapse Col2").first().click(); - Assert.assertEquals("2. Collapse state for Col2 changed to true", + assertEquals("2. Collapse state for Col2 changed to true", getLogRow(0)); // Show through menu table.openCollapseMenu().getItem(1).click(); - Assert.assertEquals("3. Collapse state for Col1 changed to false", + assertEquals("3. Collapse state for Col1 changed to false", getLogRow(0)); // Show through button $(ButtonElement.class).caption("Show Col2").first().click(); - Assert.assertEquals("4. Collapse state for Col2 changed to false", + assertEquals("4. Collapse state for Col2 changed to false", getLogRow(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/ContainerSizeChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/ContainerSizeChangeTest.java index 0f8050d804..2937e487a4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/ContainerSizeChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/ContainerSizeChangeTest.java @@ -1,8 +1,8 @@ package com.vaadin.tests.components.table; -import static junit.framework.TestCase.fail; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; import java.io.IOException; @@ -10,8 +10,8 @@ import org.junit.Test; import org.openqa.selenium.NoSuchElementException; 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; public class ContainerSizeChangeTest extends MultiBrowserTest { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/DndTableTargetDetailsTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/DndTableTargetDetailsTest.java index 741d5d7b5b..ec099b0149 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/DndTableTargetDetailsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/DndTableTargetDetailsTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.table; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -41,7 +42,7 @@ public class DndTableTargetDetailsTest extends DndActionsTest { dragAndDrop(row, getTarget()); WebElement label = findElement(By.className("dnd-button-name")); - Assert.assertEquals("Button name=left", label.getText()); + assertEquals("Button name=left", label.getText()); } protected WebElement getTarget() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/EmptyTableTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/EmptyTableTest.java index 4be5c19985..2a9b79cd73 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/EmptyTableTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/EmptyTableTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import com.vaadin.testbench.elements.NotificationElement; @@ -33,7 +34,7 @@ public class EmptyTableTest extends MultiBrowserTest { private void ensureNoErrors() { if (isElementPresent(NotificationElement.class)) { - Assert.fail("Error notification was shown!"); + fail("Error notification was shown!"); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/FocusOnSelectedItemTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/FocusOnSelectedItemTest.java index c0588eb932..5ae5bc4697 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/FocusOnSelectedItemTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/FocusOnSelectedItemTest.java @@ -15,13 +15,14 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; 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; /** @@ -43,23 +44,22 @@ public class FocusOnSelectedItemTest extends MultiBrowserTest { WebElement selectedRow = null; WebElement focusedStyleRow = null; - Assert.assertTrue("No row was selected", + assertTrue("No row was selected", isElementPresent(By.className("v-selected"))); selectedRow = getDriver().findElement(By.className("v-selected")); supposedlyFocusedRow = $(TableElement.class).first().getCell(198, 0); - Assert.assertTrue("Incorrect row was selected", - selectedRow.getLocation().getY() == supposedlyFocusedRow - .getLocation().getY()); + assertTrue("Incorrect row was selected", selectedRow.getLocation() + .getY() == supposedlyFocusedRow.getLocation().getY()); - Assert.assertTrue("No row had the focused style.", + assertTrue("No row had the focused style.", isElementPresent(By.className("v-table-focus"))); focusedStyleRow = getDriver() .findElement(By.className("v-table-focus")); - Assert.assertTrue("Incorrect row has the focused style.", selectedRow + assertTrue("Incorrect row has the focused style.", selectedRow .getLocation().getY() == focusedStyleRow.getLocation().getY()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/LeftColumnAlignmentTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/LeftColumnAlignmentTest.java index b0da36c6fb..62af1daa39 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/LeftColumnAlignmentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/LeftColumnAlignmentTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -38,20 +40,19 @@ public class LeftColumnAlignmentTest extends MultiBrowserTest { WebElement webElement = driver.findElement(By.className("v-button")); webElement.click(); - Assert.assertTrue("Table caption is not aligned to the left", - isElementPresent( - By.className("v-table-caption-container-align-left"))); + assertTrue("Table caption is not aligned to the left", isElementPresent( + By.className("v-table-caption-container-align-left"))); WebElement footer = driver .findElement(By.className("v-table-footer-container")); - Assert.assertEquals("Table footer is not aligned to the left", "left", + assertEquals("Table footer is not aligned to the left", "left", footer.getCssValue("text-align")); WebElement cell = driver .findElement(By.className("v-table-cell-wrapper")); - Assert.assertEquals("Table cell is not aligned to the left", "left", + assertEquals("Table cell is not aligned to the left", "left", cell.getCssValue("text-align")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/OnlyCollapsibleInMenu.java b/uitest/src/test/java/com/vaadin/tests/components/table/OnlyCollapsibleInMenu.java index f87ee0102e..303e5e2e98 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/OnlyCollapsibleInMenu.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/OnlyCollapsibleInMenu.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TableElement; @@ -36,19 +37,19 @@ public class OnlyCollapsibleInMenu extends SingleBrowserTest { selectMenuPath("Component", "Columns", "Property 3", "Collapsible"); table.getCollapseMenuToggle().click(); - Assert.assertEquals("Property 3 should still be in the context menu", + assertEquals("Property 3 should still be in the context menu", "Property 3", table.getContextMenu().getItem(2).getText()); selectMenuPath("Component", "Features", "Collapsible menu content", CollapseMenuContent.COLLAPSIBLE_COLUMNS.toString()); table.getCollapseMenuToggle().click(); - Assert.assertEquals("Property 3 should not be in the context menu", + assertEquals("Property 3 should not be in the context menu", "Property 4", table.getContextMenu().getItem(2).getText()); selectMenuPath("Component", "Features", "Collapsible menu content", CollapseMenuContent.ALL_COLUMNS.toString()); table.getCollapseMenuToggle().click(); - Assert.assertEquals("Property 3 should again be in the context menu", + assertEquals("Property 3 should again be in the context menu", "Property 3", table.getContextMenu().getItem(2).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/ReloadWidgetsTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/ReloadWidgetsTest.java index e201b2ad96..49e356e3ce 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/ReloadWidgetsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/ReloadWidgetsTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.components.table; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -38,7 +39,7 @@ public class ReloadWidgetsTest extends MultiBrowserTest { waitForScrollToFinish(); // Assert that we have the button widget. - Assert.assertTrue( + assertTrue( "Button widget was not found after scrolling for the first time", !findElements(By.id("46")).isEmpty()); @@ -51,7 +52,7 @@ public class ReloadWidgetsTest extends MultiBrowserTest { waitForScrollToFinish(); // Assert that we still get the button - Assert.assertTrue( + assertTrue( "Button widget was not found after refreshing container items.", !findElements(By.id("46")).isEmpty()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java index 8b5b54cfaa..a161107f25 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/SelectableEditableTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.TableElement; @@ -12,7 +13,7 @@ public class SelectableEditableTest extends MultiBrowserTest { openTestURL(); TableElement table = $(TableElement.class).first(); table.getCell(0, 1).click(70, 12); - Assert.assertTrue("Element does not have the 'v-selected' css class", + assertTrue("Element does not have the 'v-selected' css class", hasCssClass(table.getRow(0), "v-selected")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java index 4926c653fa..681fe59e1c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java @@ -17,18 +17,17 @@ package com.vaadin.tests.components.table; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; import org.junit.Ignore; import org.junit.Test; import org.openqa.selenium.NoSuchElementException; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; -import junit.framework.Assert; - /** * * @since @@ -57,7 +56,7 @@ public class SetCurrentPageFirstItemIndexTest extends MultiBrowserTest { assertThat(cell.getText(), is(Integer.toString(index + 1))); } catch (NoSuchElementException e) { - Assert.fail(String.format("Can't locate row for index: %s", index)); + fail(String.format("Can't locate row for index: %s", index)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/SortableHeaderStylesTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/SortableHeaderStylesTest.java index 53d4cfb849..019dc20793 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/SortableHeaderStylesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/SortableHeaderStylesTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.OptionGroupElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.SingleBrowserTest; public class SortableHeaderStylesTest extends SingleBrowserTest { @@ -27,9 +29,9 @@ public class SortableHeaderStylesTest extends SingleBrowserTest { public void testSortableHeaderStyles() { openTestURL(); - Assert.assertFalse(hasSortableStyle(0)); + assertFalse(hasSortableStyle(0)); for (int i = 1; i < 8; i++) { - Assert.assertTrue(hasSortableStyle(i)); + assertTrue(hasSortableStyle(i)); } OptionGroupElement sortableSelector = $(OptionGroupElement.class) @@ -37,11 +39,11 @@ public class SortableHeaderStylesTest extends SingleBrowserTest { // Toggle sortability sortableSelector.selectByText("lastName"); - Assert.assertFalse(hasSortableStyle(3)); + assertFalse(hasSortableStyle(3)); // Toggle back sortableSelector.selectByText("lastName"); - Assert.assertTrue(hasSortableStyle(3)); + assertTrue(hasSortableStyle(3)); } private boolean hasSortableStyle(int column) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnWidthsAndSortingTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnWidthsAndSortingTest.java index ceff8c1d82..0a8d7434f3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnWidthsAndSortingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnWidthsAndSortingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TableElement; @@ -44,7 +45,7 @@ public class TableColumnWidthsAndSortingTest extends MultiBrowserTest { // Assert all headers are correct height (37px according to default // Valo) for (int i = 0; i < 5; i++) { - Assert.assertEquals("Height of header cell " + i + " is wrong", 37, + assertEquals("Height of header cell " + i + " is wrong", 37, t.getHeaderCell(0).getSize().getHeight()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableDragColumnTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableDragColumnTest.java index fe061ae3e0..320a25686f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableDragColumnTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableDragColumnTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; @@ -46,14 +48,14 @@ public class TableDragColumnTest extends MultiBrowserTest { new Actions(getDriver()).moveToElement(dragged).clickAndHold() .moveByOffset(-6, 0).perform(); - Assert.assertTrue("No drag element visible", + assertTrue("No drag element visible", isElementPresent(By.className("v-table-header-drag"))); WebElement dragImage = findElement(By.className("v-table-header-drag")); String cellContent = dragged.getText(); - Assert.assertEquals("Drag image had different content than header cell", + assertEquals("Drag image had different content than header cell", cellContent, dragImage.getText()); - Assert.assertEquals("Drag image had different icon", imgSrc, + assertEquals("Drag image had different icon", imgSrc, dragImage.findElement(By.tagName("img")).getAttribute("src")); TableHeaderElement target = table.getHeaderCell(3); @@ -62,9 +64,9 @@ public class TableDragColumnTest extends MultiBrowserTest { .perform(); dragged = table.getHeaderCell(3); - Assert.assertEquals("Column was not dropped where expected.", - cellContent, dragged.getText()); - Assert.assertEquals("Drag image had different icon", imgSrc, + assertEquals("Column was not dropped where expected.", cellContent, + dragged.getText()); + assertEquals("Drag image had different icon", imgSrc, dragged.findElement(By.tagName("img")).getAttribute("src")); } @@ -89,14 +91,14 @@ public class TableDragColumnTest extends MultiBrowserTest { new Actions(getDriver()).moveToElement(dragged).clickAndHold() .moveByOffset(-6, 0).perform(); - Assert.assertTrue("No drag element visible", + assertTrue("No drag element visible", isElementPresent(By.className("v-table-header-drag"))); WebElement dragImage = findElement(By.className("v-table-header-drag")); String cellContent = dragged.getText(); - Assert.assertEquals("Drag image had different content than header cell", + assertEquals("Drag image had different content than header cell", cellContent, dragImage.getText()); - Assert.assertTrue("Missing CSS class " + styleName, + assertTrue("Missing CSS class " + styleName, hasCssClass(dragImage, styleName)); new Actions(getDriver()).release().perform(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java index 3468060fa5..bb3c4b2a48 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableParentEnabledStateChangeTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.TableRowElement; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -34,19 +36,19 @@ public class TableParentEnabledStateChangeTest extends SingleBrowserTest { ButtonElement button = $(ButtonElement.class).first(); row.click(); - Assert.assertTrue(isSelected(row)); + assertTrue(isSelected(row)); // Disable button.click(); - Assert.assertTrue(isSelected(row)); + assertTrue(isSelected(row)); row.click(); // Should have no effect - Assert.assertTrue(isSelected(row)); + assertTrue(isSelected(row)); // Enable button.click(); - Assert.assertTrue(isSelected(row)); + assertTrue(isSelected(row)); row.click(); // Should deselect - Assert.assertFalse(isSelected(row)); + assertFalse(isSelected(row)); } private boolean isSelected(TableRowElement row) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableRequiredIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableRequiredIndicatorTest.java index 793b639e74..893e5d5da6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableRequiredIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableRequiredIndicatorTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -32,7 +33,7 @@ public class TableRequiredIndicatorTest extends MultiBrowserTest { @Test public void testRequiredIndicatorIsVisible() { openTestURL(); - Assert.assertTrue( + assertTrue( isElementPresent(By.className("v-required-field-indicator"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollAfterAddRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollAfterAddRowTest.java index a2a0ae0340..a74f53c0a2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollAfterAddRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollAfterAddRowTest.java @@ -16,8 +16,8 @@ package com.vaadin.tests.components.table; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -61,7 +61,7 @@ public class TableScrollAfterAddRowTest extends MultiBrowserTest { scrollUp(); addRow(); sleep(200); - Assert.assertNotEquals("86", getCurrentPageFirstItemIndex()); + assertNotEquals("86", getCurrentPageFirstItemIndex()); } private void scrollUp() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java index 5c5d2b1719..c0ae0945ab 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableScrollUpOnSelectTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -54,6 +55,6 @@ public class TableScrollUpOnSelectTest extends MultiBrowserTest { row.click(); int newRowLocation = row.getLocation().getY(); - Assert.assertTrue("Table has scrolled.", rowLocation == newRowLocation); + assertTrue("Table has scrolled.", rowLocation == newRowLocation); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java index 7fa430208f..5646ed96d3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java @@ -17,8 +17,8 @@ package com.vaadin.tests.components.table; import static com.vaadin.tests.components.table.TableSizeInTabsheet.TABLE; import static com.vaadin.tests.components.table.TableSizeInTabsheet.TABSHEET; +import static org.junit.Assert.assertEquals; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -35,7 +35,7 @@ public class TableSizeInTabsheetTest extends MultiBrowserTest { int tableHeight = getTableHeigth(); int tabSheetContentHeight = getTableSheetContentHeight(); - Assert.assertEquals(tableHeight, tabSheetContentHeight); + assertEquals(tableHeight, tabSheetContentHeight); } private int getTableHeigth() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableSortingIndicatorTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableSortingIndicatorTest.java index b3ab909d47..ca307c0189 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableSortingIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableSortingIndicatorTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -39,28 +41,28 @@ public class TableSortingIndicatorTest extends MultiBrowserTest { ButtonElement button = $(ButtonElement.class).caption("Sort").first(); TableElement table = $(TableElement.class).first(); - Assert.assertFalse("Descending indicator was prematurely visible", + assertFalse("Descending indicator was prematurely visible", getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); - Assert.assertFalse("Ascending indicator was prematurely visible", + assertFalse("Ascending indicator was prematurely visible", getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); button.click(); - Assert.assertTrue("Indicator did not become visible", + assertTrue("Indicator did not become visible", getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); - Assert.assertFalse("Ascending sort indicator was wrongly visible", + assertFalse("Ascending sort indicator was wrongly visible", getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); table.getHeaderCell(0).click(); - Assert.assertFalse("Table sort indicator didn't change", + assertFalse("Table sort indicator didn't change", getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); - Assert.assertTrue("Ascending sort indicator didn't become visible", + assertTrue("Ascending sort indicator didn't become visible", getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); button.click(); - Assert.assertTrue( + assertTrue( "Descending sort indicator didn't appear on the second serverside sort.", getHeaderClasses(table).contains(TABLE_HEADER_DESC_INDICATOR)); - Assert.assertFalse("Ascending sort indicator didn't disappear", + assertFalse("Ascending sort indicator didn't disappear", getHeaderClasses(table).contains(TABLE_HEADER_ASC_INDICATOR)); } 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 8c02ce11b3..48f8e782c6 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 @@ -15,12 +15,14 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.TableHeaderElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -44,11 +46,11 @@ public class TableToggleColumnVisibilityTest extends MultiBrowserTest { checkHeaderAttributes(1); toggleVisibilityButton.click(); // hide column #1 - Assert.assertEquals("One column should be visible", + assertEquals("One column should be visible", findElements(By.className("v-table-header-cell")).size(), 1); toggleVisibilityButton.click(); // restore column #1 - Assert.assertEquals("Two columns should be visible", + assertEquals("Two columns should be visible", findElements(By.className("v-table-header-cell")).size(), 2); checkHeaderAttributes(1); @@ -65,16 +67,15 @@ public class TableToggleColumnVisibilityTest extends MultiBrowserTest { TableHeaderElement headerCell = $(TableElement.class).first() .getHeaderCell(columnNumber); - Assert.assertTrue("Column header text should be custom", + assertTrue("Column header text should be custom", headerCell.getText().equalsIgnoreCase("Hello World")); - Assert.assertTrue("Column should have an icon", + assertTrue("Column should have an icon", headerCell.findElements(By.className("v-icon")).size() > 0); - Assert.assertTrue("Column should have alignment to the right", - headerCell - .findElements(By.className( - "v-table-caption-container-align-right")) - .size() > 0); + assertTrue("Column should have alignment to the right", headerCell + .findElements( + By.className("v-table-caption-container-align-right")) + .size() > 0); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityWidthTest.java index 511bce3b34..0c8f029e53 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableToggleColumnVisibilityWidthTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -40,17 +41,16 @@ public class TableToggleColumnVisibilityWidthTest extends MultiBrowserTest { ButtonElement toggleButton = $(ButtonElement.class).id("toggler"); toggleButton.click(); - Assert.assertEquals("One column should be visible", + assertEquals("One column should be visible", findElements(By.className("v-table-header-cell")).size(), 1); toggleButton.click(); - Assert.assertEquals("Two columns should be visible", + assertEquals("Two columns should be visible", findElements(By.className("v-table-header-cell")).size(), 2); int secondColumnWidthRestored = findElements( By.className("v-table-header-cell")).get(1).getSize() .getWidth(); - Assert.assertEquals( - "Column width should be the same as it was before hiding", + assertEquals("Column width should be the same as it was before hiding", secondColumnWidthInitial, secondColumnWidthRestored); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableWidthItemRemoveTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableWidthItemRemoveTest.java index d80e3496d9..2008982b25 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableWidthItemRemoveTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableWidthItemRemoveTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -39,7 +40,7 @@ public class TableWidthItemRemoveTest extends MultiBrowserTest { .findElement(By.vaadin("//Table[caption=\"My table\"]")); int original_width = table.getSize().getWidth(); populateButton.click(); - Assert.assertTrue("Width changed on item add.", + assertTrue("Width changed on item add.", original_width == table.getSize().getWidth()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableWithPollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableWithPollingTest.java index 091c9866ae..bf2d5ab435 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableWithPollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableWithPollingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -72,12 +73,12 @@ public class TableWithPollingTest extends MultiBrowserTest { private void assertHeaderCellWidth(int column, int width) throws AssertionError { - Assert.assertEquals(width, getHeaderCell(column).getSize().width); + assertEquals(width, getHeaderCell(column).getSize().width); } private void assertBodyCellWidth(int column, int width) throws AssertionError { - Assert.assertEquals(width, getBodyCell(column).getSize().width); + assertEquals(width, getBodyCell(column).getSize().width); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TextFieldValueGoesMissingTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TextFieldValueGoesMissingTest.java index d71d2a7845..09c9d01cda 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TextFieldValueGoesMissingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TextFieldValueGoesMissingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.interactions.Actions; @@ -48,6 +49,6 @@ public class TextFieldValueGoesMissingTest extends MultiBrowserTest { new Actions(getDriver()).contextClick(textfield).perform(); - Assert.assertEquals("test", textfield.getValue()); + assertEquals("test", textfield.getValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/UnnecessaryScrollbarWhenZoomingTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/UnnecessaryScrollbarWhenZoomingTest.java index 43328b2e99..27d8e8c300 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/UnnecessaryScrollbarWhenZoomingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/UnnecessaryScrollbarWhenZoomingTest.java @@ -17,11 +17,11 @@ package com.vaadin.tests.components.table; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import java.util.Arrays; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; @@ -92,7 +92,7 @@ public class UnnecessaryScrollbarWhenZoomingTest extends MultiBrowserTest { try { Thread.sleep(1000); } catch (InterruptedException e) { - Assert.fail(); + fail(); } WebElement element = findElement( By.cssSelector(".v-table-body-wrapper")); diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java index a22a777b5c..6f6f17be8c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.tabsheet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -37,7 +38,7 @@ public class EmptyTabSheetTest extends MultiBrowserTest { WebElement deco = getDriver() .findElement(By.className("v-tabsheet-deco")); - Assert.assertEquals("none", deco.getCssValue("display")); + assertEquals("none", deco.getCssValue("display")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheetTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheetTest.java index 6603d2474f..12ece12146 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheetTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleInTabsheetTest.java @@ -1,13 +1,13 @@ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.TabSheetElement; import com.vaadin.tests.tb3.MultiBrowserTest; -import junit.framework.Assert; - public class FirstTabNotVisibleInTabsheetTest extends MultiBrowserTest { @Test public void testFirstTabIsVisibleAfterBeingInvisible() { @@ -18,7 +18,7 @@ public class FirstTabNotVisibleInTabsheetTest extends MultiBrowserTest { TabSheetElement tabSheet = $(TabSheetElement.class).first(); - Assert.assertTrue("TabSheet should have first tab visible", + assertTrue("TabSheet should have first tab visible", tabSheet.getTabCaptions().contains("first visible tab")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClippedTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClippedTest.java index 48e47d5619..20504b79f9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClippedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/FirstTabNotVisibleWhenTabsheetNotClippedTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.tabsheet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -24,15 +25,13 @@ public class FirstTabNotVisibleWhenTabsheetNotClippedTest .findElement(By.className("v-tabsheet-tabitemcell-first")); String caption = firstTab.findElement(By.className("v-captiontext")) .getText(); - Assert.assertEquals("Tab with -first style should be Tab 1", "Tab 1", - caption); + assertEquals("Tab with -first style should be Tab 1", "Tab 1", caption); toggleNotClipped.click(); firstTab = notClippedTabSheet .findElement(By.className("v-tabsheet-tabitemcell-first")); caption = firstTab.findElement(By.className("v-captiontext")).getText(); - Assert.assertEquals("Tab with -first style should be Tab 0", "Tab 0", - caption); + assertEquals("Tab with -first style should be Tab 0", "Tab 0", caption); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java index 9505d8a7c8..0fdab188b2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/HtmlInTabCaptionTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.tabsheet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -34,8 +35,8 @@ public class HtmlInTabCaptionTest extends SingleBrowserTest { public void tabsheetWithoutHtmlCaptions() { openTestURL(); TabSheetElement ts = $(TabSheetElement.class).get(0); - Assert.assertEquals(PLAIN_TEXT_RED, getTab(ts, 0).getText()); - Assert.assertEquals(PLAIN_TEXT_BLUE, getTab(ts, 1).getText()); + assertEquals(PLAIN_TEXT_RED, getTab(ts, 0).getText()); + assertEquals(PLAIN_TEXT_BLUE, getTab(ts, 1).getText()); } private WebElement getTab(TabSheetElement tabSheetElement, int i) { @@ -50,16 +51,16 @@ public class HtmlInTabCaptionTest extends SingleBrowserTest { public void tabsheetWithHtmlCaptions() { openTestURL(); TabSheetElement ts = $(TabSheetElement.class).get(1); - Assert.assertEquals(HTML_TEXT_RED, getTab(ts, 0).getText()); - Assert.assertEquals(HTML_TEXT_BLUE, getTab(ts, 1).getText()); + assertEquals(HTML_TEXT_RED, getTab(ts, 0).getText()); + assertEquals(HTML_TEXT_BLUE, getTab(ts, 1).getText()); } @Test public void accordionWithoutHtmlCaptions() { openTestURL(); AccordionElement acc = $(AccordionElement.class).get(0); - Assert.assertEquals(PLAIN_TEXT_RED, getTab(acc, 0).getText()); - Assert.assertEquals(PLAIN_TEXT_BLUE, getTab(acc, 1).getText()); + assertEquals(PLAIN_TEXT_RED, getTab(acc, 0).getText()); + assertEquals(PLAIN_TEXT_BLUE, getTab(acc, 1).getText()); } @@ -67,7 +68,7 @@ public class HtmlInTabCaptionTest extends SingleBrowserTest { public void accordionWithHtmlCaptions() { openTestURL(); AccordionElement acc = $(AccordionElement.class).get(1); - Assert.assertEquals(HTML_TEXT_RED, getTab(acc, 0).getText()); - Assert.assertEquals(HTML_TEXT_BLUE, getTab(acc, 1).getText()); + assertEquals(HTML_TEXT_RED, getTab(acc, 0).getText()); + assertEquals(HTML_TEXT_BLUE, getTab(acc, 1).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java index 773749098e..2757f60694 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/NewSelectionAfterTabRemoveTest.java @@ -15,10 +15,11 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -44,11 +45,11 @@ public class NewSelectionAfterTabRemoveTest extends MultiBrowserTest { selectAndClose(tab(19)); - Assert.assertTrue("Tab 18 selected", isTabSelected(tab(18))); + assertTrue("Tab 18 selected", isTabSelected(tab(18))); selectAndClose(tab(16)); - Assert.assertTrue("Tab 17 selected", isTabSelected(tab(17))); + assertTrue("Tab 17 selected", isTabSelected(tab(17))); } /* diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java index b400ca8a28..1360c77373 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.tabsheet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; @@ -32,18 +34,16 @@ public class PreventTabChangeTest extends MultiBrowserTest { clickTab(2); Thread.sleep(2000); assertTabSelected(2); - Assert.assertEquals("Tab 3 contents", - getSelectedTabContent().getText()); + assertEquals("Tab 3 contents", getSelectedTabContent().getText()); clickTab(0); clickTab(2); assertTabSelected(0); - Assert.assertEquals("Tab 1 contents", - getSelectedTabContent().getText()); + assertEquals("Tab 1 contents", getSelectedTabContent().getText()); } private void assertTabSelected(int i) throws NoSuchElementException { WebElement tabItem = findTab(i).findElement(By.xpath("..")); - Assert.assertTrue("Tab " + i + " should be selected but isn't", tabItem + assertTrue("Tab " + i + " should be selected but isn't", tabItem .getAttribute("class").contains("v-tabsheet-tabitem-selected")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java index 98604c2a6f..39b5bf07de 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -166,7 +167,7 @@ public class TabKeyboardNavigationTest extends MultiBrowserTest { waitForElementPresent(id); - Assert.assertEquals(labelCaption, labelCaption, labelElement.getText()); + assertEquals(labelCaption, labelCaption, labelElement.getText()); } /* @@ -179,7 +180,7 @@ public class TabKeyboardNavigationTest extends MultiBrowserTest { .findElements(by).get(index - 1); String expected = "Tab " + index; - Assert.assertEquals(expected, + assertEquals(expected, element.getText().substring(0, expected.length())); return element; diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServerTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServerTest.java index a36faf0c27..858b2d63e6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSelectionRevertedByServerTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; @@ -57,14 +59,14 @@ public class TabSelectionRevertedByServerTest extends MultiBrowserTest { TestBenchElement tabExpected = tab(expectedIndex); String attributeClassExpected = tabExpected.getAttribute("class"); - Assert.assertTrue("Tab " + expectedIndex + " should be selected.", + assertTrue("Tab " + expectedIndex + " should be selected.", attributeClassExpected .contains("v-tabsheet-tabitemcell-selected")); TestBenchElement tabWrong = tab(wrongIndex); String attributeClassWrong = tabWrong.getAttribute("class"); - Assert.assertTrue( + assertTrue( "Tab " + wrongIndex + " should be selected when click on Tab 4", !attributeClassWrong .contains("v-tabsheet-tabitemcell-selected")); @@ -103,7 +105,7 @@ public class TabSelectionRevertedByServerTest extends MultiBrowserTest { .findElements(by).get(index - 1); String expected = "Tab " + index; - Assert.assertEquals(expected, + assertEquals(expected, element.getText().substring(0, expected.length())); return element; diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java index 31011b8837..17afe16a98 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java @@ -16,11 +16,11 @@ package com.vaadin.tests.components.tabsheet; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -89,10 +89,10 @@ public class TabSheetErrorTooltipTest extends MultiBrowserTest { } private void assertTooltip(String tooltip) { - Assert.assertEquals(tooltip, getCurrentTooltip().getText()); + assertEquals(tooltip, getCurrentTooltip().getText()); } private void assertErrorMessage(String message) { - Assert.assertEquals(message, getCurrentErrorMessage().getText()); + assertEquals(message, getCurrentErrorMessage().getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParentTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParentTest.java index 0fe431243e..d1226769ad 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSheetInDisabledParentTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -43,7 +45,7 @@ public class TabSheetInDisabledParentTest extends MultiBrowserTest { .findElements(By.className("v-tabsheet-tabitemcell")); tabHeaders.get(1).findElement(By.className("v-captiontext")).click(); - Assert.assertFalse( + assertFalse( "It's possible to activate TabSheet tab when its parent is disabled", tabHeaders.get(1).getAttribute("class") .contains("v-tabsheet-tabitemcell-selected")); @@ -54,15 +56,14 @@ public class TabSheetInDisabledParentTest extends MultiBrowserTest { // selected tab is still the same tabHeaders = getDriver() .findElements(By.className("v-tabsheet-tabitemcell")); - Assert.assertTrue( - "Tabsheet has wrong selected tab after enabling its parent", + assertTrue("Tabsheet has wrong selected tab after enabling its parent", tabHeaders.get(0).getAttribute("class") .contains("v-tabsheet-tabitemcell-selected")); // click to the second tab tabHeaders.get(1).findElement(By.className("v-captiontext")).click(); // check the second tab is selected - Assert.assertTrue( + assertTrue( "Second tab is not activated in the Tabsheet after clicking on it", tabHeaders.get(1).getAttribute("class") .contains("v-tabsheet-tabitemcell-selected")); diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java index 4db099fded..d8566057c0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertEquals; + import java.io.IOException; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -48,7 +49,7 @@ public class TabSpaceNotScrollTest extends MultiBrowserTest { Point newLocation = tab.getLocation(); - Assert.assertEquals(oldLocation, newLocation); + assertEquals(oldLocation, newLocation); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java index 074d952889..83ac4dfae3 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollIntoViewTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -46,12 +47,12 @@ public class TabsheetScrollIntoViewTest extends MultiBrowserTest { $(ButtonElement.class).id(TabsheetScrollIntoView.BTN_SELECT_LAST_TAB) .click(); TabSheetElement tabSheet = $(TabSheetElement.class).first(); - Assert.assertTrue("Select last should not hide other tabs", + assertTrue("Select last should not hide other tabs", tabSheet.getTabCaptions().contains("Tab 98")); List<WebElement> scrollerPrev = tabSheet .findElements(By.className("v-tabsheet-scrollerPrev")); - Assert.assertTrue("Select last should not disable tab scrolling", + assertTrue("Select last should not disable tab scrolling", !scrollerPrev.isEmpty() && scrollerPrev.get(0).isDisplayed()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java index db47d0bb4b..67f29a1a25 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.tabsheet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.Point; @@ -37,7 +39,7 @@ public class TabsheetScrollingTest extends MultiBrowserTest { sendKey(Keys.ARROW_RIGHT); } sendKey(Keys.SPACE); - Assert.assertEquals("Hide this tab (21)", getHideButtonText()); + assertEquals("Hide this tab (21)", getHideButtonText()); } private WebElement getTab(int index) { @@ -56,8 +58,8 @@ public class TabsheetScrollingTest extends MultiBrowserTest { private WebElement getTabByCaption(TabSheetElement ts, String caption) { WebElement tabBar = ts.findElement(By.className("v-tabsheet-tabs")); - return tabBar.findElement(By - .xpath("./tbody/tr/td[./div/div/div[contains(., normalize-space('" + return tabBar.findElement(By.xpath( + "./tbody/tr/td[./div/div/div[contains(., normalize-space('" + caption + "'))]]")); } @@ -72,10 +74,10 @@ public class TabsheetScrollingTest extends MultiBrowserTest { openTestURL(); $(ButtonElement.class).id(TabsheetScrolling.SELECT_LAST).click(); TabSheetElement tabsheetFixed = $(TabSheetElement.class).first(); - Assert.assertTrue("Select last should scroll last tab into view", + assertTrue("Select last should scroll last tab into view", isTabVisible(tabsheetFixed, "Tab 99")); $(ButtonElement.class).id(TabsheetScrolling.SELECT_FIRST).click(); - Assert.assertTrue("Select first should scroll first tab into view", + assertTrue("Select first should scroll first tab into view", isTabVisible(tabsheetFixed, "Tab 1")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/VetoTabChangeTest.java b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/VetoTabChangeTest.java index 8721db1589..7bc3dde9fe 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tabsheet/VetoTabChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tabsheet/VetoTabChangeTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.tabsheet; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -28,16 +29,16 @@ public class VetoTabChangeTest extends SingleBrowserTest { openTestURL(); TabSheetElement tabSheet = $(TabSheetElement.class).first(); - Assert.assertEquals("Tab 1 should be there by default", "Tab 1", + assertEquals("Tab 1 should be there by default", "Tab 1", getTabContent(tabSheet)); tabSheet.openTab(1); - Assert.assertEquals("Tab should not have changed", "Tab 1", + assertEquals("Tab should not have changed", "Tab 1", getTabContent(tabSheet)); tabSheet.openTab(0); - Assert.assertEquals("Tab should still be there", "Tab 1", + assertEquals("Tab should still be there", "Tab 1", getTabContent(tabSheet)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaTextFieldCursorPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaTextFieldCursorPositionTest.java index 89065050dc..4d2e169d6d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaTextFieldCursorPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaTextFieldCursorPositionTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.components.textarea; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -30,15 +33,15 @@ public class TextAreaTextFieldCursorPositionTest extends SingleBrowserTest { openTestURL(); $(ButtonElement.class).id(TextAreaTextFieldCursorPosition.GET_POSITION) .click(); - Assert.assertEquals("2. TextField position: -1", getLogRow(0)); - Assert.assertEquals("1. TextArea position: -1", getLogRow(1)); + assertEquals("2. TextField position: -1", getLogRow(0)); + assertEquals("1. TextArea position: -1", getLogRow(1)); $(TextFieldElement.class).first().focus(); $(TextAreaElement.class).first().focus(); $(ButtonElement.class).id(TextAreaTextFieldCursorPosition.GET_POSITION) .click(); - Assert.assertTrue(getLogRow(0).startsWith("4. TextField position:")); - Assert.assertNotEquals("4. TextField position: -1", getLogRow(0)); - Assert.assertNotEquals("3. TextArea position: -1", getLogRow(1)); + assertTrue(getLogRow(0).startsWith("4. TextField position:")); + assertNotEquals("4. TextField position: -1", getLogRow(0)); + assertNotEquals("3. TextArea position: -1", getLogRow(1)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/EnumTextFieldTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/EnumTextFieldTest.java index b810de2e5f..4d77f3fc2e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/EnumTextFieldTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/EnumTextFieldTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Keys; @@ -28,20 +29,20 @@ public class EnumTextFieldTest extends SingleBrowserTest { openTestURL(); $(TextFieldElement.class).first().clear(); $(TextFieldElement.class).first().sendKeys("Value", Keys.TAB); - Assert.assertEquals("3. Value (valid)", getLogRow(0)); + assertEquals("3. Value (valid)", getLogRow(0)); $(TextFieldElement.class).first().clear(); $(TextFieldElement.class).first().sendKeys("VaLuE"); $(TextFieldElement.class).first().sendKeys(Keys.TAB); - Assert.assertEquals("5. Value (valid)", getLogRow(0)); + assertEquals("5. Value (valid)", getLogRow(0)); $(TextFieldElement.class).first().clear(); $(TextFieldElement.class).first().sendKeys("The last value"); $(TextFieldElement.class).first().sendKeys(Keys.TAB); - Assert.assertEquals("7. The last value (valid)", getLogRow(0)); + assertEquals("7. The last value (valid)", getLogRow(0)); $(TextFieldElement.class).first().clear(); - Assert.assertEquals("8. null (valid)", getLogRow(0)); + assertEquals("8. null (valid)", getLogRow(0)); } @@ -52,7 +53,7 @@ public class EnumTextFieldTest extends SingleBrowserTest { $(TextFieldElement.class).first().sendKeys("bar"); $(TextFieldElement.class).first().sendKeys(Keys.TAB); - Assert.assertEquals("3. bar (INVALID)", getLogRow(0)); + assertEquals("3. bar (INVALID)", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptGetTextTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptGetTextTest.java index 8cd1970a38..a5bedae670 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptGetTextTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptGetTextTest.java @@ -15,8 +15,9 @@ */ package com.vaadin.tests.components.textfield; +import static org.junit.Assert.assertEquals; + import org.apache.commons.lang.RandomStringUtils; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -48,7 +49,7 @@ public class InputPromptGetTextTest extends MultiBrowserTest { WebElement label = getDriver() .findElement(By.id(InputPromptGetText.LABEL2)); - Assert.assertEquals("Your input was:", label.getText().trim()); + assertEquals("Your input was:", label.getText().trim()); } private String getRandomString() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/RequiredTextFieldTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/RequiredTextFieldTest.java index cfef5a97d4..61e5592c79 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/RequiredTextFieldTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/RequiredTextFieldTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.components.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -35,12 +37,12 @@ public class RequiredTextFieldTest extends MultiBrowserTest { $(ButtonElement.class).first().click(); - Assert.assertTrue("Text field doesn't contain .v-required style", + assertTrue("Text field doesn't contain .v-required style", getStyles().contains("v-required")); $(ButtonElement.class).first().click(); - Assert.assertFalse( + assertFalse( "Text field contains .v-required style for non-required field", getStyles().contains("v-required")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/SelectionAndCursorPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/SelectionAndCursorPositionTest.java index 950c64c8b2..1350258ee5 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/SelectionAndCursorPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/SelectionAndCursorPositionTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.components.textfield; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -68,8 +69,7 @@ public class SelectionAndCursorPositionTest extends SingleBrowserTest { } private void assertSelection(int start, int length) { - Assert.assertEquals(new Selection(start, length), - getSelection(textField)); + assertEquals(new Selection(start, length), getSelection(textField)); } private WebElement getSelectAll() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java index 1d01c35409..dd39944af2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.TextAreaElement; @@ -16,13 +18,13 @@ public class TextChangeEventsTest extends SingleBrowserTest { TextAreaElement taDefault = $(TextAreaElement.class) .caption("Default text area").first(); taDefault.sendKeys("abc"); - Assert.assertEquals(getLogRow(0), + assertEquals(getLogRow(0), "1. Text change event for Default text area, text content currently:'abc' Cursor at index:3"); TextAreaElement taTimeout = $(TextAreaElement.class) .caption("Timeout 3s").first(); taTimeout.sendKeys("abc"); - Assert.assertEquals(getLogRow(0), + assertEquals(getLogRow(0), "2. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3"); } @@ -33,19 +35,19 @@ public class TextChangeEventsTest extends SingleBrowserTest { TextFieldElement tfDefault = $(TextFieldElement.class) .caption("Default").first(); tfDefault.sendKeys("abc"); - Assert.assertEquals(getLogRow(0), + assertEquals(getLogRow(0), "1. Text change event for Default, text content currently:'abc' Cursor at index:3"); TextFieldElement tfEager = $(TextFieldElement.class).caption("Eager") .first(); tfEager.sendKeys("abc"); - Assert.assertTrue(getLogRow(0).contains( + assertTrue(getLogRow(0).contains( "Text change event for Eager, text content currently:'abc' Cursor at index:3")); TextFieldElement tfTimeout = $(TextFieldElement.class) .caption("Timeout 3s").first(); tfTimeout.sendKeys("abc"); - Assert.assertTrue(getLogRow(0).contains( + assertTrue(getLogRow(0).contains( "Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeModeTest.java index fcc681bc0b..3054b68b6a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeModeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeModeTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Ignore; import org.junit.Test; import org.openqa.selenium.By; @@ -113,7 +114,7 @@ public class TextFieldsValueChangeModeTest extends MultiBrowserTest { if (tail != -1) { log = log.substring(0, tail); } - Assert.assertEquals(expected, log); + assertEquals(expected, log); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java index d7c25e60a5..3bcfac4462 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeBasicFeaturesTest.java @@ -1,10 +1,13 @@ package com.vaadin.tests.components.tree; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.util.Arrays; import java.util.function.Predicate; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -50,9 +53,9 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { public void tree_expand_and_collapse() { TreeElement tree = $(TreeElement.class).first(); tree.expand(0); - Assert.assertEquals("1 | 0", tree.getItem(1).getText()); + assertEquals("1 | 0", tree.getItem(1).getText()); tree.collapse(0); - Assert.assertEquals("0 | 1", tree.getItem(1).getText()); + assertEquals("0 | 1", tree.getItem(1).getText()); assertNoErrorNotifications(); } @@ -66,8 +69,8 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { @Test public void tree_expand_all_with_icons() throws IOException { selectMenuPath("Component", "Icons", "By Depth"); - Assert.assertTrue("Icon not present", $(TreeElement.class).first() - .getItem(0).isElementPresent(By.tagName("img"))); + assertTrue("Icon not present", $(TreeElement.class).first().getItem(0) + .isElementPresent(By.tagName("img"))); expandAll(); assertAllExpanded(true); assertNoErrorNotifications(); @@ -92,25 +95,24 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { int n = 0; for (int i = 0; i < 3; ++i) { item = tree.getItem(n++); - Assert.assertEquals("0 | " + i, item.getText()); + assertEquals("0 | " + i, item.getText()); - Assert.assertEquals("Unexpected icon state", shouldHaveIcon, + assertEquals("Unexpected icon state", shouldHaveIcon, THEME_RESOURCE.test(item)); for (int j = 0; j < 3; ++j) { item = tree.getItem(n++); - Assert.assertEquals( - (shouldHaveIcon ? "\ue92d" : "") + "1 | " + j, + assertEquals((shouldHaveIcon ? "\ue92d" : "") + "1 | " + j, item.getText()); - Assert.assertEquals("Unexpected icon state", shouldHaveIcon, + assertEquals("Unexpected icon state", shouldHaveIcon, VAADIN_ICON.test(item)); for (int k = 0; k < 3; ++k) { item = tree.getItem(n++); - Assert.assertEquals("2 | " + k, item.getText()); + assertEquals("2 | " + k, item.getText()); - Assert.assertEquals("Unexpected icon state", shouldHaveIcon, + assertEquals("Unexpected icon state", shouldHaveIcon, CLASS_RESOURCE.test(item)); } } @@ -125,19 +127,17 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { selectMenuPath("Component", "Captions", "Custom caption"); TreeElement tree = $(TreeElement.class).first(); - Assert.assertEquals("Id: /0/0\nDepth: 0, Index: 0", - tree.getItem(0).getText()); - Assert.assertEquals("Id: /0/1\nDepth: 0, Index: 1", - tree.getItem(1).getText()); + assertEquals("Id: /0/0\nDepth: 0, Index: 0", tree.getItem(0).getText()); + assertEquals("Id: /0/1\nDepth: 0, Index: 1", tree.getItem(1).getText()); tree.expand(0); - Assert.assertEquals("Id: /0/0/1/0\nDepth: 1, Index: 0", + assertEquals("Id: /0/0/1/0\nDepth: 1, Index: 0", tree.getItem(1).getText()); - Assert.assertEquals("Id: /0/0/1/1\nDepth: 1, Index: 1", + assertEquals("Id: /0/0/1/1\nDepth: 1, Index: 1", tree.getItem(2).getText()); tree.expand(1); - Assert.assertEquals("Id: /0/0/1/0/2/0\nDepth: 2, Index: 0", + assertEquals("Id: /0/0/1/0/2/0\nDepth: 2, Index: 0", tree.getItem(2).getText()); - Assert.assertEquals("Id: /0/0/1/0/2/1\nDepth: 2, Index: 1", + assertEquals("Id: /0/0/1/0/2/1\nDepth: 2, Index: 1", tree.getItem(3).getText()); assertNoErrorNotifications(); @@ -151,10 +151,9 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { selectMenuPath("Component", "Captions", "HTML caption"); TreeElement tree = $(TreeElement.class).first(); - Assert.assertEquals("Id: /0/0\nDepth: 0\nIndex: 0", - tree.getItem(0).getText()); + assertEquals("Id: /0/0\nDepth: 0\nIndex: 0", tree.getItem(0).getText()); - Assert.assertEquals("Expander element not aligned to top", + assertEquals("Expander element not aligned to top", tree.getExpandElement(0).getLocation().getY(), tree.getItem(0).getLocation().getY()); @@ -168,7 +167,7 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { selectMenuPath("Component", "ContentMode", "TEXT"); TreeElement tree = $(TreeElement.class).first(); - Assert.assertEquals("Id: /0/0<br/>Depth: 0<br/>Index: 0", + assertEquals("Id: /0/0<br/>Depth: 0<br/>Index: 0", tree.getItem(0).getText()); assertNoErrorNotifications(); @@ -178,24 +177,21 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { public void tree_item_click() { selectMenuPath("Component", "Item Click Listener"); $(TreeElement.class).first().getItem(1).click(); - Assert.assertTrue(logContainsText("ItemClick: 0 | 1")); + assertTrue(logContainsText("ItemClick: 0 | 1")); } @Test public void tree_style_generator() { selectMenuPath("Component", "Style Generator"); TreeElement tree = $(TreeElement.class).first(); - Assert.assertTrue("Style name not present", - tree.wrap(TreeGridElement.class).getRow(0).getAttribute("class") - .contains("level0")); + assertTrue("Style name not present", tree.wrap(TreeGridElement.class) + .getRow(0).getAttribute("class").contains("level0")); tree.expand(0); - Assert.assertTrue("Style name not present", - tree.wrap(TreeGridElement.class).getRow(1).getAttribute("class") - .contains("level1")); + assertTrue("Style name not present", tree.wrap(TreeGridElement.class) + .getRow(1).getAttribute("class").contains("level1")); tree.expand(1); - Assert.assertTrue("Style name not present", - tree.wrap(TreeGridElement.class).getRow(2).getAttribute("class") - .contains("level2")); + assertTrue("Style name not present", tree.wrap(TreeGridElement.class) + .getRow(2).getAttribute("class").contains("level2")); } @Test @@ -204,10 +200,10 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { TreeElement tree = $(TreeElement.class).first(); tree.expand(0); tree.expand(1); - Assert.assertEquals("2 | 0", tree.getItem(2).getText()); + assertEquals("2 | 0", tree.getItem(2).getText()); tree.collapse(1); - Assert.assertEquals("Tree should prevent collapsing all nodes.", - "2 | 0", tree.getItem(2).getText()); + assertEquals("Tree should prevent collapsing all nodes.", "2 | 0", + tree.getItem(2).getText()); } @Test @@ -216,17 +212,13 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { TreeElement tree = $(TreeElement.class).first(); tree.getItem(0).click(); TreeGridElement wrap = tree.wrap(TreeGridElement.class); - Assert.assertFalse( - "Tree MultiSelection shouldn't have selection column", + assertFalse("Tree MultiSelection shouldn't have selection column", wrap.getCell(0, 0).isElementPresent(By.tagName("input"))); - Assert.assertTrue("First row was not selected", - wrap.getRow(0).isSelected()); + assertTrue("First row was not selected", wrap.getRow(0).isSelected()); new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN, Keys.SPACE) .perform(); - Assert.assertTrue("First row was deselected", - wrap.getRow(0).isSelected()); - Assert.assertTrue("Second row was not selected", - wrap.getRow(1).isSelected()); + assertTrue("First row was deselected", wrap.getRow(0).isSelected()); + assertTrue("Second row was not selected", wrap.getRow(1).isSelected()); } @Test @@ -235,15 +227,12 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { TreeElement tree = $(TreeElement.class).first(); TreeGridElement wrap = tree.wrap(TreeGridElement.class); tree.getItem(0).click(); - Assert.assertTrue("First row was not selected", - wrap.getRow(0).isSelected()); + assertTrue("First row was not selected", wrap.getRow(0).isSelected()); tree.getItem(1).click(); - Assert.assertTrue("First row was deselected", - wrap.getRow(0).isSelected()); - Assert.assertTrue("Second row was not selected", - wrap.getRow(1).isSelected()); + assertTrue("First row was deselected", wrap.getRow(0).isSelected()); + assertTrue("Second row was not selected", wrap.getRow(1).isSelected()); tree.getItem(0).click(); - Assert.assertFalse("First row was not deselected", + assertFalse("First row was not deselected", wrap.getRow(0).isSelected()); } @@ -254,7 +243,7 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { Arrays.stream(TreeBasicFeatures.ROW_HEIGHTS).boxed() .map(String::valueOf).forEach(height -> { selectMenuPath("Component", "Row Height", height); - Assert.assertTrue(wrap.getCell(0, 0).getAttribute("style") + assertTrue(wrap.getCell(0, 0).getAttribute("style") .contains("height: " + height + "px;")); }); } @@ -264,6 +253,6 @@ public class TreeBasicFeaturesTest extends MultiBrowserTest { selectMenuPath("Component", "Descriptions", "String.valueOf"); $(TreeElement.class).first().getItem(0).showTooltip(); - Assert.assertEquals("", "0 | 0", getTooltipElement().getText()); + assertEquals("", "0 | 0", getTooltipElement().getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeOnBrowserResizeTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeOnBrowserResizeTest.java index 153f389850..5d7bd25626 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeOnBrowserResizeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeOnBrowserResizeTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.tree; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Dimension; @@ -18,7 +19,7 @@ public class TreeOnBrowserResizeTest extends MultiBrowserTest { getDriver().manage().window().setSize(new Dimension(600, 800)); - Assert.assertTrue("Tree size should decrease.", + assertTrue("Tree size should decrease.", originalWidth > $(TreeGridElement.class).first() .getTableWrapper().getSize().getWidth()); } @@ -33,7 +34,7 @@ public class TreeOnBrowserResizeTest extends MultiBrowserTest { getDriver().manage().window().setSize(new Dimension(800, 800)); - Assert.assertTrue("Tree size should increase.", + assertTrue("Tree size should increase.", originalWidth < $(TreeGridElement.class).first() .getTableWrapper().getSize().getWidth()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java index da353b545b..fd43d7ab8f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeWideContentTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.tree; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -16,9 +17,8 @@ public class TreeWideContentTest extends SingleBrowserTest { TreeGridElement tree = $(TreeElement.class).first() .wrap(TreeGridElement.class); - Assert.assertTrue("Row should be wider than tree", - tree.getTableWrapper().getSize().getWidth() < tree.getRow(0) - .getSize().getWidth()); + assertTrue("Row should be wider than tree", tree.getTableWrapper() + .getSize().getWidth() < tree.getRow(0).getSize().getWidth()); } @Test @@ -28,7 +28,7 @@ public class TreeWideContentTest extends SingleBrowserTest { TreeElement tree = $(TreeElement.class).first(); tree.collapse(0); TreeGridElement treeGrid = tree.wrap(TreeGridElement.class); - Assert.assertTrue("Row should be as wide as tree", + assertTrue("Row should be as wide as tree", treeGrid.getTableWrapper().getSize().getWidth() == treeGrid .getRow(0).getSize().getWidth()); } @@ -41,7 +41,7 @@ public class TreeWideContentTest extends SingleBrowserTest { TreeElement tree = $(TreeElement.class).first(); TreeGridElement treeGrid = tree.wrap(TreeGridElement.class); - Assert.assertTrue("Row should be as wide as tree", + assertTrue("Row should be as wide as tree", treeGrid.getTableWrapper().getSize().getWidth() == treeGrid .getRow(0).getSize().getWidth()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseDisabledTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseDisabledTest.java index dbb8e38b2a..896289c7c9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseDisabledTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseDisabledTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.treegrid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; @@ -79,7 +81,7 @@ public class TreeGridCollapseDisabledTest extends SingleBrowserTest { selectMenuPath("Component", "Features", "Collapse allowed", "depth 1 disabled"); - Assert.assertTrue("First row should still be expanded", + assertTrue("First row should still be expanded", grid.isRowExpanded(0, 0)); // Assert second row expands but does not collapse @@ -91,21 +93,20 @@ public class TreeGridCollapseDisabledTest extends SingleBrowserTest { } private void assertExpandRow(int row) { - Assert.assertFalse(grid.isRowExpanded(row, 0)); + assertFalse(grid.isRowExpanded(row, 0)); grid.expandWithClick(row); - Assert.assertTrue(grid.isRowExpanded(row, 0)); + assertTrue(grid.isRowExpanded(row, 0)); } private void assertCollapseRow(int row) { - Assert.assertTrue("Row not expanded", grid.isRowExpanded(row, 0)); + assertTrue("Row not expanded", grid.isRowExpanded(row, 0)); grid.collapseWithClick(row); - Assert.assertFalse("Row did not collapse", grid.isRowExpanded(row, 0)); + assertFalse("Row did not collapse", grid.isRowExpanded(row, 0)); } private void assertCollapseRowDisabled(int row) { - Assert.assertTrue("Row not expanded", grid.isRowExpanded(row, 0)); + assertTrue("Row not expanded", grid.isRowExpanded(row, 0)); grid.collapseWithClick(row); - Assert.assertTrue("Row should not collapse", - grid.isRowExpanded(row, 0)); + assertTrue("Row should not collapse", grid.isRowExpanded(row, 0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseToLastRowInCacheTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseToLastRowInCacheTest.java index f24fcc2e76..e053191d4e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseToLastRowInCacheTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseToLastRowInCacheTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.treegrid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -31,14 +32,14 @@ public class TreeGridCollapseToLastRowInCacheTest extends SingleBrowserTest { assertNoErrorNotifications(); - Assert.assertEquals("0 | 0", grid.getCell(0, 0).getText()); - Assert.assertEquals("1 | 0", grid.getCell(1, 0).getText()); - Assert.assertEquals("2 | 0", grid.getCell(2, 0).getText()); + assertEquals("0 | 0", grid.getCell(0, 0).getText()); + assertEquals("1 | 0", grid.getCell(1, 0).getText()); + assertEquals("2 | 0", grid.getCell(2, 0).getText()); grid.collapseWithClick(0); - Assert.assertEquals("0 | 0", grid.getCell(0, 0).getText()); - Assert.assertEquals("0 | 1", grid.getCell(1, 0).getText()); + assertEquals("0 | 0", grid.getCell(0, 0).getText()); + assertEquals("0 | 1", grid.getCell(1, 0).getText()); assertNoErrorNotifications(); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandDataRequestTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandDataRequestTest.java index 677a395e1c..947770920d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandDataRequestTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandDataRequestTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.treegrid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Before; import org.junit.Test; @@ -32,21 +33,20 @@ public class TreeGridExpandDataRequestTest extends SingleBrowserTest { @Test public void expand_node0_does_not_request_root_nodes() { grid.expandWithClick(0); - Assert.assertFalse("Log should not contain request for root nodes.", + assertFalse("Log should not contain request for root nodes.", logContainsText("Root node request: ")); } @Test public void expand_node0_after_node1_does_not_request_children_of_node1() { grid.expandWithClick(1); - Assert.assertFalse("Log should not contain request for root nodes.", + assertFalse("Log should not contain request for root nodes.", logContainsText("Root node request: ")); clearLog(); grid.expandWithClick(0); - Assert.assertFalse( - "Log should not contain request for children of '0 | 1'.", + assertFalse("Log should not contain request for children of '0 | 1'.", logContainsText("Children request: 0 | 1")); - Assert.assertFalse("Log should not contain request for root nodes.", + assertFalse("Log should not contain request for root nodes.", logContainsText("Root node request: ")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeTest.java index 1d99534719..ebf0aed6b1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridHugeTreeTest.java @@ -1,7 +1,8 @@ package com.vaadin.tests.components.treegrid; +import static org.junit.Assert.assertEquals; + import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -86,7 +87,7 @@ public class TreeGridHugeTreeTest extends SingleBrowserTest { String[] cellTexts) { int index = startRowIndex; for (String cellText : cellTexts) { - Assert.assertEquals(cellText, + assertEquals(cellText, grid.getRow(index).getCell(cellIndex).getText()); index++; } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridScrollingTest.java index b4bc65e1ce..90d69f3895 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridScrollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridScrollingTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.treegrid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TreeGridElement; @@ -16,8 +17,7 @@ public class TreeGridScrollingTest extends SingleBrowserTest { TreeGridElement grid = $(TreeGridElement.class).first(); - Assert.assertEquals(grid.getRowCount(), - TreeGridScrolling.DEFAULT_NODES); + assertEquals(grid.getRowCount(), TreeGridScrolling.DEFAULT_NODES); verifyRow(0, 0, 0); verifyRow(10, 0, 10); @@ -156,7 +156,7 @@ public class TreeGridScrollingTest extends SingleBrowserTest { private void verifyRow(int rowActualIndex, int depth, int levelIndex) { TreeGridElement grid = $(TreeGridElement.class).first(); - Assert.assertEquals("Invalid row at index " + rowActualIndex, + assertEquals("Invalid row at index " + rowActualIndex, depth + " | " + levelIndex, grid.getCell(rowActualIndex, 0).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridSelectTest.java index e167dc6ac5..f6c62ed1e2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridSelectTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.treegrid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.By; @@ -44,13 +46,13 @@ public class TreeGridSelectTest extends SingleBrowserTest { private void assertAllRowsSelected(TreeGridElement grid) { for (int i = 0; i < grid.getRowCount(); i++) { - Assert.assertTrue(grid.getRow(i).isSelected()); + assertTrue(grid.getRow(i).isSelected()); } } private void assertAllRowsDeselected(TreeGridElement grid) { for (int i = 0; i < grid.getRowCount(); i++) { - Assert.assertFalse(grid.getRow(i).isSelected()); + assertFalse(grid.getRow(i).isSelected()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java index ccce20ac9d..cbde7e172a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableRowHeaderModeTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.treetable; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.By; @@ -32,8 +33,7 @@ public class TreeTableRowHeaderModeTest extends MultiBrowserTest { public void testIconRowHeaderMode() { openTestURL(); - Assert.assertFalse( - "Unexpected row header for icons is found in TreeTable", + assertFalse("Unexpected row header for icons is found in TreeTable", isElementPresent( By.className("v-table-header-cell-rowheader"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java index cc819a2744..cba81126be 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java @@ -1,5 +1,6 @@ package com.vaadin.tests.components.twincolselect; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,7 +9,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -70,28 +70,27 @@ public class TwinColSelectTest extends MultiBrowserTest { selectMenuPath("Component", "Listeners", "Selection listener"); selectItems("Item 4"); - Assert.assertEquals("1. Selected: [Item 4]", getLogRow(0)); + assertEquals("1. Selected: [Item 4]", getLogRow(0)); assertSelected("Item 4"); // the previous item stays selected selectItems("Item 2"); // Selection order (most recently selected is last) - Assert.assertEquals("2. Selected: [Item 4, Item 2]", getLogRow(0)); + assertEquals("2. Selected: [Item 4, Item 2]", getLogRow(0)); assertSelected("Item 2", "Item 4"); deselectItems("Item 4"); - Assert.assertEquals("3. Selected: [Item 2]", getLogRow(0)); + assertEquals("3. Selected: [Item 2]", getLogRow(0)); assertSelected("Item 2"); selectItems("Item 10", "Item 0", "Item 9", "Item 4"); - Assert.assertEquals( - "4. Selected: [Item 2, Item 0, Item 4, Item 10, Item 9]", + assertEquals("4. Selected: [Item 2, Item 0, Item 4, Item 10, Item 9]", getLogRow(0)); assertSelected("Item 0", "Item 2", "Item 4", "Item 9", "Item 10"); deselectItems("Item 0", "Item 2", "Item 9"); - Assert.assertEquals("5. Selected: [Item 4, Item 10]", getLogRow(0)); + assertEquals("5. Selected: [Item 4, Item 10]", getLogRow(0)); assertSelected("Item 4", "Item 10"); } @@ -101,14 +100,14 @@ public class TwinColSelectTest extends MultiBrowserTest { List<WebElement> selects = getTwinColSelect() .findElements(By.tagName("select")); - Assert.assertEquals(2, selects.size()); - Assert.assertTrue(selects.stream() + assertEquals(2, selects.size()); + assertTrue(selects.stream() .allMatch(element -> element.getAttribute("disabled") != null)); List<WebElement> buttons = getTwinColSelect() .findElements(By.className("v-button")); - Assert.assertEquals(2, buttons.size()); - buttons.forEach(button -> Assert.assertEquals("v-button v-disabled", + assertEquals(2, buttons.size()); + buttons.forEach(button -> assertEquals("v-button v-disabled", button.getAttribute("className"))); selectMenuPath("Component", "Listeners", "Selection listener"); @@ -116,16 +115,16 @@ public class TwinColSelectTest extends MultiBrowserTest { String lastLogRow = getLogRow(0); selectItems("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); selectItems("Item 2"); // Selection order (most recently selected is last) - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); selectItems("Item 4"); - Assert.assertEquals(lastLogRow, getLogRow(0)); + assertEquals(lastLogRow, getLogRow(0)); assertNothingSelected(); } @@ -136,14 +135,14 @@ public class TwinColSelectTest extends MultiBrowserTest { List<WebElement> selects = getTwinColSelect() .findElements(By.tagName("select")); - Assert.assertEquals(2, selects.size()); - Assert.assertTrue(selects.stream() + assertEquals(2, selects.size()); + assertTrue(selects.stream() .allMatch(element -> element.getAttribute("disabled") != null)); List<WebElement> buttons = getTwinColSelect() .findElements(By.className("v-button")); - Assert.assertEquals(2, buttons.size()); - buttons.forEach(button -> Assert.assertEquals("v-button v-disabled", + assertEquals(2, buttons.size()); + buttons.forEach(button -> assertEquals("v-button v-disabled", button.getAttribute("className"))); selectItems("Item 4"); @@ -154,15 +153,15 @@ public class TwinColSelectTest extends MultiBrowserTest { assertElementNotPresent(By.className("v-disabled")); selectItems("Item 5"); - Assert.assertEquals("3. Selected: [Item 5]", getLogRow(0)); + assertEquals("3. Selected: [Item 5]", getLogRow(0)); assertSelected("Item 5"); selectItems("Item 2"); - Assert.assertEquals("4. Selected: [Item 5, Item 2]", getLogRow(0)); + assertEquals("4. Selected: [Item 5, Item 2]", getLogRow(0)); assertSelected("Item 2", "Item 5"); deselectItems("Item 5"); - Assert.assertEquals("5. Selected: [Item 2]", getLogRow(0)); + assertEquals("5. Selected: [Item 2]", getLogRow(0)); assertSelected("Item 2"); } @@ -178,7 +177,7 @@ public class TwinColSelectTest extends MultiBrowserTest { selectMenuPath("Component", "Item Generator", "Item Caption Generator", "Null Caption Generator"); for (String text : getTwinColSelect().getOptions()) { - Assert.assertEquals("", text); + assertEquals("", text); } } @@ -187,36 +186,35 @@ public class TwinColSelectTest extends MultiBrowserTest { selectMenuPath("Component", "Listeners", "Selection listener"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("2. Selected: [Item 5]", getLogRow(0)); + assertEquals("2. Selected: [Item 5]", getLogRow(0)); assertSelected("Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 1"); // Selection order (most recently selected is last) - Assert.assertEquals("4. Selected: [Item 5, Item 1]", getLogRow(0)); + assertEquals("4. Selected: [Item 5, Item 1]", getLogRow(0)); // DOM order assertSelected("Item 1", "Item 5"); selectMenuPath("Component", "Selection", "Toggle Item 5"); - Assert.assertEquals("6. Selected: [Item 1]", getLogRow(0)); + assertEquals("6. Selected: [Item 1]", getLogRow(0)); assertSelected("Item 1"); selectMenuPath("Component", "Selection", "Toggle items 0, 1, 5, 10, 25"); // currently non-existing items are added to selection! - Assert.assertEquals( - "8. Selected: [Item 1, Item 0, Item 5, Item 10, Item 25]", + assertEquals("8. Selected: [Item 1, Item 0, Item 5, Item 10, Item 25]", getLogRow(0)); assertSelected("Item 0", "Item 1", "Item 5", "Item 10"); } private void assertSelected(String... expectedSelection) { - Assert.assertEquals(Arrays.asList(expectedSelection), + assertEquals(Arrays.asList(expectedSelection), getTwinColSelect().getValues()); } private void assertNothingSelected() { - Assert.assertEquals(0, getTwinColSelect().getValues().size()); + assertEquals(0, getTwinColSelect().getValues().size()); } @Override @@ -284,7 +282,7 @@ public class TwinColSelectTest extends MultiBrowserTest { protected void assertOptionTexts(String... items) { List<String> optionTexts = getOptionsElement().getOptions().stream() .map(element -> element.getText()).collect(Collectors.toList()); - Assert.assertArrayEquals(items, optionTexts.toArray()); + assertArrayEquals(items, optionTexts.toArray()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportEmptyTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportEmptyTest.java index 08e2a248b3..09549d0dba 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportEmptyTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportEmptyTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.ui; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -45,7 +46,7 @@ public class DynamicViewportEmptyTest extends MultiBrowserTest { List<WebElement> viewportElements = findElements( By.cssSelector("meta[name=viewport]")); - Assert.assertTrue("There should be no viewport tags", + assertTrue("There should be no viewport tags", viewportElements.isEmpty()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportTest.java index 56f365702e..73a4837119 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/DynamicViewportTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -31,7 +32,7 @@ public class DynamicViewportTest extends SingleBrowserTest { WebElement viewportElement = findElement( By.cssSelector("meta[name=viewport]")); - Assert.assertTrue( + assertTrue( viewportElement.getAttribute("content").contains("PhantomJS")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/InitiallyEmptyFragmentTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/InitiallyEmptyFragmentTest.java index fc948ab3db..5d7e05ac85 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/InitiallyEmptyFragmentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/InitiallyEmptyFragmentTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -25,6 +26,6 @@ public class InitiallyEmptyFragmentTest extends MultiBrowserTest { } private void assertLogText(String expected) { - Assert.assertEquals("Unexpected log contents,", expected, getLogRow(0)); + assertEquals("Unexpected log contents,", expected, getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/InvalidViewportTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/InvalidViewportTest.java index b6f8d6762c..470c24e5b4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/InvalidViewportTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/InvalidViewportTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -30,7 +31,7 @@ public class InvalidViewportTest extends SingleBrowserTest { WebElement heading = findElement(By.tagName("h2")); - Assert.assertEquals("HTTP ERROR 500", heading.getText()); + assertEquals("HTTP ERROR 500", heading.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToStringTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToStringTest.java index 5470a8c229..d29f4f8759 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToStringTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/RpcInvocationHandlerToStringTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -20,8 +21,7 @@ public class RpcInvocationHandlerToStringTest extends MultiBrowserTest { $(ButtonElement.class) .caption("Exec " + method + " for an invocation proxy").first() .click(); - Assert.assertFalse( - method + " for invocation proxy caused a notification", + assertFalse(method + " for invocation proxy caused a notification", $(NotificationElement.class).exists()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/StaticViewportTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/StaticViewportTest.java index 5e4cd165fb..2828ad4d34 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/StaticViewportTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/StaticViewportTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -31,7 +32,6 @@ public class StaticViewportTest extends SingleBrowserTest { WebElement viewportElement = findElement( By.cssSelector("meta[name=viewport]")); - Assert.assertEquals("myViewport", - viewportElement.getAttribute("content")); + assertEquals("myViewport", viewportElement.getAttribute("content")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java index 2786e52849..ce26ab535d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationModifierKeysTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.ui; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -45,7 +46,7 @@ public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest { builder.perform(); // Should have triggered shortcut - Assert.assertEquals("1. Shift-Enter button pressed", getLogRow(0)); + assertEquals("1. Shift-Enter button pressed", getLogRow(0)); } @Test @@ -64,7 +65,7 @@ public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest { builder.perform(); // Should have triggered shortcut - Assert.assertEquals("1. Ctrl-Enter button pressed", getLogRow(0)); + assertEquals("1. Ctrl-Enter button pressed", getLogRow(0)); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessExceptionHandlingTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessExceptionHandlingTest.java index b49de55a56..8745f78e42 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessExceptionHandlingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessExceptionHandlingTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -33,7 +34,6 @@ public class UIAccessExceptionHandlingTest extends MultiBrowserTest { } private void assertLogText(int index, String expected) { - Assert.assertEquals("Unexpected log contents,", expected, - getLogRow(index)); + assertEquals("Unexpected log contents,", expected, getLogRow(index)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java index 14975c63f6..73dfc8f77e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.ui; +import static org.junit.Assert.assertTrue; + import java.util.Locale; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -35,13 +36,12 @@ public class UIAutoGeneratedStyleNameTest extends MultiBrowserTest { public void testUiStyleName() { openTestURL(); - Assert.assertTrue( - "UI div element doesn't contain autogenerated style name", + assertTrue("UI div element doesn't contain autogenerated style name", containsStyle(getDriver().findElement(By.className("v-app")), UIAutoGeneratedStyleName.class.getSimpleName() .toLowerCase(Locale.ENGLISH))); - Assert.assertTrue( + assertTrue( "Overlays div element doesn't contain autogenerated style name", containsStyle( getDriver().findElement( diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitBrowserDetailsTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitBrowserDetailsTest.java index 641ac6d82a..71d6871883 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitBrowserDetailsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitBrowserDetailsTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -37,7 +39,7 @@ public class UIInitBrowserDetailsTest extends MultiBrowserTest { private void compareRequestAndBrowserValue(String paramName, String browserName, String errorValue) { assertTextNotEquals(browserName, errorValue); - Assert.assertEquals( + assertEquals( String.format("Browser and request values differ in '%s',", browserName), getLabelText(paramName), getLabelText(browserName)); @@ -53,7 +55,7 @@ public class UIInitBrowserDetailsTest extends MultiBrowserTest { private void assertTextNotEquals(String id, String notExpected) { String actual = getLabelText(id); - Assert.assertNotEquals(String.format("Unexpected value for '%s'", id), + assertNotEquals(String.format("Unexpected value for '%s'", id), notExpected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitExceptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitExceptionTest.java index 064132d4c7..dea9a22d7f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitExceptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIInitExceptionTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -9,7 +10,7 @@ public class UIInitExceptionTest extends SingleBrowserTest { @Test public void testExceptionOnUIInit() throws Exception { openTestURL(); - Assert.assertTrue("Page does not contain the given text", + assertTrue("Page does not contain the given text", driver.getPageSource().contains("Catch me if you can")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIPollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIPollingTest.java index bfc856d1b1..11b343b3fa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIPollingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIPollingTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.TextFieldElement; @@ -14,12 +16,12 @@ public class UIPollingTest extends MultiBrowserTest { getTextField().setValue("500"); sleep(2000); /* Ensure polling has taken place */ - Assert.assertTrue("Page does not contain the given text", + assertTrue("Page does not contain the given text", driver.getPageSource().contains("2. 1000ms has passed")); getTextField().setValue("-1"); sleep(2000); /* Ensure polling has stopped */ - Assert.assertFalse("Page contains the given text", + assertFalse("Page contains the given text", driver.getPageSource().contains("20. 10000ms has passed")); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIRefreshTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIRefreshTest.java index 3d038a2a5a..adc7da1a0d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIRefreshTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIRefreshTest.java @@ -16,7 +16,9 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.By; @@ -27,10 +29,10 @@ public class UIRefreshTest extends MultiBrowserTest { @Test public void testUIRefresh() { openTestURL(); - Assert.assertFalse(reinitLabelExists()); + assertFalse(reinitLabelExists()); // Reload the page; UI.refresh should be invoked openTestURL(); - Assert.assertTrue(reinitLabelExists()); + assertTrue(reinitLabelExists()); } private boolean reinitLabelExists() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UITabIndexTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UITabIndexTest.java index 390907ee8a..c5c9dc1ace 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UITabIndexTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UITabIndexTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -22,7 +23,7 @@ public class UITabIndexTest extends MultiBrowserTest { } private void assertTabIndex(String expected) { - Assert.assertEquals("Unexpected tab index,", expected, + assertEquals("Unexpected tab index,", expected, $(UIElement.class).first().getAttribute("tabIndex")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIsInMultipleTabsTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIsInMultipleTabsTest.java index e703deb634..b053ef3880 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIsInMultipleTabsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIsInMultipleTabsTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.LabelElement; @@ -19,7 +20,7 @@ public class UIsInMultipleTabsTest extends MultiBrowserTest { } private void assertUI(int i) { - Assert.assertEquals("Unexpected UI found,", "This is UI number " + i, + assertEquals("Unexpected UI found,", "This is UI number " + i, $(LabelElement.class).first().getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java index f74c5fa396..794d8f9bc2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -29,7 +30,7 @@ public class UiDependenciesInHtmlTest extends SingleBrowserTest { String statusText = findElement(By.id("statusBox")).getText(); - Assert.assertEquals( + assertEquals( "Script loaded before vaadinBootstrap.js: true\nStyle tag before vaadin theme: true\nStyle tags in correct order: true", statusText); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java index 07362af46e..e65e2221b2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/VaadinFinderLocatorUISearchTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertNotNull; + import org.junit.Test; import com.vaadin.testbench.elements.UIElement; @@ -38,6 +39,6 @@ public class VaadinFinderLocatorUISearchTest extends MultiBrowserTest { public void getUIElementTest() { openTestURL(); UIElement ui = $(UIElement.class).first(); - Assert.assertNotNull("Couldn't find the UI Element on the page", ui); + assertNotNull("Couldn't find the UI Element on the page", ui); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java index 715025bf5e..1473918cdf 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.ui; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -40,10 +41,9 @@ public class WindowAndUIShortcutsTest extends SingleBrowserTest { window.$(TextFieldElement.class).first().sendKeys(Keys.ESCAPE); // Window should have been closed - Assert.assertTrue($(WindowElement.class).all().isEmpty()); + assertTrue($(WindowElement.class).all().isEmpty()); // "Close page" should not have been clicked - Assert.assertTrue( - $(ButtonElement.class).caption("Close page").exists()); + assertTrue($(ButtonElement.class).caption("Close page").exists()); } @Test @@ -56,8 +56,7 @@ public class WindowAndUIShortcutsTest extends SingleBrowserTest { By.className("v-window-modalitycurtain")); curtain.sendKeys(Keys.ESCAPE); // "Close page" should not have been clicked - Assert.assertTrue( - $(ButtonElement.class).caption("Close page").exists()); + assertTrue($(ButtonElement.class).caption("Close page").exists()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java index d3a4a39d05..5f17003090 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/TestFileUploadTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.tests.components.upload; +import static org.junit.Assert.assertEquals; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -24,7 +26,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -59,7 +60,7 @@ public class TestFileUploadTest extends MultiBrowserTest { md5(getTempFileContents())); String actual = getLogRow(0); - Assert.assertEquals("Upload log row does not match expected", expected, + assertEquals("Upload log row does not match expected", expected, actual); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadNoSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadNoSelectionTest.java index 3b7a208d27..35616e1ec7 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadNoSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadNoSelectionTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.upload; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -29,7 +30,7 @@ public class UploadNoSelectionTest extends MultiBrowserTest { openTestURL(); // empty content is populated by com.vaadin.tests.util.Log - Assert.assertEquals(" ", getLogRow(0)); + assertEquals(" ", getLogRow(0)); getSubmitButton().click(); @@ -50,7 +51,7 @@ public class UploadNoSelectionTest extends MultiBrowserTest { private void assertLogRow(int index, int expentedRowNo, String expectedValueWithoutRowNo) { - Assert.assertEquals(expentedRowNo + ". " + expectedValueWithoutRowNo, + assertEquals(expentedRowNo + ". " + expectedValueWithoutRowNo, getLogRow(index)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadTitleWithTooltipTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadTitleWithTooltipTest.java index 5e0582d6d8..e4c9078a13 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadTitleWithTooltipTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadTitleWithTooltipTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.upload; +import static org.junit.Assert.assertNotNull; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -43,8 +44,7 @@ public class UploadTitleWithTooltipTest extends TooltipTest { } } - Assert.assertNotNull("Input element with type 'file' is not found", - input); + assertNotNull("Input element with type 'file' is not found", input); checkTooltip(input, "tooltip"); diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/CloseModalSubWindowTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/CloseModalSubWindowTest.java index 44cb094975..9058b142b1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/CloseModalSubWindowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/CloseModalSubWindowTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.components.window; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -35,12 +36,12 @@ public class CloseModalSubWindowTest extends MultiBrowserTest { List<WebElement> buttons = getDriver() .findElements(By.id(CloseModalSubWindow.DELETE_BUTTON + "0")); int deleteButtonCount = buttons.size(); - Assert.assertEquals(1, deleteButtonCount); + assertEquals(1, deleteButtonCount); // assert that there's no sub-windows open List<WebElement> subWindows = getDriver() .findElements(By.id(CloseModalSubWindow.SUB_WINDOW)); - Assert.assertEquals(0, subWindows.size()); + assertEquals(0, subWindows.size()); // click the first delete button getFirstDeteleButton(0).click(); @@ -48,7 +49,7 @@ public class CloseModalSubWindowTest extends MultiBrowserTest { // assert that there's ONE sub-window open subWindows = getDriver() .findElements(By.id(CloseModalSubWindow.SUB_WINDOW)); - Assert.assertEquals(1, subWindows.size()); + assertEquals(1, subWindows.size()); WebElement confirm = getDriver() .findElement(By.id(CloseModalSubWindow.CONFIRM_BUTTON)); @@ -59,12 +60,12 @@ public class CloseModalSubWindowTest extends MultiBrowserTest { // assert that there's no sub-windows open subWindows = getDriver() .findElements(By.id(CloseModalSubWindow.SUB_WINDOW)); - Assert.assertEquals(0, subWindows.size()); + assertEquals(0, subWindows.size()); // assert that there's no button with 'del-btn0' id anymore buttons = getDriver() .findElements(By.id(CloseModalSubWindow.DELETE_BUTTON + "0")); - Assert.assertEquals(0, buttons.size()); + assertEquals(0, buttons.size()); } private WebElement getFirstDeteleButton(int index) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/CloseSubWindowTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/CloseSubWindowTest.java index 48ac923082..532b9ab419 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/CloseSubWindowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/CloseSubWindowTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -41,7 +42,7 @@ public class CloseSubWindowTest extends MultiBrowserTest { } private void assertLogText() { - Assert.assertEquals("Unexpected log contents,", + assertEquals("Unexpected log contents,", "1. Window 'Sub-window' closed", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/ExtraWindowShownTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/ExtraWindowShownTest.java index abbc7ddac0..88f5215514 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/ExtraWindowShownTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/ExtraWindowShownTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -31,7 +32,7 @@ public class ExtraWindowShownTest extends MultiBrowserTest { } private void assertNoWindow() { - Assert.assertFalse("Window found when there should be none.", + assertFalse("Window found when there should be none.", $(WindowElement.class).exists()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/MaximizeRestoreWindowWithManagedLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/MaximizeRestoreWindowWithManagedLayoutTest.java index a3a43b218b..bb402cd91a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/MaximizeRestoreWindowWithManagedLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/MaximizeRestoreWindowWithManagedLayoutTest.java @@ -15,12 +15,13 @@ */ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Dimension; -import com.vaadin.testbench.elements.WindowElement; import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.elements.WindowElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class MaximizeRestoreWindowWithManagedLayoutTest @@ -54,6 +55,6 @@ public class MaximizeRestoreWindowWithManagedLayoutTest private void assertSameWidth(WindowElement window, TextFieldElement field) { Dimension windowSize = window.getSize(); Dimension fieldSize = field.getSize(); - Assert.assertEquals(windowSize.getWidth(), fieldSize.getWidth()); + assertEquals(windowSize.getWidth(), fieldSize.getWidth()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/RepaintWindowContentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/RepaintWindowContentsTest.java index d097aa183c..2fa30b36f2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/RepaintWindowContentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/RepaintWindowContentsTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -26,7 +27,7 @@ public class RepaintWindowContentsTest extends MultiBrowserTest { } private void assertWindowContents(String expected) { - Assert.assertEquals("Unexpected window contents,", expected, + assertEquals("Unexpected window contents,", expected, getWindowButton().getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java index 26041d8531..da4ea7b6a4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.Keys; @@ -29,6 +30,6 @@ public class ShortcutInWindowTest extends SingleBrowserTest { openTestURL(); TextFieldElement tf = $(TextFieldElement.class).first(); tf.sendKeys("foo" + Keys.ENTER); - Assert.assertEquals("2. Submitted value: foo", getLogRow(0)); + assertEquals("2. Submitted value: foo", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java index dae3267d70..04ed75cb39 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.components.window; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -71,12 +73,12 @@ public class SubWindowsTextSelectionTest extends MultiBrowserTest { .executeScript("return document.getSelection().toString();") .toString(); - Assert.assertTrue("Text selection was not empty:" + selection, + assertTrue("Text selection was not empty:" + selection, selection.isEmpty()); // Verify also that window was really moved Point location2 = element.getLocation(); - Assert.assertEquals(location.getX() + (4 * 10), location2.getX()); + assertEquals(location.getX() + (4 * 10), location2.getX()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowCaptionTest.java index 9807790330..8e960f7c2d 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowCaptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowCaptionTest.java @@ -15,14 +15,15 @@ */ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.testbench.elements.WindowElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.WindowElement; import com.vaadin.tests.tb3.SingleBrowserTest; public class WindowCaptionTest extends SingleBrowserTest { @@ -41,9 +42,9 @@ public class WindowCaptionTest extends SingleBrowserTest { @Test public void htmlCaption() { - Assert.assertEquals("HtmlWindow's caption didn't match,", + assertEquals("HtmlWindow's caption didn't match,", "This may or may not be red", htmlWindow.getCaption()); - Assert.assertEquals("TextWindow's caption didn't match,", + assertEquals("TextWindow's caption didn't match,", "<font style='color: red;'>This may or may not be red</font>", textWindow.getCaption()); } @@ -86,7 +87,7 @@ public class WindowCaptionTest extends SingleBrowserTest { }); - Assert.assertEquals("TextWindow's caption didn't match,", - expectedCaption, textWindow.getCaption()); + assertEquals("TextWindow's caption didn't match,", expectedCaption, + textWindow.getCaption()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java index c20207a6fd..089b6ed1f4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -37,7 +38,7 @@ public class WindowInUiWithNoContentTest extends MultiBrowserTest { WebElement window = driver.findElement(By.className("v-window")); String position = window.getCssValue("position"); - Assert.assertEquals("Window element has non-absolute position and " + assertEquals("Window element has non-absolute position and " + "is broken in the UI", "absolute", position); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowMaxHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowMaxHeightTest.java index 450d72dc91..74e8d8611e 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowMaxHeightTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowMaxHeightTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Dimension; @@ -29,8 +30,7 @@ public class WindowMaxHeightTest extends SingleBrowserTest { openTestURL(); WindowElement window = $(WindowElement.class).first(); Dimension size = window.getSize(); - Assert.assertTrue( - "Window should be 200-250px high, was " + size.getHeight(), + assertTrue("Window should be 200-250px high, was " + size.getHeight(), size.getHeight() < 250); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowOrderTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowOrderTest.java index 1ab131a920..0fafc6afe9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowOrderTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowOrderTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -46,25 +47,25 @@ public class WindowOrderTest extends MultiBrowserTest { // Bring the first window to front and check order positions of the // windows findElement(By.className("bring-to-front-first")).click(); - Assert.assertTrue( + assertTrue( "The first window has wrong order position after bring first to front", hasOrder("window1", 2)); - Assert.assertTrue( + assertTrue( "The first window position is incorrectly updated via UI listener after bring first to front", hasOrderInUi("window1", 2)); - Assert.assertTrue( + assertTrue( "The second window has wrong order position after bring first to front", hasOrder("window2", 0)); - Assert.assertTrue( + assertTrue( "The second window position is incorrectly updated via UI after bring first to front", hasOrderInUi("window2", 0)); - Assert.assertTrue( + assertTrue( "The third window has wrong order position after bring first to front", hasOrder("window3", 1)); - Assert.assertTrue( + assertTrue( "The third window position is incorrectly updated via UI after bring first to front", hasOrderInUi("window3", 1)); - Assert.assertTrue( + assertTrue( "Last window is not attached and should have '-1' position, but hasn't.", lastWindowHasOrder(-1)); } @@ -75,25 +76,25 @@ public class WindowOrderTest extends MultiBrowserTest { // windows findElement(By.className("bring-to-front-all")).click(); - Assert.assertTrue( + assertTrue( "The first window has wrong order position after bring all to front", hasOrder("window2", 2)); - Assert.assertTrue( + assertTrue( "The first window position is incorrectly updated via UI after bring all to front", hasOrderInUi("window2", 2)); - Assert.assertTrue( + assertTrue( "The second window has wrong order position after bring all to front", hasOrder("window1", 1)); - Assert.assertTrue( + assertTrue( "The second window position is incorrectly updated via UI after bring all to front", hasOrderInUi("window1", 1)); - Assert.assertTrue( + assertTrue( "The third window has wrong order position after bring all to front", hasOrder("window3", 0)); - Assert.assertTrue( + assertTrue( "The third window position is incorrectly updated via UI after bring all to front", hasOrderInUi("window3", 0)); - Assert.assertTrue( + assertTrue( "Last window is not attached and should have '-1' position, but hasn't.", lastWindowHasOrder(-1)); } @@ -103,25 +104,25 @@ public class WindowOrderTest extends MultiBrowserTest { // windows findElement(By.className("detach-window")).click(); - Assert.assertTrue( + assertTrue( "The first window has wrong order position after detach last window", hasOrder("window2", 1)); - Assert.assertTrue( + assertTrue( "The first window position is incorrectly updated after detach last window", hasOrderInUi("window2", 1)); - Assert.assertTrue( + assertTrue( "The second window has wrong order position after detach last window", hasOrder("window1", 0)); - Assert.assertTrue( + assertTrue( "The second window position is incorrectly updated after detach last window", hasOrderInUi("window1", 0)); WebElement thirdWindowInfo = findElement(By.className("w3-detached")); - Assert.assertTrue("The third window has wrong order after detach", + assertTrue("The third window has wrong order after detach", thirdWindowInfo.getAttribute("class").contains("w3--1")); - Assert.assertTrue( + assertTrue( "The third window position is incorrectly updated after detach last window", hasOrderInUi("window3", -1)); - Assert.assertTrue( + assertTrue( "Last window is not attached and should have '-1' position, but hasn't.", lastWindowHasOrder(-1)); } @@ -131,22 +132,22 @@ public class WindowOrderTest extends MultiBrowserTest { // windows findElement(By.className("add-window")).click(); - Assert.assertTrue( + assertTrue( "The first window has wrong order position after add new window", hasOrder("window2", 1)); - Assert.assertTrue( + assertTrue( "The first window position is incorrectly updated after add new window", hasOrderInUi("window2", 1)); - Assert.assertTrue( + assertTrue( "The second window has wrong order position after add new window", hasOrder("window1", 0)); - Assert.assertTrue( + assertTrue( "The second window position is incorrectly updated after add new window", hasOrderInUi("window1", 0)); - Assert.assertTrue( + assertTrue( "The last window has wrong order position after add new window", hasOrder("window4", 2)); - Assert.assertTrue( + assertTrue( "The last window position is incorrectly updated after add new window", hasOrderInUi("window4", 2)); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandlerTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandlerTest.java index 179e904d0e..b36b9567d2 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandlerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowShouldRemoveActionHandlerTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -45,7 +46,7 @@ public class WindowShouldRemoveActionHandlerTest extends MultiBrowserTest { } private void assertState(String expected) { - Assert.assertEquals("Unexpected state,", expected, + assertEquals("Unexpected state,", expected, $(LabelElement.class).id("state").getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListenerTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListenerTest.java index b77eced9cc..6cffb9ac45 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListenerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/window/WindowWithInvalidCloseListenerTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.By; @@ -13,7 +14,7 @@ public class WindowWithInvalidCloseListenerTest extends MultiBrowserTest { openTestURL(); $(WindowElement.class).first() .findElement(By.className("v-window-closebox")).click(); - Assert.assertFalse("Window found when there should be none.", + assertFalse("Window found when there should be none.", $(WindowElement.class).exists()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/contextclick/AbstractContextClickTest.java b/uitest/src/test/java/com/vaadin/tests/contextclick/AbstractContextClickTest.java index 8497ec8eed..db31e89064 100644 --- a/uitest/src/test/java/com/vaadin/tests/contextclick/AbstractContextClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/contextclick/AbstractContextClickTest.java @@ -16,12 +16,12 @@ package com.vaadin.tests.contextclick; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.Point; @@ -87,10 +87,8 @@ public abstract class AbstractContextClickTest extends MultiBrowserTest { Point l = component.getLocation(); Matcher matcher = defaultLog.matcher(getLogRow(0)); - Assert.assertTrue( - "Log row content did not match default listener output: " - + getLogRow(0), - matcher.find()); + assertTrue("Log row content did not match default listener output: " + + getLogRow(0), matcher.find()); int xCoord = Integer.parseInt(matcher.group(1)); int yCoord = Integer.parseInt(matcher.group(2)); @@ -98,11 +96,11 @@ public abstract class AbstractContextClickTest extends MultiBrowserTest { int xExpected = l.getX() + x; int yExpected = l.getY() + y; - Assert.assertTrue( + assertTrue( "X Coordinate differs too much from expected. Expected: " + xExpected + ", actual: " + xCoord, Math.abs(xExpected - xCoord) <= 1); - Assert.assertTrue( + assertTrue( "Y Coordinate differs too much from expected. Expected: " + yExpected + ", actual: " + yCoord, Math.abs(yExpected - yCoord) <= 1); diff --git a/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java b/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java index 12cfb45d07..158167c8d9 100644 --- a/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/core/SpecialCharactersEncodingUITest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.core; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -17,17 +18,15 @@ public class SpecialCharactersEncodingUITest extends SingleBrowserTest { openTestURL(); String textFieldValue = $(TextFieldElement.class).id("textfield") .getValue(); - Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, - textFieldValue); + assertEquals(SpecialCharactersEncodingUI.textWithZwnj, textFieldValue); LabelElement label = $(LabelElement.class).id("label"); String labelValue = getHtml(label); // getText() strips some characters - Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, - labelValue); + assertEquals(SpecialCharactersEncodingUI.textWithZwnj, labelValue); MenuBarElement menubar = $(MenuBarElement.class).first(); WebElement menuItem = menubar .findElement(By.className("v-menubar-menuitem-caption")); - Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + assertEquals(SpecialCharactersEncodingUI.textWithZwnj, getHtml(menuItem)); } diff --git a/uitest/src/test/java/com/vaadin/tests/data/DataProviderRefreshTest.java b/uitest/src/test/java/com/vaadin/tests/data/DataProviderRefreshTest.java index f32ec543a8..bbb31535a8 100644 --- a/uitest/src/test/java/com/vaadin/tests/data/DataProviderRefreshTest.java +++ b/uitest/src/test/java/com/vaadin/tests/data/DataProviderRefreshTest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.data; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -13,25 +16,24 @@ public class DataProviderRefreshTest extends SingleBrowserTest { public void select_and_replace() { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertFalse("Row should not be initially selected", + assertFalse("Row should not be initially selected", grid.getRow(0).isSelected()); // Select item before replace $(ButtonElement.class).caption("Select old").first().click(); - Assert.assertTrue("Row should be selected", - grid.getRow(0).isSelected()); + assertTrue("Row should be selected", grid.getRow(0).isSelected()); $(ButtonElement.class).caption("Replace item").first().click(); - Assert.assertTrue("Row should still be selected after item replace", + assertTrue("Row should still be selected after item replace", grid.getRow(0).isSelected()); - Assert.assertEquals("Grid content was not updated.", "{ Bar, 10 }", + assertEquals("Grid content was not updated.", "{ Bar, 10 }", grid.getCell(0, 0).getText()); // Deselect row grid.getCell(0, 0).click(); - Assert.assertFalse("Row should be deselected after click", + assertFalse("Row should be deselected after click", grid.getRow(0).isSelected()); - Assert.assertEquals("Second row was affected", "{ Baz, 11 }", + assertEquals("Second row was affected", "{ Baz, 11 }", grid.getCell(1, 0).getText()); } @@ -39,28 +41,27 @@ public class DataProviderRefreshTest extends SingleBrowserTest { public void replace_and_select() { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertFalse("Row should not be initially selected", + assertFalse("Row should not be initially selected", grid.getRow(0).isSelected()); // Replace item before select $(ButtonElement.class).caption("Replace item").first().click(); - Assert.assertFalse("Row should not be selected after item replace", + assertFalse("Row should not be selected after item replace", grid.getRow(0).isSelected()); - Assert.assertEquals("Grid content was not updated.", "{ Bar, 10 }", + assertEquals("Grid content was not updated.", "{ Bar, 10 }", grid.getCell(0, 0).getText()); $(ButtonElement.class).caption("Select old").first().click(); - Assert.assertTrue("Row should be selected", - grid.getRow(0).isSelected()); - Assert.assertEquals("Grid content should not update.", "{ Bar, 10 }", + assertTrue("Row should be selected", grid.getRow(0).isSelected()); + assertEquals("Grid content should not update.", "{ Bar, 10 }", grid.getCell(0, 0).getText()); // Deselect row grid.getCell(0, 0).click(); - Assert.assertFalse("Row should be deselected after click", + assertFalse("Row should be deselected after click", grid.getRow(0).isSelected()); - Assert.assertEquals("Second row was affected", "{ Baz, 11 }", + assertEquals("Second row was affected", "{ Baz, 11 }", grid.getCell(1, 0).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/data/GridRefreshWithGetIdTest.java b/uitest/src/test/java/com/vaadin/tests/data/GridRefreshWithGetIdTest.java index c3bda4f3ca..83da78712e 100644 --- a/uitest/src/test/java/com/vaadin/tests/data/GridRefreshWithGetIdTest.java +++ b/uitest/src/test/java/com/vaadin/tests/data/GridRefreshWithGetIdTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.data; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -15,13 +17,11 @@ public class GridRefreshWithGetIdTest extends SingleBrowserTest { // Select item GridElement grid = $(GridElement.class).first(); grid.getCell(2, 0).click(); - Assert.assertTrue("Row should be selected", - grid.getRow(2).isSelected()); - Assert.assertEquals("green", grid.getCell(2, 0).getText()); + assertTrue("Row should be selected", grid.getRow(2).isSelected()); + assertEquals("green", grid.getCell(2, 0).getText()); $(ButtonElement.class).first().click(); - Assert.assertTrue("Row was no longer selected", - grid.getRow(2).isSelected()); - Assert.assertEquals("black", grid.getCell(2, 0).getText()); + assertTrue("Row was no longer selected", grid.getRow(2).isSelected()); + assertEquals("black", grid.getCell(2, 0).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/data/ReplaceDataProviderTest.java b/uitest/src/test/java/com/vaadin/tests/data/ReplaceDataProviderTest.java index 41731296ac..c64a06600e 100644 --- a/uitest/src/test/java/com/vaadin/tests/data/ReplaceDataProviderTest.java +++ b/uitest/src/test/java/com/vaadin/tests/data/ReplaceDataProviderTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.data; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import org.junit.Before; import org.junit.Test; @@ -21,19 +23,19 @@ public class ReplaceDataProviderTest extends SingleBrowserTest { ButtonElement replaceDataProviderButton = $(ButtonElement.class) .first(); - Assert.assertEquals(20, grid.getRowCount()); + assertEquals(20, grid.getRowCount()); grid.getCell(0, 0).click(); assertCellText("a", 0, 0); replaceDataProviderButton.click(); - Assert.assertEquals(10, grid.getRowCount()); + assertEquals(10, grid.getRowCount()); assertCellText("b", 0, 0); for (int i = 1; i < 10; i++) { assertCellText("a", i, 0); } - Assert.assertFalse(grid.getRow(0).isSelected()); + assertFalse(grid.getRow(0).isSelected()); grid.getCell(0, 0).click(); assertCellText("b", 0, 0); @@ -47,6 +49,6 @@ public class ReplaceDataProviderTest extends SingleBrowserTest { private void assertCellText(String text, int rowIndex, int colIndex) { String firstCellText = $(GridElement.class).first() .getCell(rowIndex, colIndex).getText(); - Assert.assertEquals(text, firstCellText); + assertEquals(text, firstCellText); } } diff --git a/uitest/src/test/java/com/vaadin/tests/dd/DDInterruptTest.java b/uitest/src/test/java/com/vaadin/tests/dd/DDInterruptTest.java index b34a56ac09..856ab7bba9 100644 --- a/uitest/src/test/java/com/vaadin/tests/dd/DDInterruptTest.java +++ b/uitest/src/test/java/com/vaadin/tests/dd/DDInterruptTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.dd; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -69,13 +70,12 @@ public class DDInterruptTest extends MultiBrowserTest { } private void assertNoNotifications() { - Assert.assertEquals( - "Notification found when there should have been none,", 0, + assertEquals("Notification found when there should have been none,", 0, findElements(By.className("v-Notification")).size()); } private void assertDragged(boolean dragged) { - Assert.assertEquals("Unexpected drag state,", dragged ? 1 : 0, + assertEquals("Unexpected drag state,", dragged ? 1 : 0, findElements(By.className("v-ddwrapper-over-bottom")).size()); } diff --git a/uitest/src/test/java/com/vaadin/tests/debug/PreserveCustomDebugSectionOpenTest.java b/uitest/src/test/java/com/vaadin/tests/debug/PreserveCustomDebugSectionOpenTest.java index c8a7fa3d22..32c772b67b 100644 --- a/uitest/src/test/java/com/vaadin/tests/debug/PreserveCustomDebugSectionOpenTest.java +++ b/uitest/src/test/java/com/vaadin/tests/debug/PreserveCustomDebugSectionOpenTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.debug; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -36,12 +37,12 @@ public class PreserveCustomDebugSectionOpenTest extends SingleBrowserTest { By.cssSelector(".v-debugwindow-content")); // Sanity check - Assert.assertEquals("Dummy debug window section", content.getText()); + assertEquals("Dummy debug window section", content.getText()); // Open page again, should still have the same section open openTestURL(); content = findElement(By.cssSelector(".v-debugwindow-content")); - Assert.assertEquals("Dummy debug window section", content.getText()); + assertEquals("Dummy debug window section", content.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/debug/ProfilerZeroOverheadTest.java b/uitest/src/test/java/com/vaadin/tests/debug/ProfilerZeroOverheadTest.java index fff3f012cf..d4df441ac3 100644 --- a/uitest/src/test/java/com/vaadin/tests/debug/ProfilerZeroOverheadTest.java +++ b/uitest/src/test/java/com/vaadin/tests/debug/ProfilerZeroOverheadTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.debug; -import org.junit.Assert; +import static org.junit.Assert.fail; + import org.junit.Test; import org.openqa.selenium.By; @@ -45,7 +46,7 @@ public class ProfilerZeroOverheadTest extends SingleBrowserTest { // Method body shouldn't contain anything else than whitespace if (!methodBody.replaceAll("\\s", "").isEmpty()) { - Assert.fail("Canary method is not empty: " + canaryMethodString); + fail("Canary method is not empty: " + canaryMethodString); } } } diff --git a/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java b/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java index 9e9d1e969c..351cfa1e59 100644 --- a/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java +++ b/uitest/src/test/java/com/vaadin/tests/debug/PushVersionInfoTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.debug; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -39,9 +41,9 @@ public class PushVersionInfoTest extends SingleBrowserTest { openTestURL(); selectInfoTab(); - Assert.assertNull("Found push info server string for disabled Push", + assertNull("Found push info server string for disabled Push", getPushRowValue("Push server version")); - Assert.assertNull("Found push info client string for disabled Push", + assertNull("Found push info client string for disabled Push", getPushRowValue("Push client version")); } @@ -54,13 +56,12 @@ public class PushVersionInfoTest extends SingleBrowserTest { WebElement pushRow = getPushRowValue("Push server version"); String atmVersion = findElement(By.className("atmosphere-version")) .getText(); - Assert.assertTrue("Push row doesn't contain Atmosphere version", + assertTrue("Push row doesn't contain Atmosphere version", pushRow.getText().contains(atmVersion)); String jsString = getPushRowValue("Push client version").getText(); - Assert.assertTrue("Push client version doesn't contain 'vaadin' string", + assertTrue("Push client version doesn't contain 'vaadin' string", jsString.contains("vaadin")); - Assert.assertTrue( - "Push client version doesn't contain 'javascript' string", + assertTrue("Push client version doesn't contain 'javascript' string", jsString.contains("javascript")); } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValueTest.java index 0dd504732b..3903876386 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityComponentElementGetValueTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.elements; +import static org.junit.Assert.assertEquals; + import java.text.SimpleDateFormat; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -47,7 +48,7 @@ public class CompatibilityComponentElementGetValueTest ComboBoxElement elem = $(ComboBoxElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -55,7 +56,7 @@ public class CompatibilityComponentElementGetValueTest ListSelectElement elem = $(ListSelectElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -63,7 +64,7 @@ public class CompatibilityComponentElementGetValueTest NativeSelectElement elem = $(NativeSelectElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -71,7 +72,7 @@ public class CompatibilityComponentElementGetValueTest OptionGroupElement elem = $(OptionGroupElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -79,7 +80,7 @@ public class CompatibilityComponentElementGetValueTest TwinColSelectElement elem = $(TwinColSelectElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -105,7 +106,7 @@ public class CompatibilityComponentElementGetValueTest CheckBoxElement cb = $(CheckBoxElement.class).get(0); String expected = "checked"; String actual = cb.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -115,12 +116,12 @@ public class CompatibilityComponentElementGetValueTest String expected = format1 .format(CompatibilityComponentElementGetValue.TEST_DATE_VALUE); String actual = df.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } private void checkValue(AbstractTextFieldElement elem) { String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityElementComponentGetCaptionBaseTest.java b/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityElementComponentGetCaptionBaseTest.java index a44534102f..bbebfc6c01 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityElementComponentGetCaptionBaseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/CompatibilityElementComponentGetCaptionBaseTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.elements; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; @@ -128,7 +129,7 @@ public abstract class CompatibilityElementComponentGetCaptionBaseTest private void testCaption(AbstractComponentElement elem, int caption_index) { String actual = elem.getCaption(); String expected = CompatibilityElementComponentGetCaptionBase.DEFAULT_CAPTIONS[caption_index]; - Assert.assertTrue("Error with class:" + elem.getAttribute("class"), + assertTrue("Error with class:" + elem.getAttribute("class"), expected.equals(actual)); } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/ComponentElementGetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/ComponentElementGetValueTest.java index de4a6785c4..bd1ea57eaf 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/ComponentElementGetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/ComponentElementGetValueTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.tests.elements; +import static org.junit.Assert.assertEquals; + import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -49,7 +50,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { ComboBoxElement elem = $(ComboBoxElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -57,7 +58,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { ListSelectElement elem = $(ListSelectElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -65,7 +66,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { NativeSelectElement elem = $(NativeSelectElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -74,7 +75,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { List<String> expected = Collections .singletonList(ComponentElementGetValue.TEST_STRING_VALUE); List<String> actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -82,7 +83,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { RadioButtonGroupElement elem = $(RadioButtonGroupElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -90,7 +91,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { TwinColSelectElement elem = $(TwinColSelectElement.class).get(0); String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -116,7 +117,7 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { CheckBoxElement cb = $(CheckBoxElement.class).get(0); String expected = "checked"; String actual = cb.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -126,12 +127,12 @@ public class ComponentElementGetValueTest extends MultiBrowserTest { String expected = formatter .format(ComponentElementGetValue.TEST_DATE_VALUE); String actual = df.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } private void checkValue(AbstractTextFieldElement elem) { String expected = ComponentElementGetValue.TEST_STRING_VALUE; String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/ElementComponentGetCaptionBaseTest.java b/uitest/src/test/java/com/vaadin/tests/elements/ElementComponentGetCaptionBaseTest.java index 6e6a9c2b4a..412900b368 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/ElementComponentGetCaptionBaseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/ElementComponentGetCaptionBaseTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.elements; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; @@ -189,7 +190,7 @@ public abstract class ElementComponentGetCaptionBaseTest private void testCaption(AbstractComponentElement elem, int caption_index) { String actual = elem.getCaption(); String expected = ElementComponentGetCaptionBase.DEFAULT_CAPTIONS[caption_index]; - Assert.assertTrue("Error with class:" + elem.getAttribute("class"), + assertTrue("Error with class:" + elem.getAttribute("class"), expected.equals(actual)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/ElementQueryUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/ElementQueryUITest.java index b8f3d8d207..786d98991e 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/ElementQueryUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/ElementQueryUITest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.elements; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -13,16 +14,14 @@ public class ElementQueryUITest extends MultiBrowserTest { @Test public void firstGetAllLast() { openTestURL(); - Assert.assertEquals("Button 0", - $(ButtonElement.class).first().getCaption()); - Assert.assertEquals("Button 9", - $(ButtonElement.class).last().getCaption()); + assertEquals("Button 0", $(ButtonElement.class).first().getCaption()); + assertEquals("Button 9", $(ButtonElement.class).last().getCaption()); List<ButtonElement> all = $(ButtonElement.class).all(); for (int i = 0; i < 10; i++) { - Assert.assertEquals("Button " + i, all.get(i).getCaption()); - Assert.assertEquals("Button " + i, + assertEquals("Button " + i, all.get(i).getCaption()); + assertEquals("Button " + i, $(ButtonElement.class).get(i).getCaption()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementClearValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementClearValueTest.java index 9237a541e0..e20963edde 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementClearValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementClearValueTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.elements; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.time.format.DateTimeFormatter; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,7 +72,7 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { public void clearTextField() { TextFieldElement elem = $(TextFieldElement.class).get(0); checkElementValue(elem); - Assert.assertEquals(ComponentElementGetValue.FIELD_VALUES[0], + assertEquals(ComponentElementGetValue.FIELD_VALUES[0], labelChangeValue.getText()); } @@ -78,7 +80,7 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { public void clearTextArea() { TextAreaElement elem = $(TextAreaElement.class).get(0); checkElementValue(elem); - Assert.assertEquals(ComponentElementGetValue.FIELD_VALUES[1], + assertEquals(ComponentElementGetValue.FIELD_VALUES[1], labelChangeValue.getText()); } @@ -86,7 +88,7 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { public void clearPasswordField() { PasswordFieldElement elem = $(PasswordFieldElement.class).get(0); checkElementValue(elem); - Assert.assertEquals(ComponentElementGetValue.FIELD_VALUES[2], + assertEquals(ComponentElementGetValue.FIELD_VALUES[2], labelChangeValue.getText()); } @@ -97,10 +99,10 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { String expected = formatter .format(ComponentElementGetValue.TEST_DATE_VALUE); String initial = df.getValue(); - Assert.assertEquals(expected, initial); + assertEquals(expected, initial); df.clear(); - Assert.assertEquals("", df.getValue()); - Assert.assertEquals(ComponentElementGetValue.DATEFIELD_VALUE_CHANGE, + assertEquals("", df.getValue()); + assertEquals(ComponentElementGetValue.DATEFIELD_VALUE_CHANGE, labelChangeValue.getText()); } @@ -134,8 +136,8 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { public void clearCheckBox() { CheckBoxElement elem = $(CheckBoxElement.class).get(0); elem.clear(); - Assert.assertTrue(elem.getValue().equals("unchecked")); - Assert.assertEquals(ComponentElementGetValue.CHECKBOX_VALUE_CHANGE, + assertTrue(elem.getValue().equals("unchecked")); + assertEquals(ComponentElementGetValue.CHECKBOX_VALUE_CHANGE, labelChangeValue.getText()); } @@ -143,8 +145,8 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { public void clearTwinCol() { TwinColSelectElement elem = $(TwinColSelectElement.class).get(0); elem.clear(); - Assert.assertEquals("", elem.getValue()); - Assert.assertEquals(ComponentElementGetValue.MULTI_SELECT_VALUE_CHANGE, + assertEquals("", elem.getValue()); + assertEquals(ComponentElementGetValue.MULTI_SELECT_VALUE_CHANGE, labelChangeValue.getText()); } @@ -158,11 +160,11 @@ public class TestBenchElementClearValueTest extends MultiBrowserTest { String expected) { // check initial element value String actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); // check cleared element value elem.clear(); expected = ""; actual = elem.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementRightClickTest.java b/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementRightClickTest.java index 866776c70b..3dc83e04b9 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementRightClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/TestBenchElementRightClickTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -25,8 +26,7 @@ public class TestBenchElementRightClickTest extends MultiBrowserTest { cell.contextClick(); String actual = label.getText(); String expected = "RightClick"; - Assert.assertEquals("TestBenchElement right click fails", expected, - actual); + assertEquals("TestBenchElement right click fails", expected, actual); } @@ -35,7 +35,6 @@ public class TestBenchElementRightClickTest extends MultiBrowserTest { cell.doubleClick(); String actual = label.getText(); String expected = "DoubleClick"; - Assert.assertEquals("TestBenchElement double click fails", expected, - actual); + assertEquals("TestBenchElement double click fails", expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/TreeElementGetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/TreeElementGetValueTest.java index 151992ce63..67ba411c6d 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/TreeElementGetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/TreeElementGetValueTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.elements; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -31,7 +32,6 @@ public class TreeElementGetValueTest extends MultiBrowserTest { @Test public void testGetValue() { TreeElement tree = $(TreeElement.class).get(0); - Assert.assertEquals(tree.getValue(), - TreeElementGetValue.TEST_VALUE_LVL2); + assertEquals(tree.getValue(), TreeElementGetValue.TEST_VALUE_LVL2); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/AbstractTextElementSetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/AbstractTextElementSetValueTest.java index 587836fa6a..e1b9960908 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/AbstractTextElementSetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/AbstractTextElementSetValueTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.elements.abstracttextfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -65,7 +66,7 @@ public class AbstractTextElementSetValueTest extends MultiBrowserTest { // we can type any string in date field element elem.setValue(TYPED_STRING); // invalid values should stay unchanged - Assert.assertEquals(TYPED_STRING, elem.getValue()); + assertEquals(TYPED_STRING, elem.getValue()); } // helper methods @@ -73,15 +74,15 @@ public class AbstractTextElementSetValueTest extends MultiBrowserTest { private void checkType(AbstractTextFieldElement elem, LabelElement eventCount) { // check first that the initial value is set - Assert.assertEquals(AbstractTextElementSetValue.INITIAL_VALUE, + assertEquals(AbstractTextElementSetValue.INITIAL_VALUE, elem.getValue()); elem.setValue(TYPED_STRING); // check that typed value is the same - Assert.assertEquals(TYPED_STRING, elem.getValue()); + assertEquals(TYPED_STRING, elem.getValue()); // checks that there was only one change value event - Assert.assertEquals("1", eventCount.getText()); + assertEquals("1", eventCount.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractTextElementSetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractTextElementSetValueTest.java index d96f5df84a..5f1b20ee31 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractTextElementSetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractTextElementSetValueTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.elements.abstracttextfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -60,8 +61,8 @@ public class CompatibilityAbstractTextElementSetValueTest LabelElement eventCount = $(LabelElement.class).get(4); // we can type any string in date field element elem.setValue(TYPED_STRING); - Assert.assertEquals(TYPED_STRING, elem.getValue()); - Assert.assertEquals("1", eventCount.getText()); + assertEquals(TYPED_STRING, elem.getValue()); + assertEquals("1", eventCount.getText()); } // helper methods @@ -69,16 +70,15 @@ public class CompatibilityAbstractTextElementSetValueTest private void checkType(AbstractTextFieldElement elem, LabelElement eventCount) { // check first that the initial value is set - Assert.assertEquals( - CompatibilityAbstractTextElementSetValue.INITIAL_VALUE, + assertEquals(CompatibilityAbstractTextElementSetValue.INITIAL_VALUE, elem.getValue()); elem.setValue(TYPED_STRING); // check that typed value is the same - Assert.assertEquals(TYPED_STRING, elem.getValue()); + assertEquals(TYPED_STRING, elem.getValue()); // checks that there was only one change value event - Assert.assertEquals("1", eventCount.getText()); + assertEquals("1", eventCount.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/button/ButtonUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/button/ButtonUITest.java index c5a166f8f5..f6c92c7870 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/button/ButtonUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/button/ButtonUITest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.button; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -21,7 +22,7 @@ public class ButtonUITest extends MultiBrowserTest { .id(ButtonUI.QUIET_BUTTON_ID); TextFieldElement field = $(TextFieldElement.class).first(); button.click(); - Assert.assertEquals("Clicked", field.getValue()); + assertEquals("Clicked", field.getValue()); } @Test @@ -30,7 +31,7 @@ public class ButtonUITest extends MultiBrowserTest { .id(ButtonUI.QUIET_BUTTON_NO_CAPTION_ID); TextFieldElement field = $(TextFieldElement.class).first(); button.click(); - Assert.assertEquals("Clicked", field.getValue()); + assertEquals("Clicked", field.getValue()); } @Test @@ -41,7 +42,7 @@ public class ButtonUITest extends MultiBrowserTest { TextFieldElement field = $(TextFieldElement.class) .id(ButtonUI.TEXT_FIELD_ID); button.click(); - Assert.assertEquals("Clicked", field.getValue()); + assertEquals("Clicked", field.getValue()); } @Test @@ -52,6 +53,6 @@ public class ButtonUITest extends MultiBrowserTest { LabelElement label = $(LabelElement.class).id(ButtonUI.LABEL_ID); button.click(); - Assert.assertEquals("Clicked", label.getText()); + assertEquals("Clicked", label.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/checkboxgroup/CheckBoxGroupSetSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/elements/checkboxgroup/CheckBoxGroupSetSelectionTest.java index cb244873d8..0eedf14b38 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/checkboxgroup/CheckBoxGroupSetSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/checkboxgroup/CheckBoxGroupSetSelectionTest.java @@ -1,10 +1,11 @@ package com.vaadin.tests.elements.checkboxgroup; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -27,22 +28,20 @@ public class CheckBoxGroupSetSelectionTest extends MultiBrowserTest { @Test public void testSetSelection() { group.setValue(NEW_VALUE); - Assert.assertEquals(Collections.singletonList(NEW_VALUE), - group.getValue()); + assertEquals(Collections.singletonList(NEW_VALUE), group.getValue()); } @Test public void testSelectByText() { group.selectByText(NEW_VALUE); - Assert.assertEquals(Collections.singletonList(NEW_VALUE), - group.getValue()); + assertEquals(Collections.singletonList(NEW_VALUE), group.getValue()); } @Test public void testSelectAll() { List<String> value = Arrays.asList("item1", "item2", "item3"); group.setValue(value); - Assert.assertEquals(value, group.getValue()); + assertEquals(value, group.getValue()); } @Test @@ -50,7 +49,7 @@ public class CheckBoxGroupSetSelectionTest extends MultiBrowserTest { testSelectByText(); group.setValue(); - Assert.assertEquals(Collections.emptyList(), group.getValue()); + assertEquals(Collections.emptyList(), group.getValue()); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxGetSuggestionsTest.java b/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxGetSuggestionsTest.java index 1a527d8e9a..6794319ccb 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxGetSuggestionsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxGetSuggestionsTest.java @@ -1,9 +1,10 @@ package com.vaadin.tests.elements.combobox; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ComboBoxElement; @@ -19,6 +20,6 @@ public class ComboBoxGetSuggestionsTest extends MultiBrowserTest { for (int i = 1; i < 11; i++) { expectedSuggestions.add("item" + i); } - Assert.assertEquals(expectedSuggestions, suggestions); + assertEquals(expectedSuggestions, suggestions); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxInputNotAllowedTest.java b/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxInputNotAllowedTest.java index b2e4ee0151..003c659d9b 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxInputNotAllowedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/combobox/ComboBoxInputNotAllowedTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Ignore; import org.junit.Test; @@ -23,8 +24,7 @@ public class ComboBoxInputNotAllowedTest extends MultiBrowserTest { openTestURL(); ComboBoxElement cb = $(ComboBoxElement.class).first(); - String[] optionsToTest = { - ComboBoxInputNotAllowed.ITEM_ON_FIRST_PAGE, + String[] optionsToTest = { ComboBoxInputNotAllowed.ITEM_ON_FIRST_PAGE, ComboBoxInputNotAllowed.ITEM_ON_SECOND_PAGE, ComboBoxInputNotAllowed.ITEM_ON_LAST_PAGE, ComboBoxInputNotAllowed.ITEM_LAST_WITH_PARENTHESIS, @@ -32,9 +32,9 @@ public class ComboBoxInputNotAllowedTest extends MultiBrowserTest { for (String option : optionsToTest) { cb.selectByText(option); - Assert.assertEquals("Value is now: " + option, + assertEquals("Value is now: " + option, $(LabelElement.class).last().getText()); - Assert.assertEquals(option, cb.getValue()); + assertEquals(option, cb.getValue()); } } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/datefield/DateFieldPopupSetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/datefield/DateFieldPopupSetValueTest.java index 831ec1371a..5465bbbaf5 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/datefield/DateFieldPopupSetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/datefield/DateFieldPopupSetValueTest.java @@ -1,9 +1,10 @@ package com.vaadin.tests.elements.datefield; +import static org.junit.Assert.assertEquals; + import java.text.SimpleDateFormat; import java.util.Date; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -28,7 +29,7 @@ public class DateFieldPopupSetValueTest extends MultiBrowserTest { @Test public void testGetValue() { String value = df.getValue(); - Assert.assertEquals("04/12/15", value); + assertEquals("04/12/15", value); } @Test @@ -36,7 +37,7 @@ public class DateFieldPopupSetValueTest extends MultiBrowserTest { Date date = DateFieldPopupSetValue.changedDate; String value = (new SimpleDateFormat("MM/dd/yy")).format(date); df.setValue(value); - Assert.assertEquals("06/11/15", df.getValue()); + assertEquals("06/11/15", df.getValue()); } @Test @@ -45,6 +46,6 @@ public class DateFieldPopupSetValueTest extends MultiBrowserTest { String value = (new SimpleDateFormat("MM/dd/yy")).format(date); df.setValue(value); counter.waitForVaadin(); - Assert.assertEquals("1", counter.getText()); + assertEquals("1", counter.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java index 8ac0aae0fe..b045bf2874 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.NoSuchElementException; @@ -13,13 +14,13 @@ public class GridUITest extends MultiBrowserTest { @Test public void testRowCount() { openTestURL("rowCount=0"); - Assert.assertEquals(0, getRowCount()); + assertEquals(0, getRowCount()); openTestURL("rowCount=1&restartApplication"); - Assert.assertEquals(1, getRowCount()); + assertEquals(1, getRowCount()); openTestURL("rowCount=10&restartApplication"); - Assert.assertEquals(10, getRowCount()); + assertEquals(10, getRowCount()); openTestURL("rowCount=1000&restartApplication"); - Assert.assertEquals(1000, getRowCount()); + assertEquals(1000, getRowCount()); } private long getRowCount() { @@ -33,13 +34,13 @@ public class GridUITest extends MultiBrowserTest { @Test public void testGetRows() { openTestURL("rowCount=0"); - Assert.assertEquals(0, checkRows()); + assertEquals(0, checkRows()); openTestURL("rowCount=1&restartApplication"); - Assert.assertEquals(1, checkRows()); + assertEquals(1, checkRows()); openTestURL("rowCount=10&restartApplication"); - Assert.assertEquals(10, checkRows()); + assertEquals(10, checkRows()); openTestURL("rowCount=100&restartApplication"); - Assert.assertEquals(100, checkRows()); + assertEquals(100, checkRows()); } @Test @@ -87,8 +88,8 @@ public class GridUITest extends MultiBrowserTest { private int checkRows() { int rowCount = 0; for (final GridRowElement row : getRows()) { - Assert.assertEquals("foo " + rowCount, row.getCell(0).getText()); - Assert.assertEquals("bar " + rowCount, row.getCell(1).getText()); + assertEquals("foo " + rowCount, row.getCell(0).getText()); + assertEquals("bar " + rowCount, row.getCell(1).getText()); rowCount++; } return rowCount; diff --git a/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java index 78d1fe8deb..c6bcae1864 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/gridlayout/GridLayoutUITest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.elements.gridlayout; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Test; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; @@ -28,18 +30,18 @@ public class GridLayoutUITest extends SingleBrowserTest { @Test public void getRows() { openTestURL(); - Assert.assertEquals(1, $(GridLayoutElement.class) + assertEquals(1, $(GridLayoutElement.class) .id(GridLayoutUI.ONE_ROW_ONE_COL).getRowCount()); - Assert.assertEquals(10, $(GridLayoutElement.class) + assertEquals(10, $(GridLayoutElement.class) .id(GridLayoutUI.TEN_ROWS_TEN_COLS).getRowCount()); } @Test public void getColumns() { openTestURL(); - Assert.assertEquals(1, $(GridLayoutElement.class) + assertEquals(1, $(GridLayoutElement.class) .id(GridLayoutUI.ONE_ROW_ONE_COL).getColumnCount()); - Assert.assertEquals(10, $(GridLayoutElement.class) + assertEquals(10, $(GridLayoutElement.class) .id(GridLayoutUI.TEN_ROWS_TEN_COLS).getColumnCount()); } @@ -50,22 +52,22 @@ public class GridLayoutUITest extends SingleBrowserTest { .id(GridLayoutUI.TEN_ROWS_TEN_COLS); WebElement cell55 = grid.getCell(5, 5); - Assert.assertEquals("v-gridlayout-slot", cell55.getAttribute("class")); - Assert.assertEquals("5-5", cell55.getText()); + assertEquals("v-gridlayout-slot", cell55.getAttribute("class")); + assertEquals("5-5", cell55.getText()); try { grid.getCell(4, 4); - Assert.fail("Should throw for empty cell"); + fail("Should throw for empty cell"); } catch (NoSuchElementException e) { } WebElement cell77 = grid.getCell(7, 7); - Assert.assertEquals("v-gridlayout-slot", cell77.getAttribute("class")); - Assert.assertEquals("7-7 8-8", cell77.getText()); + assertEquals("v-gridlayout-slot", cell77.getAttribute("class")); + assertEquals("7-7 8-8", cell77.getText()); try { grid.getCell(7, 8); - Assert.fail("Should throw for merged cell"); + fail("Should throw for merged cell"); } catch (NoSuchElementException e) { } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/link/LinkUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/link/LinkUITest.java index 1560dc64d5..a3ab7346b6 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/link/LinkUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/link/LinkUITest.java @@ -1,6 +1,9 @@ package com.vaadin.tests.elements.link; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; @@ -19,12 +22,11 @@ public class LinkUITest extends MultiBrowserTest { @Test public void testLinkClick() { String currentUrl = getDriver().getCurrentUrl(); - Assert.assertTrue( - "Current URL " + currentUrl + " should end with LinkUI?", + assertTrue("Current URL " + currentUrl + " should end with LinkUI?", currentUrl.endsWith("LinkUI")); link.click(); currentUrl = getDriver().getCurrentUrl(); - Assert.assertFalse( + assertFalse( "Current URL " + currentUrl + " should not end with LinkUI?", currentUrl.endsWith("LinkUI")); @@ -32,7 +34,7 @@ public class LinkUITest extends MultiBrowserTest { @Test public void getLinkCaption() { - Assert.assertEquals("server root", link.getCaption()); + assertEquals("server root", link.getCaption()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/listselect/ListSelectOptionClickTest.java b/uitest/src/test/java/com/vaadin/tests/elements/listselect/ListSelectOptionClickTest.java index ce7eca6322..def4da1c62 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/listselect/ListSelectOptionClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/listselect/ListSelectOptionClickTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.elements.listselect; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -43,23 +44,23 @@ public class ListSelectOptionClickTest extends MultiBrowserTest { @Test public void testMultiSelectDeselectByText() { select.selectByText("item2"); - Assert.assertEquals("1: [item1, item2]", counterLbl.getText()); + assertEquals("1: [item1, item2]", counterLbl.getText()); select.selectByText("item3"); - Assert.assertEquals("2: [item1, item2, item3]", counterLbl.getText()); + assertEquals("2: [item1, item2, item3]", counterLbl.getText()); select.deselectByText("item2"); - Assert.assertEquals("3: [item1, item3]", counterLbl.getText()); + assertEquals("3: [item1, item3]", counterLbl.getText()); } @Test public void testDeselectSelectByText() { select.deselectByText("item1"); - Assert.assertEquals("1: []", counterLbl.getText()); + assertEquals("1: []", counterLbl.getText()); select.selectByText("item1"); - Assert.assertEquals("2: [item1]", counterLbl.getText()); + assertEquals("2: [item1]", counterLbl.getText()); select.selectByText("item3"); - Assert.assertEquals("3: [item1, item3]", counterLbl.getText()); + assertEquals("3: [item1, item3]", counterLbl.getText()); select.deselectByText("item1"); - Assert.assertEquals("4: [item3]", counterLbl.getText()); + assertEquals("4: [item3]", counterLbl.getText()); } /* @@ -69,10 +70,9 @@ public class ListSelectOptionClickTest extends MultiBrowserTest { private void checkValueChanged() { String actual = select.getValue(); String actualCounter = counterLbl.getText(); - Assert.assertEquals("The value of the ListSelect has not changed", - "item2", actual); - Assert.assertEquals( - "The number of list select valueChange events is not one.", + assertEquals("The value of the ListSelect has not changed", "item2", + actual); + assertEquals("The number of list select valueChange events is not one.", "1: item2", actualCounter); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/nativeselect/NativeSelectSetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/nativeselect/NativeSelectSetValueTest.java index 0ce358e727..282feee67d 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/nativeselect/NativeSelectSetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/nativeselect/NativeSelectSetValueTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.nativeselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -35,8 +36,8 @@ public class NativeSelectSetValueTest extends MultiBrowserTest { private void checkTestValue() { // checks value has changed String actual = select.getValue(); - Assert.assertEquals("item 2", actual); + assertEquals("item 2", actual); // checks change value event occures - Assert.assertEquals("1", counter.getText()); + assertEquals("1", counter.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationCloseTest.java b/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationCloseTest.java index 2640c1a5e7..333fd7e8e3 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationCloseTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationCloseTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.elements.notification; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -46,7 +47,6 @@ public class NotificationCloseTest extends MultiBrowserTest { List<NotificationElement> notifications = $(NotificationElement.class) .all(); // check that all notifications are closed - Assert.assertTrue("There are open notifications", - notifications.isEmpty()); + assertTrue("There are open notifications", notifications.isEmpty()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescriptionTest.java b/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescriptionTest.java index ae0ea0e757..55f4d6947d 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescriptionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationGetTypeAndDescriptionTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.notification; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -38,14 +39,13 @@ public class NotificationGetTypeAndDescriptionTest extends MultiBrowserTest { NotificationElement notification = $(NotificationElement.class).get(0); String eCaption = NotificationGetTypeAndDescription.captions[index]; String aCaption = notification.getCaption(); - Assert.assertEquals("Test captions fail", eCaption, aCaption); + assertEquals("Test captions fail", eCaption, aCaption); String eDescription = NotificationGetTypeAndDescription.descriptions[index]; String aDescription = notification.getDescription(); - Assert.assertEquals("Test descriptions fail", eDescription, - aDescription); + assertEquals("Test descriptions fail", eDescription, aDescription); String eType = NotificationGetTypeAndDescription.type_names[index]; String aType = notification.getType(); - Assert.assertEquals("Test types fail", eType, aType); + assertEquals("Test types fail", eType, aType); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/optiongroup/OptionGroupSetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/optiongroup/OptionGroupSetValueTest.java index a4fc3932db..241f7c6ffc 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/optiongroup/OptionGroupSetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/optiongroup/OptionGroupSetValueTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.optiongroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -22,13 +23,13 @@ public class OptionGroupSetValueTest extends MultiBrowserTest { @Test public void testSetValue() { group.setValue(NEW_VALUE); - Assert.assertEquals(NEW_VALUE, group.getValue()); + assertEquals(NEW_VALUE, group.getValue()); } @Test public void testSelectByText() { group.selectByText(NEW_VALUE); - Assert.assertEquals(NEW_VALUE, group.getValue()); + assertEquals(NEW_VALUE, group.getValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/panel/PanelScrollTest.java b/uitest/src/test/java/com/vaadin/tests/elements/panel/PanelScrollTest.java index 97b35b2e63..c8267c595f 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/panel/PanelScrollTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/panel/PanelScrollTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.panel; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -15,7 +16,7 @@ public class PanelScrollTest extends MultiBrowserTest { openTestURL(); PanelElement panel = $(PanelElement.class).get(0); panel.scrollLeft(SCROLL_VALUE); - Assert.assertEquals(SCROLL_VALUE, getScrollLeftValue(panel)); + assertEquals(SCROLL_VALUE, getScrollLeftValue(panel)); } @Test @@ -23,7 +24,7 @@ public class PanelScrollTest extends MultiBrowserTest { openTestURL(); PanelElement panel = $(PanelElement.class).get(0); panel.scroll(SCROLL_VALUE); - Assert.assertEquals(SCROLL_VALUE, getScrollTopValue(panel)); + assertEquals(SCROLL_VALUE, getScrollTopValue(panel)); } // helper functions diff --git a/uitest/src/test/java/com/vaadin/tests/elements/radiobuttongroup/RadioButtonGroupSetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/radiobuttongroup/RadioButtonGroupSetValueTest.java index 03bc2d8379..05f00fdf41 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/radiobuttongroup/RadioButtonGroupSetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/radiobuttongroup/RadioButtonGroupSetValueTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.radiobuttongroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -22,13 +23,13 @@ public class RadioButtonGroupSetValueTest extends MultiBrowserTest { @Test public void testSetValue() { group.setValue(NEW_VALUE); - Assert.assertEquals(NEW_VALUE, group.getValue()); + assertEquals(NEW_VALUE, group.getValue()); } @Test public void testSelectByText() { group.selectByText(NEW_VALUE); - Assert.assertEquals(NEW_VALUE, group.getValue()); + assertEquals(NEW_VALUE, group.getValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetHandleTest.java b/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetHandleTest.java index bd4e567b70..191707a0cb 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetHandleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetHandleTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.slider; -import org.junit.Assert; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -31,7 +32,7 @@ public class SliderGetHandleTest extends MultiBrowserTest { String initial = "" + (int) SliderGetHandle.INITIAL_VALUE; String actual = slider.getValue(); - Assert.assertNotEquals(initial, actual); + assertNotEquals(initial, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetValueTest.java b/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetValueTest.java index ef41ab8a0f..30eec5ba7d 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetValueTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/slider/SliderGetValueTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.slider; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; @@ -25,6 +26,6 @@ public class SliderGetValueTest extends MultiBrowserTest { SliderElement pb = $(SliderElement.class).get(0); String expected = "" + ComponentElementGetValue.TEST_SLIDER_VALUE; String actual = pb.getValue(); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/table/GetRowHeaderTest.java b/uitest/src/test/java/com/vaadin/tests/elements/table/GetRowHeaderTest.java index 742fd33947..ee8fedfa62 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/table/GetRowHeaderTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/table/GetRowHeaderTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.elements.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; @@ -34,8 +36,7 @@ public class GetRowHeaderTest extends MultiBrowserTest { TableHeaderElement header = table.getHeaderCell(COLUMN_INDEX); String expected = "property0"; String actual = header.getCaption(); - Assert.assertEquals( - "TableHeaderElement.getCaption() returns wrong value.", + assertEquals("TableHeaderElement.getCaption() returns wrong value.", expected, actual); } @@ -51,10 +52,8 @@ public class GetRowHeaderTest extends MultiBrowserTest { table.waitForVaadin(); String expected = "col=0 row=99"; String actual = table.getCell(0, COLUMN_INDEX).getText(); - Assert.assertEquals( - "TableHeaderElement.toggleSort() did not sort column " - + COLUMN_INDEX, - expected, actual); + assertEquals("TableHeaderElement.toggleSort() did not sort column " + + COLUMN_INDEX, expected, actual); } @Test @@ -82,7 +81,7 @@ public class GetRowHeaderTest extends MultiBrowserTest { } header = table.getHeaderCell(COLUMN_INDEX); int widthAfterResize = header.getSize().width; - Assert.assertTrue( + assertTrue( "The column with index " + COLUMN_INDEX + " was not resized.", initialWidth > widthAfterResize); } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/table/TableElementContextMenuTest.java b/uitest/src/test/java/com/vaadin/tests/elements/table/TableElementContextMenuTest.java index 6a05730814..e2975564e5 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/table/TableElementContextMenuTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/table/TableElementContextMenuTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.table; -import org.junit.Assert; +import static org.junit.Assert.assertNotNull; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.NoSuchElementException; @@ -23,7 +24,7 @@ public class TableElementContextMenuTest extends MultiBrowserTest { tableElement.contextClick(); TableElement.ContextMenuElement contextMenu = tableElement .getContextMenu(); - Assert.assertNotNull( + assertNotNull( "There is no context menu open by tableElement.contextClick()", contextMenu); } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/table/TableGetRowTest.java b/uitest/src/test/java/com/vaadin/tests/elements/table/TableGetRowTest.java index 8068c5aabd..43ffca87d5 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/table/TableGetRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/table/TableGetRowTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.NoSuchElementException; @@ -38,7 +39,7 @@ public class TableGetRowTest extends MultiBrowserTest { String expected = "col=0 row=0"; String actual = cell.getText(); - Assert.assertEquals(GET_ROW_ERROR_MESSAGE, expected, actual); + assertEquals(GET_ROW_ERROR_MESSAGE, expected, actual); } @Test @@ -47,14 +48,14 @@ public class TableGetRowTest extends MultiBrowserTest { WebElement cell = row.getCell(1); String expected = "col=1 row=4"; String actual = cell.getText(); - Assert.assertEquals(GET_ROW_ERROR_MESSAGE, expected, actual); + assertEquals(GET_ROW_ERROR_MESSAGE, expected, actual); } @Test public void rowGetCellTest() { TestBenchElement cellFromTable = table.getCell(firstRow, firstCol); WebElement cellFromRow = table.getRow(firstRow).getCell(firstCol); - Assert.assertEquals( + assertEquals( "Table.getCell() and Row.getCell() return different values", cellFromRow.getText(), cellFromTable.getText()); } @@ -64,7 +65,7 @@ public class TableGetRowTest extends MultiBrowserTest { TestBenchElement cell = table.getCell(firstRow, firstCol); String actual = cell.getText(); String expected = "col=0 row=0"; - Assert.assertEquals(GET_CELL_ERROR_MESSAGE, expected, actual); + assertEquals(GET_CELL_ERROR_MESSAGE, expected, actual); } @Test(expected = NoSuchElementException.class) diff --git a/uitest/src/test/java/com/vaadin/tests/elements/table/TableScrollTest.java b/uitest/src/test/java/com/vaadin/tests/elements/table/TableScrollTest.java index f607db2fc3..06d34131bf 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/table/TableScrollTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/table/TableScrollTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.table; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; @@ -16,7 +17,7 @@ public class TableScrollTest extends MultiBrowserTest { openTestURL(); TableElement table = $(TableElement.class).get(0); table.scrollLeft(SCROLL_VALUE); - Assert.assertEquals(SCROLL_VALUE, getScrollLeftValue(table)); + assertEquals(SCROLL_VALUE, getScrollLeftValue(table)); } @Test @@ -24,7 +25,7 @@ public class TableScrollTest extends MultiBrowserTest { openTestURL(); TableElement table = $(TableElement.class).get(0); table.scroll(SCROLL_VALUE); - Assert.assertEquals(SCROLL_VALUE, getScrollTopValue(table)); + assertEquals(SCROLL_VALUE, getScrollTopValue(table)); } // helper functions diff --git a/uitest/src/test/java/com/vaadin/tests/elements/treetable/TreeTableElementExpandRowTest.java b/uitest/src/test/java/com/vaadin/tests/elements/treetable/TreeTableElementExpandRowTest.java index e20a6dd4ab..0f007c4eac 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/treetable/TreeTableElementExpandRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/treetable/TreeTableElementExpandRowTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.elements.treetable; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -53,6 +54,6 @@ public class TreeTableElementExpandRowTest extends MultiBrowserTest { } errorMessage += "Return value of row=" + rowIndex + " cell=0 should be " + expectedValue + "."; - Assert.assertEquals(errorMessage, expectedValue, cell.getText()); + assertEquals(errorMessage, expectedValue, cell.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/elements/twincolselect/TwinColSelectUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/twincolselect/TwinColSelectUITest.java index 66be8c2aa9..1a0c197195 100644 --- a/uitest/src/test/java/com/vaadin/tests/elements/twincolselect/TwinColSelectUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/elements/twincolselect/TwinColSelectUITest.java @@ -1,8 +1,10 @@ package com.vaadin.tests.elements.twincolselect; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -24,20 +26,19 @@ public class TwinColSelectUITest extends MultiBrowserTest { @Test public void testSelectDeselectByText() { multiSelect.selectByText("item2"); - Assert.assertEquals("1: [item1, item2]", multiCounterLbl.getText()); + assertEquals("1: [item1, item2]", multiCounterLbl.getText()); multiSelect.selectByText("item3"); - Assert.assertEquals("2: [item1, item2, item3]", - multiCounterLbl.getText()); + assertEquals("2: [item1, item2, item3]", multiCounterLbl.getText()); multiSelect.deselectByText("item2"); - Assert.assertEquals("3: [item1, item3]", multiCounterLbl.getText()); + assertEquals("3: [item1, item3]", multiCounterLbl.getText()); } @Test public void testDeselectSelectByText() { multiSelect.deselectByText("item1"); - Assert.assertEquals("1: []", multiCounterLbl.getText()); + assertEquals("1: []", multiCounterLbl.getText()); multiSelect.selectByText("item1"); - Assert.assertEquals("2: [item1]", multiCounterLbl.getText()); + assertEquals("2: [item1]", multiCounterLbl.getText()); } @Test @@ -51,6 +52,6 @@ public class TwinColSelectUITest extends MultiBrowserTest { private void assertAvailableOptions(String... items) { List<String> optionTexts = multiSelect.getAvailableOptions(); - Assert.assertArrayEquals(items, optionTexts.toArray()); + assertArrayEquals(items, optionTexts.toArray()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java b/uitest/src/test/java/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java index 408dcd28e0..821d95a8a9 100644 --- a/uitest/src/test/java/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java +++ b/uitest/src/test/java/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java @@ -1,8 +1,9 @@ package com.vaadin.tests.extensions; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; @@ -26,7 +27,7 @@ public class IframeIsOpenedInNonIOSTest extends MultiBrowserTest { .contains(IframeIsOpenedInNonIOS.FILE_NAME); } - Assert.assertTrue("page doesn't contain iframe with the file", + assertTrue("page doesn't contain iframe with the file", containsFileIframe); } diff --git a/uitest/src/test/java/com/vaadin/tests/extensions/UnknownExtensionHandlingTest.java b/uitest/src/test/java/com/vaadin/tests/extensions/UnknownExtensionHandlingTest.java index 855b7ed789..dc1eb24499 100644 --- a/uitest/src/test/java/com/vaadin/tests/extensions/UnknownExtensionHandlingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/extensions/UnknownExtensionHandlingTest.java @@ -15,9 +15,11 @@ */ package com.vaadin.tests.extensions; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -34,10 +36,9 @@ public class UnknownExtensionHandlingTest extends SingleBrowserTest { openDebugLogTab(); - Assert.assertTrue( - hasMessageContaining(MyExtension.class.getCanonicalName())); + assertTrue(hasMessageContaining(MyExtension.class.getCanonicalName())); - Assert.assertFalse(hasMessageContaining("Hierachy claims")); + assertFalse(hasMessageContaining("Hierachy claims")); } private boolean hasMessageContaining(String needle) { diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java index 8a0d63ecd4..f23f087b40 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridEditorRowTest.java @@ -16,8 +16,9 @@ package com.vaadin.tests.fieldgroup; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -25,9 +26,9 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.CheckBoxElement; import com.vaadin.testbench.elements.DateFieldElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.GridElement.GridEditorElement; import com.vaadin.testbench.parallel.TestCategory; @@ -67,11 +68,10 @@ public class BasicCrudGridEditorRowTest extends MultiBrowserTest { input.sendKeys("Invalid", Keys.TAB); editor.save(); - Assert.assertTrue("Editor wasn't displayed.", editor.isDisplayed()); - Assert.assertTrue("DateField wasn't displayed.", - dateField.isDisplayed()); + assertTrue("Editor wasn't displayed.", editor.isDisplayed()); + assertTrue("DateField wasn't displayed.", dateField.isDisplayed()); - Assert.assertTrue("DateField didn't have 'v-invalid' css class.", + assertTrue("DateField didn't have 'v-invalid' css class.", hasCssClass(dateField, "v-datefield-error")); } @@ -88,8 +88,7 @@ public class BasicCrudGridEditorRowTest extends MultiBrowserTest { // Check values String value = cb.getValue(); cb.click(5, 5); - Assert.assertNotEquals("Checkbox value did not change", value, - cb.getValue()); + assertNotEquals("Checkbox value did not change", value, cb.getValue()); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java index 6b737c8278..f77242ed5a 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudGridTest.java @@ -15,14 +15,16 @@ */ package com.vaadin.tests.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.AbstractHasTestBenchCommandExecutor; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.AbstractComponentElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; @@ -35,7 +37,7 @@ public class BasicCrudGridTest extends SingleBrowserTestPhantomJS2 { .$(TextFieldElement.class).all(); for (TextFieldElement e : textFields) { - Assert.assertEquals("TextField should be empty", "", e.getValue()); + assertEquals("TextField should be empty", "", e.getValue()); } } @@ -54,15 +56,14 @@ public class BasicCrudGridTest extends SingleBrowserTestPhantomJS2 { .$(TextFieldElement.class).all(); for (TextFieldElement e : textFields) { - Assert.assertNotEquals("TextField should not be empty", "", - e.getValue()); + assertNotEquals("TextField should not be empty", "", e.getValue()); } // Deselect row $(GridElement.class).first().getCell(2, 2).click(); for (TextFieldElement e : textFields) { - Assert.assertEquals("TextField should be empty", "", e.getValue()); + assertEquals("TextField should be empty", "", e.getValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudTableTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudTableTest.java index 3ca03717a1..6acdbdf85c 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudTableTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicCrudTableTest.java @@ -15,14 +15,16 @@ */ package com.vaadin.tests.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.AbstractHasTestBenchCommandExecutor; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.AbstractComponentElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -35,7 +37,7 @@ public class BasicCrudTableTest extends SingleBrowserTest { .$(TextFieldElement.class).all(); for (TextFieldElement e : textFields) { - Assert.assertEquals("TextField should be empty", "", e.getValue()); + assertEquals("TextField should be empty", "", e.getValue()); } } @@ -54,15 +56,14 @@ public class BasicCrudTableTest extends SingleBrowserTest { .$(TextFieldElement.class).all(); for (TextFieldElement e : textFields) { - Assert.assertNotEquals("TextField should not be empty", "", - e.getValue()); + assertNotEquals("TextField should not be empty", "", e.getValue()); } // Deselect row $(TableElement.class).first().getCell(2, 2).click(); for (TextFieldElement e : textFields) { - Assert.assertEquals("TextField should be empty", "", e.getValue()); + assertEquals("TextField should be empty", "", e.getValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java index ddf97d8727..7dbfc03b5a 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BasicPersonFormTest.java @@ -15,13 +15,14 @@ */ package com.vaadin.tests.fieldgroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.NotificationElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.TableRowElement; import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.testbench.elements.TextFieldElement; @@ -115,14 +116,13 @@ public abstract class BasicPersonFormTest extends MultiBrowserTest { private void assertFieldValue(String caption, String expected, TestBenchElement field) { - Assert.assertEquals( - String.format("Unexpected value for field '%s',", caption), + assertEquals(String.format("Unexpected value for field '%s',", caption), expected, field.getAttribute("value")); } protected void assertSelectedSex(Sex sex) { TableRowElement row = getGenderTable().getRow(getIndex(sex)); - Assert.assertTrue( + assertTrue( String.format("Given sex (%s) isn't selected.", sex.getStringRepresentation()), hasCssClass(row, "v-selected")); @@ -164,8 +164,8 @@ public abstract class BasicPersonFormTest extends MultiBrowserTest { protected void assertLogText(String expected) { ++logCounter; - Assert.assertEquals("Unexpected log contents,", - logCounter + ". " + expected, getLogRow(0)); + assertEquals("Unexpected log contents,", logCounter + ". " + expected, + getLogRow(0)); } protected void assertDefaults() { diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BooleanTextFieldTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BooleanTextFieldTest.java index abbe4128dd..e5ff31f9e1 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/BooleanTextFieldTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/BooleanTextFieldTest.java @@ -1,8 +1,10 @@ package com.vaadin.tests.fieldgroup; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -32,15 +34,15 @@ public class BooleanTextFieldTest extends BasicPersonFormTest { getDeceasedField().sendKeys("false", Keys.ENTER); /* error indicator */ - Assert.assertEquals("Incorrect amount of error indicators on page.", 1, + assertEquals("Incorrect amount of error indicators on page.", 1, findElements(By.className("v-errorindicator")).size()); - Assert.assertEquals("false", getDeceasedField().getAttribute("value")); + assertEquals("false", getDeceasedField().getAttribute("value")); assertBeanValuesUnchanged(); /* error message in tooltip */ getDeceasedField().showTooltip(); - Assert.assertEquals("Could not convert value to Boolean", + assertEquals("Could not convert value to Boolean", getTooltipErrorElement().getText()); getDeceasedField().click(); @@ -50,13 +52,13 @@ public class BooleanTextFieldTest extends BasicPersonFormTest { getDeceasedField().sendKeys("YAY!", Keys.ENTER); /* no error indicator */ - Assert.assertFalse(isElementPresent(By.className("v-errorindicator"))); + assertFalse(isElementPresent(By.className("v-errorindicator"))); assertCommitSuccessful(); /* commit last name and new deceased status */ showBeanValues(); - Assert.assertEquals( + assertEquals( "4. Person [firstName=John, lastName=Dover, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=true, salary=null, salaryDouble=null, rent=null]", getLogRow(0)); } diff --git a/uitest/src/test/java/com/vaadin/tests/fieldgroup/DateFormTest.java b/uitest/src/test/java/com/vaadin/tests/fieldgroup/DateFormTest.java index 5bad4aa98c..4a0b95fc73 100644 --- a/uitest/src/test/java/com/vaadin/tests/fieldgroup/DateFormTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fieldgroup/DateFormTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.fieldgroup; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -15,17 +17,16 @@ public class DateFormTest extends MultiBrowserTest { @Test public void testCorrectDateFormat() throws Exception { openTestURL(); - Assert.assertEquals("Unexpected DateField value,", "1/20/84", + assertEquals("Unexpected DateField value,", "1/20/84", getDateFieldValue()); - Assert.assertEquals("Unexpected PopupDateField value,", "1/21/84", + assertEquals("Unexpected PopupDateField value,", "1/21/84", getPopupDateFieldValue()); WebElement day20 = getInlineDateFieldCalendarPanel() .findElement(By.vaadin("#day20")); - Assert.assertTrue( - "Unexpected InlineDateField state, 20th not selected.", + assertTrue("Unexpected InlineDateField state, 20th not selected.", hasCssClass(day20, "v-inline-datefield-calendarpanel-day-selected")); - Assert.assertEquals("Unexpected TextField contents,", + assertEquals("Unexpected TextField contents,", "Jan 20, 1984 4:34:49 PM", $(TextFieldElement.class).first().getValue()); } diff --git a/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java b/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java index 16ea0d051f..db61d72d8f 100644 --- a/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fields/TabIndexesTest.java @@ -1,9 +1,10 @@ package com.vaadin.tests.fields; +import static org.junit.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -80,12 +81,12 @@ public class TabIndexesTest extends SingleBrowserTest { } private void assertLogText(String expected) { - Assert.assertEquals("Unexpected log contents,", expected, getLogRow(0)); + assertEquals("Unexpected log contents,", expected, getLogRow(0)); } private void assertTabIndex(String expected, WebElement element) { if (!expected.equals(element.getAttribute("tabIndex"))) { - Assert.assertEquals( + assertEquals( "Unexpected tab index for element " + element.getAttribute("outerHTML"), expected, element.getAttribute("tabIndex")); @@ -118,7 +119,7 @@ public class TabIndexesTest extends SingleBrowserTest { List<AbstractComponentElement> components = $( VerticalLayoutElement.class).id(TabIndexes.FIELD_CONTAINER_ID) .$(AbstractComponentElement.class).all(); - Assert.assertEquals(components.size(), focusElements.size()); + assertEquals(components.size(), focusElements.size()); return focusElements; } diff --git a/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java b/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java index db5c08c653..fdf82ff02e 100644 --- a/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java +++ b/uitest/src/test/java/com/vaadin/tests/fonticon/GridLayoutOnFontLoadTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.fonticon; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -23,11 +24,11 @@ public class GridLayoutOnFontLoadTest extends MultiBrowserTest { TextAreaElement textarea = $(TextAreaElement.class).first(); GridElement grid = $(GridElement.class).first(); - Assert.assertTrue( + assertTrue( "Button overlaps with checkbox (layout done before fonts loaded)", button.getLocation().getX() + button.getSize().width <= checkbox .getLocation().getX()); - Assert.assertTrue( + assertTrue( "TextArea overlaps with grid caption (layout done before fonts loaded)", textarea.getLocation().getY() + textarea.getSize().height + 10 < grid.getLocation().getY()); diff --git a/uitest/src/test/java/com/vaadin/tests/htmlimport/HtmlImportUITest.java b/uitest/src/test/java/com/vaadin/tests/htmlimport/HtmlImportUITest.java index b830552c27..3ba04b64b2 100644 --- a/uitest/src/test/java/com/vaadin/tests/htmlimport/HtmlImportUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/htmlimport/HtmlImportUITest.java @@ -15,12 +15,15 @@ */ package com.vaadin.tests.htmlimport; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; @@ -55,13 +58,13 @@ public class HtmlImportUITest extends MultiBrowserTest { WebElement log = findElement(By.id("clientlog")); // Defined by ui.js List<WebElement> messages = log.findElements(By.className("message")); - // Assert.assertEquals("Some log messages are missing or extra", 3, + // assertEquals("Some log messages are missing or extra", 3, // messages.size()); // JS before HTML, UI deps in bootstrap, rest dynamically // ui.js just sets up the logging - Assert.assertEquals("ui.html", messages.get(0).getText()); + assertEquals("ui.html", messages.get(0).getText()); // Apparently Chrome does not guarantee that "label.js" is executed // before "label.html", at least in the way we are loading HTML and JS. @@ -78,14 +81,14 @@ public class HtmlImportUITest extends MultiBrowserTest { // HTML import String href = e.getAttribute("href"); String file = href.substring(href.lastIndexOf('/') + 1); - Assert.assertFalse("Multiple HTML imports for " + file, + assertFalse("Multiple HTML imports for " + file, htmlImportIndexes.containsKey(file)); htmlImportIndexes.put(file, i); } else if (e.getTagName().equalsIgnoreCase("script")) { // JS String src = e.getAttribute("src"); String file = src.substring(src.lastIndexOf('/') + 1); - Assert.assertFalse("Multiple script tags for " + file, + assertFalse("Multiple script tags for " + file, jsIndexes.containsKey(file)); jsIndexes.put(file, i); } @@ -102,13 +105,13 @@ public class HtmlImportUITest extends MultiBrowserTest { int otherJsIndex = jsIndexes.get("labelX.js"); int otherHtmlIndex = htmlImportIndexes.get("labelX.html"); - Assert.assertTrue("super js should be before super html", + assertTrue("super js should be before super html", superJsIndex < superHtmlIndex); - Assert.assertTrue("super dependencies should be before sub js", + assertTrue("super dependencies should be before sub js", superHtmlIndex < subJsIndex); - Assert.assertTrue("sub js should be before sub html", + assertTrue("sub js should be before sub html", subJsIndex < subHtmlIndex); } } diff --git a/uitest/src/test/java/com/vaadin/tests/layoutmanager/LayoutDuringStateUpdateTest.java b/uitest/src/test/java/com/vaadin/tests/layoutmanager/LayoutDuringStateUpdateTest.java index 1d601b6fb1..ba184ce0ab 100644 --- a/uitest/src/test/java/com/vaadin/tests/layoutmanager/LayoutDuringStateUpdateTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layoutmanager/LayoutDuringStateUpdateTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.layoutmanager; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -30,7 +31,7 @@ public class LayoutDuringStateUpdateTest extends SingleBrowserTest { WebElement label = findElement(By.className("gwt-Label")); - Assert.assertEquals("Layout phase count: 1", label.getText()); + assertEquals("Layout phase count: 1", label.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java index 82ddc53fbf..57b2285f10 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutAbsoluteUrlTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.layouts; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -33,7 +34,7 @@ public class CssLayoutAbsoluteUrlTest extends SingleBrowserTest { // Not testing string equality since some browsers return the style with // quotes around the url argument and some without quotes. - Assert.assertTrue(backgroundImage + " does not contain 'about:blank'", + assertTrue(backgroundImage + " does not contain 'about:blank'", backgroundImage.contains("about:blank")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentTest.java index 789f15e5e4..bd66164d08 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/CssLayoutRemoveComponentTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.layouts; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -40,7 +41,7 @@ public class CssLayoutRemoveComponentTest extends SingleBrowserTestPhantomJS2 { Long mutationEvents = (Long) executeScript( "return document.mutationEventCount;"); - Assert.assertEquals( + assertEquals( "Parent should only have two mutation events (remove field and its caption)", 2, mutationEvents.intValue()); } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/HorizontalLayoutAndCaretPositionTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/HorizontalLayoutAndCaretPositionTest.java index 132845a74c..36e201feab 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/HorizontalLayoutAndCaretPositionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/HorizontalLayoutAndCaretPositionTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.layouts; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TextFieldElement; @@ -31,14 +33,14 @@ public class HorizontalLayoutAndCaretPositionTest extends MultiBrowserTest { first.click(); first.sendKeys("test"); // make sure that the field could be focused and text typed - Assert.assertEquals("Field must be focused on click", "test", + assertEquals("Field must be focused on click", "test", first.getValue()); // now move the focus to the next text field $(TextFieldElement.class).get(1).click(); // and back to the first one first.click(30, 10); first.sendKeys("do_not_put_in_beginning_"); - Assert.assertNotEquals("The caret position must be maintained", + assertNotEquals("The caret position must be maintained", "do_not_put_in_beginning_test", first.getValue()); } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/RelativeSizeInUndefinedCssLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/RelativeSizeInUndefinedCssLayoutTest.java index 02c9a5a3df..2d2f764297 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/RelativeSizeInUndefinedCssLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/RelativeSizeInUndefinedCssLayoutTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.layouts; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.FormLayoutElement; @@ -29,9 +31,9 @@ public class RelativeSizeInUndefinedCssLayoutTest public void relativeSizeInUndefinedCssLayout() { openTestURL(); int w = $(FormLayoutElement.class).first().getSize().getWidth(); - Assert.assertEquals(w, 520); + assertEquals(w, 520); int w2 = $(TextFieldElement.class).first().getSize().getWidth(); - Assert.assertTrue(w2 > 400); + assertTrue(w2 > 400); } } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java index 9d3bf43ff8..a9517d5504 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/TestLayoutClickListenersTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.layouts; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.interactions.Actions; @@ -195,6 +196,6 @@ public class TestLayoutClickListenersTest extends MultiBrowserTest { private void assertLogText(String message, String expected) { String actual = $(LabelElement.class).first().getText(); - Assert.assertEquals(message, expected, actual); + assertEquals(message, expected, actual); } } diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/VerticalLayoutRemoveComponentTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/VerticalLayoutRemoveComponentTest.java index 5ce565230d..39d9cc673d 100644 --- a/uitest/src/test/java/com/vaadin/tests/layouts/VerticalLayoutRemoveComponentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/layouts/VerticalLayoutRemoveComponentTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.layouts; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -41,8 +42,7 @@ public class VerticalLayoutRemoveComponentTest Long mutationEvents = (Long) executeScript( "return document.mutationEventCount;"); - Assert.assertEquals( - "Parent should only have one mutation event (remove slot)", 1, - mutationEvents.intValue()); + assertEquals("Parent should only have one mutation event (remove slot)", + 1, mutationEvents.intValue()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/navigator/DelayedViewLeaveConfirmationTest.java b/uitest/src/test/java/com/vaadin/tests/navigator/DelayedViewLeaveConfirmationTest.java index b3f7053cda..3e652bd0d3 100644 --- a/uitest/src/test/java/com/vaadin/tests/navigator/DelayedViewLeaveConfirmationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/navigator/DelayedViewLeaveConfirmationTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.navigator; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -97,17 +98,16 @@ public class DelayedViewLeaveConfirmationTest extends SingleBrowserTest { } private void assertOnOtherView() { - Assert.assertEquals("Just another view", + assertEquals("Just another view", $(LabelElement.class).first().getText()); } private void assertOnMainView() { - Assert.assertEquals("Saved value", - $(LabelElement.class).first().getCaption()); + assertEquals("Saved value", $(LabelElement.class).first().getCaption()); } private void assertLoggedOut() { - Assert.assertEquals("You have been logged out", + assertEquals("You have been logged out", $(LabelElement.class).first().getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/performance/MemoryIT.java b/uitest/src/test/java/com/vaadin/tests/performance/MemoryIT.java index d3082ec336..f80fe7bbc5 100644 --- a/uitest/src/test/java/com/vaadin/tests/performance/MemoryIT.java +++ b/uitest/src/test/java/com/vaadin/tests/performance/MemoryIT.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.performance; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -45,7 +47,6 @@ public class MemoryIT extends SingleBrowserTest { performTest(TreeGridMemory.PATH + "?items=1", "tree-grid-one-item-"); performTest(TreeTableMemory.PATH + "?items=1", "tree-table-one-item-"); - performTest(TreeGridMemory.PATH + "?items=100&initiallyExpanded", "tree-grid-100-items-initially-expanded-"); performTest(TreeTableMemory.PATH + "?items=100&initiallyExpanded", @@ -89,7 +90,7 @@ public class MemoryIT extends SingleBrowserTest { return; } if (i == MAX_ITERATIONS) { - Assert.fail("Memory size does not stabilize"); + fail("Memory size does not stabilize"); } } } @@ -112,7 +113,7 @@ public class MemoryIT extends SingleBrowserTest { private void openUI(String path) { getDriver().get(StringUtils.strip(getBaseURL(), "/") + path); - Assert.assertTrue(isElementPresent(By.className("v-grid")) + assertTrue(isElementPresent(By.className("v-grid")) || isElementPresent(By.className("v-treegrid")) || isElementPresent(By.className("v-table"))); } diff --git a/uitest/src/test/java/com/vaadin/tests/push/BarInUIDLTest.java b/uitest/src/test/java/com/vaadin/tests/push/BarInUIDLTest.java index 47b05ac854..8963c26bb2 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/BarInUIDLTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/BarInUIDLTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -28,15 +29,13 @@ public class BarInUIDLTest extends MultiBrowserTest { public void sendBarInUIDL() { openTestURL(); getButton().click(); - Assert.assertEquals("Thank you for clicking | bar", - vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]") - .getText()); + assertEquals("Thank you for clicking | bar", vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]") + .getText()); getButton().click(); - Assert.assertEquals("Thank you for clicking | bar", - vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]") - .getText()); + assertEquals("Thank you for clicking | bar", vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]") + .getText()); } private WebElement getButton() { diff --git a/uitest/src/test/java/com/vaadin/tests/push/IdlePushChannelTest.java b/uitest/src/test/java/com/vaadin/tests/push/IdlePushChannelTest.java index 4291b99dc6..a96bdce9c9 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/IdlePushChannelTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/IdlePushChannelTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.parallel.TestCategory; @@ -30,10 +31,10 @@ public abstract class IdlePushChannelTest extends MultiBrowserTest { public void longWaitBetweenActions() throws Exception { openTestURL(); BasicPushTest.getIncrementButton(this).click(); - Assert.assertEquals(1, BasicPushTest.getClientCounter(this)); + assertEquals(1, BasicPushTest.getClientCounter(this)); sleep(SEVEN_MINUTES_IN_MS); BasicPushTest.getIncrementButton(this).click(); - Assert.assertEquals(2, BasicPushTest.getClientCounter(this)); + assertEquals(2, BasicPushTest.getClientCounter(this)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/push/MakeComponentVisibleWithPushTest.java b/uitest/src/test/java/com/vaadin/tests/push/MakeComponentVisibleWithPushTest.java index 80bedff193..c5bb5900f7 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/MakeComponentVisibleWithPushTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/MakeComponentVisibleWithPushTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -30,10 +31,10 @@ public class MakeComponentVisibleWithPushTest extends SingleBrowserTest { openTestURL(); $(ButtonElement.class).first().click(); - Assert.assertEquals("Unexpected row count", 1, + assertEquals("Unexpected row count", 1, $(GridElement.class).first().getRowCount()); $(ButtonElement.class).first().click(); - Assert.assertEquals("Unexpected row count", 2, + assertEquals("Unexpected row count", 2, $(GridElement.class).first().getRowCount()); assertNoErrorNotifications(); diff --git a/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java b/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java index 320627ca74..985181b8cd 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/PushErrorHandlingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -32,7 +33,7 @@ public class PushErrorHandlingTest extends MultiBrowserTest { setPush(true); openTestURL(); vaadinElementById("npeButton").click(); - Assert.assertEquals( + assertEquals( "An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc", $(LabelElement.class).get(1).getText()); @@ -41,7 +42,7 @@ public class PushErrorHandlingTest extends MultiBrowserTest { .findElement(By.xpath("//div[text()='Click for NPE']")); row.click(); - Assert.assertEquals("Internal error", + assertEquals("Internal error", vaadinElement("Root/VNotification[0]/HTML[0]/domChild[0]") .getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/push/PushToggleComponentVisibilityTest.java b/uitest/src/test/java/com/vaadin/tests/push/PushToggleComponentVisibilityTest.java index 11ad287240..0a7ee645d5 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/PushToggleComponentVisibilityTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/PushToggleComponentVisibilityTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -31,12 +32,10 @@ public class PushToggleComponentVisibilityTest extends SingleBrowserTest { openTestURL(); $(ButtonElement.class).id(HIDE).click(); - Assert.assertEquals("Please wait", - $(LabelElement.class).first().getText()); + assertEquals("Please wait", $(LabelElement.class).first().getText()); waitUntil(driver -> isElementPresent(ButtonElement.class)); $(ButtonElement.class).id(HIDE).click(); - Assert.assertEquals("Please wait", - $(LabelElement.class).first().getText()); + assertEquals("Please wait", $(LabelElement.class).first().getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/push/PushWithPreserveOnRefreshTest.java b/uitest/src/test/java/com/vaadin/tests/push/PushWithPreserveOnRefreshTest.java index ad1f30172e..7542fd13d2 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/PushWithPreserveOnRefreshTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/PushWithPreserveOnRefreshTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -28,11 +29,11 @@ public class PushWithPreserveOnRefreshTest extends MultiBrowserTest { openTestURL(); $(ButtonElement.class).first().click(); $(ButtonElement.class).first().click(); - Assert.assertEquals("2. Button has been clicked 2 times", getLogRow(0)); + assertEquals("2. Button has been clicked 2 times", getLogRow(0)); openTestURL(); - Assert.assertEquals("2. Button has been clicked 2 times", getLogRow(0)); + assertEquals("2. Button has been clicked 2 times", getLogRow(0)); $(ButtonElement.class).first().click(); - Assert.assertEquals("3. Button has been clicked 3 times", getLogRow(0)); + assertEquals("3. Button has been clicked 3 times", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/push/RefreshCloseConnectionTest.java b/uitest/src/test/java/com/vaadin/tests/push/RefreshCloseConnectionTest.java index cfbc528718..6f19fcb9f9 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/RefreshCloseConnectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/RefreshCloseConnectionTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.push; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.remote.DesiredCapabilities; @@ -31,12 +32,12 @@ public class RefreshCloseConnectionTest extends MultiBrowserTest { public void testSessionRefresh() { openTestURL("restartApplication"); - Assert.assertEquals("1. Init", getLogRow(0)); + assertEquals("1. Init", getLogRow(0)); openTestURL(); - Assert.assertEquals("2. Refresh", getLogRow(1)); - Assert.assertEquals("3. Push", getLogRow(0)); + assertEquals("2. Refresh", getLogRow(1)); + assertEquals("3. Push", getLogRow(0)); } @Override diff --git a/uitest/src/test/java/com/vaadin/tests/push/TogglePushTest.java b/uitest/src/test/java/com/vaadin/tests/push/TogglePushTest.java index 0508ec3695..6913dd2700 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/TogglePushTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/TogglePushTest.java @@ -15,7 +15,10 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -33,21 +36,19 @@ public class TogglePushTest extends MultiBrowserTest { // Open with push disabled driver.get(addParameter(url, "push=disabled")); - Assert.assertFalse(getPushToggle().isSelected()); + assertFalse(getPushToggle().isSelected()); getDelayedCounterUpdateButton().click(); sleep(2000); - Assert.assertEquals("Counter has been updated 0 times", - getCounterText()); + assertEquals("Counter has been updated 0 times", getCounterText()); // Open with push enabled driver.get(addParameter(url, "push=enabled")); - Assert.assertTrue(getPushToggle().isSelected()); + assertTrue(getPushToggle().isSelected()); getDelayedCounterUpdateButton().click(); sleep(2000); - Assert.assertEquals("Counter has been updated 1 times", - getCounterText()); + assertEquals("Counter has been updated 1 times", getCounterText()); } @@ -67,21 +68,18 @@ public class TogglePushTest extends MultiBrowserTest { sleep(2000); // Push is enabled, so text gets updated - Assert.assertEquals("Counter has been updated 1 times", - getCounterText()); + assertEquals("Counter has been updated 1 times", getCounterText()); // Disable push getPushToggle().click(); getDelayedCounterUpdateButton().click(); sleep(2000); // Push is disabled, so text is not updated - Assert.assertEquals("Counter has been updated 1 times", - getCounterText()); + assertEquals("Counter has been updated 1 times", getCounterText()); getDirectCounterUpdateButton().click(); // Direct update is visible, and includes previous update - Assert.assertEquals("Counter has been updated 3 times", - getCounterText()); + assertEquals("Counter has been updated 3 times", getCounterText()); // Re-enable push getPushToggle().click(); @@ -89,8 +87,7 @@ public class TogglePushTest extends MultiBrowserTest { sleep(2000); // Push is enabled again, so text gets updated - Assert.assertEquals("Counter has been updated 4 times", - getCounterText()); + assertEquals("Counter has been updated 4 times", getCounterText()); } private WebElement getDirectCounterUpdateButton() { diff --git a/uitest/src/test/java/com/vaadin/tests/push/TrackMessageSizeUITest.java b/uitest/src/test/java/com/vaadin/tests/push/TrackMessageSizeUITest.java index 03ecb8a07d..ad5225b9a9 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/TrackMessageSizeUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/TrackMessageSizeUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.parallel.TestCategory; @@ -26,7 +27,7 @@ public class TrackMessageSizeUITest extends MultiBrowserTest { @Test public void runTests() { openTestURL(); - Assert.assertEquals("1. All tests run", + assertEquals("1. All tests run", vaadinElementById("Log_row_0").getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java b/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java index a5b1f0451c..d46b5d164a 100644 --- a/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java +++ b/uitest/src/test/java/com/vaadin/tests/requesthandlers/AppResource404Test.java @@ -1,8 +1,10 @@ package com.vaadin.tests.requesthandlers; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.remote.DesiredCapabilities; @@ -15,7 +17,7 @@ public class AppResource404Test extends MultiBrowserTest { openTestURL(); $(LinkElement.class).first().click(5, 5); disableWaitingAndWait(); - Assert.assertFalse("Page contains the given text", + assertFalse("Page contains the given text", driver.getPageSource().contains("404")); } @@ -24,7 +26,7 @@ public class AppResource404Test extends MultiBrowserTest { openTestURL(); $(LinkElement.class).get(1).click(5, 5); disableWaitingAndWait(); - Assert.assertTrue("Page does not contain the given text", + assertTrue("Page does not contain the given text", driver.getPageSource().contains( "/APP/connector/0/4/asdfasdf can not be found")); } @@ -34,9 +36,9 @@ public class AppResource404Test extends MultiBrowserTest { openTestURL(); $(LinkElement.class).get(2).click(5, 5); disableWaitingAndWait(); - Assert.assertTrue("Page does not contain the given text", + assertTrue("Page does not contain the given text", driver.getPageSource().contains("HTTP ERROR 404")); - Assert.assertTrue("Page does not contain the given text", + assertTrue("Page does not contain the given text", driver.getPageSource().contains("Problem accessing /run/APP/")); } @@ -45,7 +47,7 @@ public class AppResource404Test extends MultiBrowserTest { openTestURL(); $(LinkElement.class).get(3).click(5, 5); disableWaitingAndWait(); - Assert.assertFalse("Page contains the given text", + assertFalse("Page contains the given text", driver.getPageSource().contains("can not be found")); } diff --git a/uitest/src/test/java/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java b/uitest/src/test/java/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java index d2bfbd1160..79c2c0a37b 100644 --- a/uitest/src/test/java/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/requesthandlers/CommunicationErrorTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.requesthandlers; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -35,7 +36,7 @@ public class CommunicationErrorTest extends MultiBrowserTest { $(ButtonElement.class).first().click(); - Assert.assertTrue(isElementPresent(By.className("redirected"))); + assertTrue(isElementPresent(By.className("redirected"))); } } diff --git a/uitest/src/test/java/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java b/uitest/src/test/java/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java index 16b92139f7..d9f52c6b54 100644 --- a/uitest/src/test/java/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java +++ b/uitest/src/test/java/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.requesthandlers; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.net.HttpURLConnection; import java.net.URL; import org.apache.commons.io.IOUtils; -import org.junit.Assert; import org.junit.Test; import com.vaadin.tests.tb3.PrivateTB3Configuration; @@ -34,7 +36,7 @@ public class UnsupportedBrowserHandlerUserAgents { public void ie7NotSupported() { String response = requestWithUserAgent( "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727)"); - Assert.assertTrue("IE7 should not be supported", + assertTrue("IE7 should not be supported", response.contains("your browser is not supported")); } @@ -42,7 +44,7 @@ public class UnsupportedBrowserHandlerUserAgents { public void ie9NotSupported() { String response = requestWithUserAgent( "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)"); - Assert.assertTrue("IE9 should not be supported", + assertTrue("IE9 should not be supported", response.contains("your browser is not supported")); } @@ -50,7 +52,7 @@ public class UnsupportedBrowserHandlerUserAgents { public void unknownSupported() { String response = requestWithUserAgent( "Very strange user agent, like wat"); - Assert.assertFalse("Unknown user agent should be supported", + assertFalse("Unknown user agent should be supported", response.contains("your browser is not supported")); } diff --git a/uitest/src/test/java/com/vaadin/tests/resources/FrontendInitialResourceUITest.java b/uitest/src/test/java/com/vaadin/tests/resources/FrontendInitialResourceUITest.java index 2c5039717b..4a6a4812f8 100644 --- a/uitest/src/test/java/com/vaadin/tests/resources/FrontendInitialResourceUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/resources/FrontendInitialResourceUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.resources; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -40,7 +41,7 @@ public class FrontendInitialResourceUITest extends MultiBrowserTest { testBench().disableWaitForVaadin(); } - Assert.assertEquals("/VAADIN/frontend/" + es + "/logFilename.js", + assertEquals("/VAADIN/frontend/" + es + "/logFilename.js", findElement(By.tagName("body")).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/resources/FrontendLaterLoadedResourceUITest.java b/uitest/src/test/java/com/vaadin/tests/resources/FrontendLaterLoadedResourceUITest.java index 4709ebbcc0..034b1da1d1 100644 --- a/uitest/src/test/java/com/vaadin/tests/resources/FrontendLaterLoadedResourceUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/resources/FrontendLaterLoadedResourceUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.resources; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -42,7 +43,7 @@ public class FrontendLaterLoadedResourceUITest extends MultiBrowserTest { testBench().disableWaitForVaadin(); } - Assert.assertEquals("/VAADIN/frontend/" + es + "/logFilename.js", + assertEquals("/VAADIN/frontend/" + es + "/logFilename.js", findElement(By.tagName("body")).getText()); } diff --git a/uitest/src/test/java/com/vaadin/tests/resources/SpecialCharsInThemeResources.java b/uitest/src/test/java/com/vaadin/tests/resources/SpecialCharsInThemeResources.java index 308cf76e92..862ab2cc56 100644 --- a/uitest/src/test/java/com/vaadin/tests/resources/SpecialCharsInThemeResources.java +++ b/uitest/src/test/java/com/vaadin/tests/resources/SpecialCharsInThemeResources.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.resources; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -47,7 +48,7 @@ public class SpecialCharsInThemeResources extends SingleBrowserTest { private void checkSource() { String source = getDriver().getPageSource(); - Assert.assertTrue("Incorrect contents (was: " + source + ")", + assertTrue("Incorrect contents (was: " + source + ")", source.contains("Just ordinary contents here")); } } diff --git a/uitest/src/test/java/com/vaadin/tests/serialization/EncodeResultDisplayTest.java b/uitest/src/test/java/com/vaadin/tests/serialization/EncodeResultDisplayTest.java index 8d1f78429b..a33d5e26c5 100644 --- a/uitest/src/test/java/com/vaadin/tests/serialization/EncodeResultDisplayTest.java +++ b/uitest/src/test/java/com/vaadin/tests/serialization/EncodeResultDisplayTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.serialization; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -27,18 +29,17 @@ public class EncodeResultDisplayTest extends SingleBrowserTest { int logRow = 0; - Assert.assertEquals("Void: null", getLogRow(logRow++)); - Assert.assertEquals("SimpleTestBean: {\"value\":5}", - getLogRow(logRow++)); - Assert.assertEquals("List: [\"Three\",\"Four\"]", getLogRow(logRow++)); - Assert.assertEquals("String[]: [\"One\",\"Two\"]", getLogRow(logRow++)); - Assert.assertEquals("Double: 2.2", getLogRow(logRow++)); + assertEquals("Void: null", getLogRow(logRow++)); + assertEquals("SimpleTestBean: {\"value\":5}", getLogRow(logRow++)); + assertEquals("List: [\"Three\",\"Four\"]", getLogRow(logRow++)); + assertEquals("String[]: [\"One\",\"Two\"]", getLogRow(logRow++)); + assertEquals("Double: 2.2", getLogRow(logRow++)); // PhantomJS likes to add a couple of extra decimals - Assert.assertTrue(getLogRow(logRow++).startsWith("Float: 1.1")); - Assert.assertEquals("Long: 2147483648", getLogRow(logRow++)); - Assert.assertEquals("Integer: 3", getLogRow(logRow++)); - Assert.assertEquals("Byte: 1", getLogRow(logRow++)); - Assert.assertEquals("Character: \"v\"", getLogRow(logRow++)); - Assert.assertEquals("String: \"My string\"", getLogRow(logRow++)); + assertTrue(getLogRow(logRow++).startsWith("Float: 1.1")); + assertEquals("Long: 2147483648", getLogRow(logRow++)); + assertEquals("Integer: 3", getLogRow(logRow++)); + assertEquals("Byte: 1", getLogRow(logRow++)); + assertEquals("Character: \"v\"", getLogRow(logRow++)); + assertEquals("String: \"My string\"", getLogRow(logRow++)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java b/uitest/src/test/java/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java index c62cb92378..7e771987f8 100644 --- a/uitest/src/test/java/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.serialization; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -28,8 +29,7 @@ public class GenericWidgetHandlingTest extends MultiBrowserTest { openTestURL(); WebElement label = vaadinElementById("label"); - Assert.assertEquals("The generic text is strong in this one", - label.getText()); + assertEquals("The generic text is strong in this one", label.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/serialization/LegacySerializerUITest.java b/uitest/src/test/java/com/vaadin/tests/serialization/LegacySerializerUITest.java index 13fa85ca72..015affda80 100644 --- a/uitest/src/test/java/com/vaadin/tests/serialization/LegacySerializerUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/serialization/LegacySerializerUITest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.serialization; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -28,9 +29,9 @@ public class LegacySerializerUITest extends SingleBrowserTest { public void testInfinity() { openTestURL(); WebElement html = findElement(By.className("gwt-HTML")); - Assert.assertEquals("doubleInfinity: Infinity", html.getText()); + assertEquals("doubleInfinity: Infinity", html.getText()); // Can't send infinity back, never have been able to - Assert.assertEquals("1. doubleInfinity: null", getLogRow(0)); + assertEquals("1. doubleInfinity: null", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/tests/serialization/NoLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/serialization/NoLayoutTest.java index 58f36f5665..339132de24 100644 --- a/uitest/src/test/java/com/vaadin/tests/serialization/NoLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/serialization/NoLayoutTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.serialization; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -72,10 +73,9 @@ public class NoLayoutTest extends MultiBrowserTest { } private void assertCounts(int layoutCount, int rpcCount) { - Assert.assertEquals("Unexpected layout count", layoutCount, + assertEquals("Unexpected layout count", layoutCount, getCount("layoutCount")); - Assert.assertEquals("Unexpected RPC count", rpcCount, - getCount("rpcCount")); + assertEquals("Unexpected RPC count", rpcCount, getCount("rpcCount")); } private int getCount(String id) { diff --git a/uitest/src/test/java/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/test/java/com/vaadin/tests/serialization/SerializerTestTest.java index db3bdd7a36..77fb764cae 100644 --- a/uitest/src/test/java/com/vaadin/tests/serialization/SerializerTestTest.java +++ b/uitest/src/test/java/com/vaadin/tests/serialization/SerializerTestTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.tests.serialization; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -27,105 +29,97 @@ public class SerializerTestTest extends MultiBrowserTest { openTestURL(); int logRow = 0; - Assert.assertEquals( - "sendJson: {\"b\":false,\"s\":\"JSON\"}, null, \"value\"", + assertEquals("sendJson: {\"b\":false,\"s\":\"JSON\"}, null, \"value\"", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendDateArray: January 31, 2013 10:00:00 PM UTC January 31, 2012 10:00:00 PM UTC", getLogRow(logRow++)); - Assert.assertEquals("sendDate: May 31, 2013 8:12:13 AM UTC", + assertEquals("sendDate: May 31, 2013 8:12:13 AM UTC", getLogRow(logRow++)); - Assert.assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC", + assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendEnum: PREFORMATTED, [HTML, TEXT], [PREFORMATTED, TEXT]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendMap: {a=SimpleTestBean(1)}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=SimpleTestBean(4)], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]", getLogRow(logRow++)); - Assert.assertEquals("sendNull: null, Not null", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals("sendNull: null, Not null", getLogRow(logRow++)); + assertEquals( "sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension", getLogRow(logRow++)); - Assert.assertEquals("sendString: Taegghiiiinnrsssstt‡, [null, ‡]", + assertEquals("sendString: Taegghiiiinnrsssstt‡, [null, ‡]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals( "sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]", getLogRow(logRow++)); - Assert.assertEquals("sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]", - getLogRow(logRow++)); - Assert.assertEquals("sendLong: -57841235865, 577431841358, [57, 0]", - getLogRow(logRow++)); - Assert.assertEquals("sendInt: 2, 5, [2147483647, 0]", + assertEquals("sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]", getLogRow(logRow++)); - Assert.assertEquals("sendChar: Å, ∫, [a, b, c, d]", + assertEquals("sendLong: -57841235865, 577431841358, [57, 0]", getLogRow(logRow++)); - Assert.assertEquals("sendByte: 5, -12, [3, 1, 2]", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals("sendInt: 2, 5, [2147483647, 0]", getLogRow(logRow++)); + assertEquals("sendChar: Å, ∫, [a, b, c, d]", getLogRow(logRow++)); + assertEquals("sendByte: 5, -12, [3, 1, 2]", getLogRow(logRow++)); + assertEquals( "sendBoolean: false, false, [false, false, true, false, true, true]", getLogRow(logRow++)); - Assert.assertEquals("sendBeanSubclass: 43", getLogRow(logRow++)); - Assert.assertEquals( + assertEquals("sendBeanSubclass: 43", getLogRow(logRow++)); + assertEquals( "state.dateArray: Thu Jan 01 02:00:00 GMT+200 1970 Thu Jan 01 02:00:00 GMT+200 1970", getLogRow(logRow++)); - Assert.assertEquals("state.date2: Fri May 31 11:12:13 GMT+300 2013", - getLogRow(logRow++)); - Assert.assertEquals("state.date1: Thu Jan 01 02:00:00 GMT+200 1970", - getLogRow(logRow++)); - Assert.assertEquals("state.jsonBoolean: false", getLogRow(logRow++)); - Assert.assertEquals("state.jsonString: a string", getLogRow(logRow++)); - Assert.assertEquals("state.jsonNull: NULL", getLogRow(logRow++)); - Assert.assertEquals("state.stringArray: [null, ‡]", + assertEquals("state.date2: Fri May 31 11:12:13 GMT+300 2013", getLogRow(logRow++)); - Assert.assertEquals("state.string: This is a tesing string ‡", + assertEquals("state.date1: Thu Jan 01 02:00:00 GMT+200 1970", getLogRow(logRow++)); - Assert.assertEquals( - "state.doubleArray: [1.7976931348623157e+308, 5e-324]", + assertEquals("state.jsonBoolean: false", getLogRow(logRow++)); + assertEquals("state.jsonString: a string", getLogRow(logRow++)); + assertEquals("state.jsonNull: NULL", getLogRow(logRow++)); + assertEquals("state.stringArray: [null, ‡]", getLogRow(logRow++)); + assertEquals("state.string: This is a tesing string ‡", getLogRow(logRow++)); - Assert.assertEquals("state.doubleObjectValue: -2.718281828459045", + assertEquals("state.doubleArray: [1.7976931348623157e+308, 5e-324]", getLogRow(logRow++)); - Assert.assertEquals("state.doubleValue: 3.141592653589793", + assertEquals("state.doubleObjectValue: -2.718281828459045", getLogRow(logRow++)); - Assert.assertEquals("state.floatArray: [57, 0, -12]", + assertEquals("state.doubleValue: 3.141592653589793", getLogRow(logRow++)); - Assert.assertTrue(getLogRow(logRow++) + assertEquals("state.floatArray: [57, 0, -12]", getLogRow(logRow++)); + assertTrue(getLogRow(logRow++) .startsWith("state.floatObjectValue: 1.0000001")); - Assert.assertTrue( - getLogRow(logRow++).startsWith("state.floatValue: 3.14159")); - Assert.assertEquals("state.longArray: [-57841235865, 57]", - getLogRow(logRow++)); - Assert.assertEquals("state.longObjectValue: 577431841360", - getLogRow(logRow++)); - Assert.assertEquals("state.longValue: 577431841359", - getLogRow(logRow++)); - Assert.assertEquals("state.intArray: [5, 7]", getLogRow(logRow++)); - Assert.assertEquals("state.intObjectValue: 42", getLogRow(logRow++)); - Assert.assertEquals("state.intValue: 2147483647", getLogRow(logRow++)); - Assert.assertEquals("state.charArray: aBcD", getLogRow(logRow++)); - Assert.assertEquals("state.charObjectValue: å", getLogRow(logRow++)); - Assert.assertEquals("state.charValue: ∫", getLogRow(logRow++)); - Assert.assertEquals("state.byteArray: [3, 1, 2]", getLogRow(logRow++)); - Assert.assertEquals("state.byteObjectValue: -12", getLogRow(logRow++)); - Assert.assertEquals("state.byteValue: 5", getLogRow(logRow++)); - Assert.assertEquals( + assertTrue(getLogRow(logRow++).startsWith("state.floatValue: 3.14159")); + assertEquals("state.longArray: [-57841235865, 57]", + getLogRow(logRow++)); + assertEquals("state.longObjectValue: 577431841360", + getLogRow(logRow++)); + assertEquals("state.longValue: 577431841359", getLogRow(logRow++)); + assertEquals("state.intArray: [5, 7]", getLogRow(logRow++)); + assertEquals("state.intObjectValue: 42", getLogRow(logRow++)); + assertEquals("state.intValue: 2147483647", getLogRow(logRow++)); + assertEquals("state.charArray: aBcD", getLogRow(logRow++)); + assertEquals("state.charObjectValue: å", getLogRow(logRow++)); + assertEquals("state.charValue: ∫", getLogRow(logRow++)); + assertEquals("state.byteArray: [3, 1, 2]", getLogRow(logRow++)); + assertEquals("state.byteObjectValue: -12", getLogRow(logRow++)); + assertEquals("state.byteValue: 5", getLogRow(logRow++)); + assertEquals( "state.booleanArray: [true, true, false, true, false, false]", getLogRow(logRow++)); diff --git a/uitest/src/test/java/com/vaadin/tests/smoke/DateFieldSmokeTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/DateFieldSmokeTest.java index e86df853d9..915d5359bc 100644 --- a/uitest/src/test/java/com/vaadin/tests/smoke/DateFieldSmokeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/smoke/DateFieldSmokeTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.smoke; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -38,9 +39,9 @@ public class DateFieldSmokeTest extends MultiBrowserTest { openTestURL(); PopupDateFieldElement popup = $(PopupDateFieldElement.class).first(); - Assert.assertEquals("12/28/16", popup.getValue()); + assertEquals("12/28/16", popup.getValue()); InlineDateFieldElement inline = $(InlineDateFieldElement.class).first(); - Assert.assertEquals(String.valueOf(29), + assertEquals(String.valueOf(29), inline.findElement(By.className( "v-inline-datefield-calendarpanel-day-selected")) .getText()); @@ -60,12 +61,12 @@ public class DateFieldSmokeTest extends MultiBrowserTest { inline.findElement(By.className("v-button-prevmonth")).click(); WebElement monthTitle = inline.findElement( By.className("v-inline-datefield-calendarpanel-month")); - Assert.assertEquals("November 2016", monthTitle.getText()); + assertEquals("November 2016", monthTitle.getText()); inline.findElement(By.className("v-button-nextyear")).click(); monthTitle = inline.findElement( By.className("v-inline-datefield-calendarpanel-month")); - Assert.assertEquals("November 2017", monthTitle.getText()); + assertEquals("November 2017", monthTitle.getText()); } private void selectDay(WebElement calendar, int day, String cssPrefix) { diff --git a/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java index 5546faf53b..5268919b25 100644 --- a/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/smoke/GridSmokeTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.tests.smoke; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -31,16 +32,16 @@ public class GridSmokeTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Lorem", grid.getCell(0, 1).getText()); - Assert.assertEquals("2", grid.getCell(1, 2).getText()); + assertEquals("Lorem", grid.getCell(0, 1).getText()); + assertEquals("2", grid.getCell(1, 2).getText()); addRow(); - Assert.assertEquals("Dolor", grid.getCell(2, 1).getText()); + assertEquals("Dolor", grid.getCell(2, 1).getText()); addRow(); - Assert.assertEquals("Dolor", grid.getCell(3, 1).getText()); + assertEquals("Dolor", grid.getCell(3, 1).getText()); } private void addRow() { diff --git a/uitest/src/test/java/com/vaadin/tests/smoke/TableSqlContainerTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/TableSqlContainerTest.java index 97d6a7bb58..7e82ff9aba 100644 --- a/uitest/src/test/java/com/vaadin/tests/smoke/TableSqlContainerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/smoke/TableSqlContainerTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.smoke; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; @@ -35,9 +36,8 @@ public class TableSqlContainerTest extends MultiBrowserTest { TableElement table = $(TableElement.class).first(); char ch = 'A'; for (int i = 0; i < 4; i++) { - Assert.assertEquals(String.valueOf(i + 1), - table.getCell(i, 0).getText()); - Assert.assertEquals(String.valueOf(ch) + i % 2, + assertEquals(String.valueOf(i + 1), table.getCell(i, 0).getText()); + assertEquals(String.valueOf(ch) + i % 2, table.getCell(i, 2).getText()); if (i == 1) { ch++; @@ -46,8 +46,7 @@ public class TableSqlContainerTest extends MultiBrowserTest { table.getCell(1, 0).click(); - Assert.assertEquals("Selected: 2", - findElement(By.id("selection")).getText()); + assertEquals("Selected: 2", findElement(By.id("selection")).getText()); } } 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 3d2c8e8481..c04104934b 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -16,6 +16,11 @@ package com.vaadin.tests.tb3; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; @@ -35,7 +40,6 @@ import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHttpEntityEnclosingRequest; -import org.junit.Assert; import org.junit.Rule; import org.junit.rules.TestName; import org.junit.runner.RunWith; @@ -209,8 +213,8 @@ public abstract class AbstractTB3Test extends ParallelTest { } protected void clearDebugMessages() { - driver.findElement(By - .xpath("//button[@class='v-debugwindow-button' and @title='Clear log']")) + driver.findElement(By.xpath( + "//button[@class='v-debugwindow-button' and @title='Clear log']")) .click(); } @@ -861,8 +865,8 @@ public abstract class AbstractTB3Test extends ParallelTest { for (WebElement e : logElements) { logRows += "\n" + e.getText(); } - Assert.fail("Found debug messages with level " + level.getName() - + ": " + logRows); + fail("Found debug messages with level " + level.getName() + ": " + + logRows); } } @@ -1115,7 +1119,7 @@ public abstract class AbstractTB3Test extends ParallelTest { * the locator for the element */ protected void assertElementPresent(By by) { - Assert.assertTrue("Element is not present", isElementPresent(by)); + assertTrue("Element is not present", isElementPresent(by)); } /** @@ -1125,7 +1129,7 @@ public abstract class AbstractTB3Test extends ParallelTest { * the locator for the element */ protected void assertElementNotPresent(By by) { - Assert.assertFalse("Element is present", isElementPresent(by)); + assertFalse("Element is present", isElementPresent(by)); } /** @@ -1133,8 +1137,7 @@ public abstract class AbstractTB3Test extends ParallelTest { * "?debug" as exceptions are otherwise not shown as notifications. */ protected void assertNoErrorNotifications() { - Assert.assertFalse( - "Error notification with client side exception is shown", + assertFalse("Error notification with client side exception is shown", isNotificationPresent("error")); } @@ -1142,8 +1145,7 @@ public abstract class AbstractTB3Test extends ParallelTest { * Asserts that no system notifications are shown. */ protected void assertNoSystemNotifications() { - Assert.assertFalse( - "Error notification with system error exception is shown", + assertFalse("Error notification with system error exception is shown", isNotificationPresent("system")); } @@ -1151,14 +1153,14 @@ public abstract class AbstractTB3Test extends ParallelTest { * Asserts that a system notification is shown. */ protected void assertSystemNotification() { - Assert.assertTrue( + assertTrue( "Error notification with system error exception is not shown", isNotificationPresent("system")); } private boolean isNotificationPresent(String type) { if ("error".equals(type)) { - Assert.assertTrue( + assertTrue( "Debug window must be open to be able to see error notifications", isDebugWindowOpen()); } @@ -1193,7 +1195,7 @@ public abstract class AbstractTB3Test extends ParallelTest { } message += " have a horizontal scrollbar (scrollWidth: " + scrollWidth + ", clientWidth: " + clientWidth + "): " + errorMessage; - Assert.assertEquals(message, expected, hasScrollbar); + assertEquals(message, expected, hasScrollbar); } protected void assertNoVerticalScrollbar(WebElement element, @@ -1205,7 +1207,7 @@ public abstract class AbstractTB3Test extends ParallelTest { int scrollHeight = getScrollHeight(element); boolean hasScrollbar = scrollHeight > clientHeight; - Assert.assertFalse( + assertFalse( "The element should not have a vertical scrollbar (scrollHeight: " + scrollHeight + ", clientHeight: " + clientHeight + "): " + errorMessage, @@ -1254,7 +1256,7 @@ public abstract class AbstractTB3Test extends ParallelTest { actualElement = ((WrapsElement) actualElement).getWrappedElement(); } - Assert.assertEquals(expectedElement, actualElement); + assertEquals(expectedElement, actualElement); } protected WebElement getActiveElement() { diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/test/java/com/vaadin/tests/tb3/PrivateTB3Configuration.java index aae9b3e13f..4a34c355ad 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -16,6 +16,8 @@ package com.vaadin.tests.tb3; +import static org.junit.Assert.fail; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -26,7 +28,6 @@ import java.util.Calendar; import java.util.Enumeration; import java.util.Properties; -import org.junit.Assert; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; @@ -92,9 +93,8 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { String allowRunLocally = getProperty(ALLOW_RUN_LOCALLY_PROPERTY); if ((allowRunLocally == null || !allowRunLocally.equals("" + true)) && getClass().getAnnotation(RunLocally.class) != null) { - Assert.fail( - "@RunLocally annotation is not allowed by default in framework tests. " - + "See file uitest/eclipse-run-selected-test.properties for more information."); + fail("@RunLocally annotation is not allowed by default in framework tests. " + + "See file uitest/eclipse-run-selected-test.properties for more information."); } super.setup(); diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java index 9c99818a96..39e837ebfb 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/TooltipTest.java @@ -16,10 +16,13 @@ package com.vaadin.tests.tb3; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.List; import java.util.NoSuchElementException; -import org.junit.Assert; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; @@ -62,19 +65,16 @@ public abstract class TooltipTest extends MultiBrowserTest { protected void checkTooltip(String value) throws Exception { WebElement body = findElement(By.cssSelector("body")); WebElement tooltip = getTooltip(); - Assert.assertEquals(value, tooltip.getText()); - Assert.assertTrue("Tooltip overflowed to the left", + assertEquals(value, tooltip.getText()); + assertTrue("Tooltip overflowed to the left", tooltip.getLocation().getX() >= 0); - Assert.assertTrue("Tooltip overflowed up", - tooltip.getLocation().getY() >= 0); - Assert.assertTrue("Tooltip overflowed to the right", + assertTrue("Tooltip overflowed up", tooltip.getLocation().getY() >= 0); + assertTrue("Tooltip overflowed to the right", tooltip.getLocation().getX() + tooltip.getSize().getWidth() < body.getSize() .getWidth()); - Assert.assertTrue("Tooltip overflowed down", - tooltip.getLocation().getY() - + tooltip.getSize().getHeight() < body.getSize() - .getHeight()); + assertTrue("Tooltip overflowed down", tooltip.getLocation().getY() + + tooltip.getSize().getHeight() < body.getSize().getHeight()); } @@ -93,12 +93,11 @@ public abstract class TooltipTest extends MultiBrowserTest { WebElement tooltip = getTooltip(); if (!tooltip.getText().isEmpty() || tooltip.getLocation().getX() > -999) { - Assert.fail("Found tooltip that shouldn't be visible: " + fail("Found tooltip that shouldn't be visible: " + tooltip.getText() + " at " + tooltip.getLocation()); } } catch (NoSuchElementException e) { - Assert.fail( - "Tooltip element was removed completely, causing extra events to accessibility tools"); + fail("Tooltip element was removed completely, causing extra events to accessibility tools"); } } diff --git a/uitest/src/test/java/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java b/uitest/src/test/java/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java index b90e7f41b2..462b47e776 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java @@ -15,19 +15,21 @@ */ package com.vaadin.tests.themes; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; -import com.vaadin.testbench.elements.ComboBoxElement; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.ComboBoxElement; import com.vaadin.testbench.elements.EmbeddedElement; import com.vaadin.testbench.elements.MenuBarElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.parallel.Browser; import com.vaadin.testbench.parallel.BrowserUtil; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -115,8 +117,7 @@ public class LegacyComponentThemeChangeTest extends MultiBrowserTest { // Something in Selenium normalizes the image so it becomes // "/themes/runo/icons/16/ok.png" here although it is // "/themes/<currenttheme>/../runo/icons/16/ok.png" in the browser - Assert.assertEquals(getThemeURL("runo") + "icons/16/ok.png", - runoImageSrc); + assertEquals(getThemeURL("runo") + "icons/16/ok.png", runoImageSrc); // The other image should change with the theme WebElement themeImage = $(MenuBarElement.class).first() @@ -131,7 +132,7 @@ public class LegacyComponentThemeChangeTest extends MultiBrowserTest { WebElement subMenuRuno = subMenu .findElement(By.xpath(".//span[text()='runo']/img")); String subMenuRunoImageSrc = subMenuRuno.getAttribute("src"); - Assert.assertEquals(getThemeURL("runo") + "icons/16/ok.png", + assertEquals(getThemeURL("runo") + "icons/16/ok.png", subMenuRunoImageSrc); WebElement subMenuThemeImage = subMenu .findElement(By.xpath(".//span[text()='selectedtheme']/img")); @@ -142,7 +143,7 @@ public class LegacyComponentThemeChangeTest extends MultiBrowserTest { String theme) { String value = element.getAttribute(attribute); String expectedPrefix = getThemeURL(theme); - Assert.assertTrue( + assertTrue( "Attribute " + attribute + "='" + value + "' does not start with " + expectedPrefix, value.startsWith(expectedPrefix)); diff --git a/uitest/src/test/java/com/vaadin/tests/themes/ThemeChangeFaviconTest.java b/uitest/src/test/java/com/vaadin/tests/themes/ThemeChangeFaviconTest.java index bc897d14b0..2cb9133bbb 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/ThemeChangeFaviconTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/ThemeChangeFaviconTest.java @@ -15,10 +15,12 @@ */ package com.vaadin.tests.themes; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Collections; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -62,10 +64,10 @@ public class ThemeChangeFaviconTest extends SingleBrowserTest { List<WebElement> elements = findElements( By.cssSelector("link[rel~=\"icon\"]")); - Assert.assertEquals(2, elements.size()); + assertEquals(2, elements.size()); for (WebElement element : elements) { - Assert.assertTrue( + assertTrue( element.getAttribute("href") + " does not end with " + faviconUrl, element.getAttribute("href").endsWith(faviconUrl)); diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/CollapsibleTableColumnTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/CollapsibleTableColumnTest.java index 92bff1da9b..ef6ac07458 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/CollapsibleTableColumnTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/CollapsibleTableColumnTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.themes.valo; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -48,7 +49,7 @@ public class CollapsibleTableColumnTest extends MultiBrowserTest { String nonCollapsibleColumnOpacity = items.get(1) .getCssValue("opacity"); - Assert.assertNotEquals( + assertNotEquals( "Opacity value is the same for collapsible " + "and non-collapsible column item", collapsibleColumnOpacity, nonCollapsibleColumnOpacity); diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/ContrastFontColorTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/ContrastFontColorTest.java index d802d02bac..ccd34aeb99 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/ContrastFontColorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/ContrastFontColorTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.themes.valo; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TextFieldElement; @@ -33,7 +34,7 @@ public class ContrastFontColorTest extends MultiBrowserTest { openTestURL(); String color = $(TextFieldElement.class).first().getCssValue("color"); - Assert.assertEquals( + assertEquals( "Unexpected text color value using 0.1 as defualt contrast value :" + color, "rgba(230, 230, 230, 1)", color); diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/DisabledLabelTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/DisabledLabelTest.java index 125c852e1e..892a20c021 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/DisabledLabelTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/DisabledLabelTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.themes.valo; -import org.junit.Assert; +import static org.junit.Assert.assertNotEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -39,7 +40,7 @@ public class DisabledLabelTest extends MultiBrowserTest { WebElement disabled = findElement(By.className("my-disabled")); String disabledOpacity = disabled.getCssValue("opacity"); - Assert.assertNotEquals( + assertNotEquals( "Opacity value is the same for enabled and disabled label", enabledOpacity, disabledOpacity); } diff --git a/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java b/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java index 9d8632218b..6aa7a274be 100644 --- a/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/themes/valo/NotificationStyleTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.themes.valo; +import static org.junit.Assert.assertNotEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -50,7 +51,7 @@ public class NotificationStyleTest extends MultiBrowserTest { .findElements(By.tagName(ValoTheme.LABEL_H1)); String textAlign = headers.get(0).getCssValue("text-align"); String textAlignInnerHeader = headers.get(1).getCssValue("text-align"); - Assert.assertNotEquals( + assertNotEquals( "Styles for notification defined h1 tag " + "and custom HTML tag are the same", textAlign, textAlignInnerHeader); @@ -71,7 +72,7 @@ public class NotificationStyleTest extends MultiBrowserTest { String display = description.getCssValue("display"); String displayP2 = notification.findElement(By.className("tested-p")) .getCssValue("display"); - Assert.assertNotEquals( + assertNotEquals( "Styles for notification defined 'p' tag " + "and custom HTML tag are the same", display, displayP2); diff --git a/uitest/src/test/java/com/vaadin/tests/tooltip/TooltipAndJavascriptTest.java b/uitest/src/test/java/com/vaadin/tests/tooltip/TooltipAndJavascriptTest.java index dd44a436c8..3e8084b440 100644 --- a/uitest/src/test/java/com/vaadin/tests/tooltip/TooltipAndJavascriptTest.java +++ b/uitest/src/test/java/com/vaadin/tests/tooltip/TooltipAndJavascriptTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.tooltip; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; @@ -33,7 +34,7 @@ public class TooltipAndJavascriptTest extends MultiBrowserTest { WebElement tooltip = findElement( By.cssSelector(".v-overlay-container .v-tooltip")); WebElement overlayContainer = getParent(tooltip); - Assert.assertTrue("v-overlay-container did not receive theme", + assertTrue("v-overlay-container did not receive theme", hasClass(overlayContainer, "reindeer")); } diff --git a/uitest/src/test/java/com/vaadin/tests/util/WidgetUtilTest.java b/uitest/src/test/java/com/vaadin/tests/util/WidgetUtilTest.java index d9c5d74114..0f3d4f6961 100644 --- a/uitest/src/test/java/com/vaadin/tests/util/WidgetUtilTest.java +++ b/uitest/src/test/java/com/vaadin/tests/util/WidgetUtilTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.util; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -67,7 +68,7 @@ public class WidgetUtilTest extends MultiBrowserTest { private void assertExpectedSize(WebElement testComponent, String id, String size) { WebElement e = testComponent.findElement(By.id(id)); - Assert.assertEquals(id + ": " + size, e.getText()); + assertEquals(id + ": " + size, e.getText()); } private boolean browserRoundsBorderToInteger( diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java index f6bbe2dc0a..73e3587715 100644 --- a/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java +++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/AssertionsEnabledTest.java @@ -1,6 +1,8 @@ package com.vaadin.tests.widgetset.server; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.By; @@ -18,12 +20,12 @@ public class AssertionsEnabledTest extends SingleBrowserTest { // If assertions are disabled, the AssertionFailureWidget will add a // label to the UI. - Assert.assertFalse( + assertFalse( "Label with classname " + FAILING_CLASSNAME + " should not exist", isElementPresent(By.className(FAILING_CLASSNAME))); - Assert.assertTrue("Assertion error Notification is not present", + assertTrue("Assertion error Notification is not present", isElementPresent(NotificationElement.class)); } diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java index d71676b298..7d30e20623 100644 --- a/uitest/src/test/java/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java +++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.widgetset.server; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -30,6 +31,6 @@ public class ClientRpcClassTest extends MultiBrowserTest { WebElement element = getDriver() .findElement(By.id(ClientRpcClass.TEST_COMPONENT_ID)); - Assert.assertEquals("pause", element.getText()); + assertEquals("pause", element.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java index ce1829796a..f544db8771 100644 --- a/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java +++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/NoneLoadStyleTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.widgetset.server; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; @@ -28,6 +29,6 @@ public class NoneLoadStyleTest extends SingleBrowserTest { String componentText = findElement(By.id("component")).getText(); - Assert.assertTrue(componentText.contains("does not contain")); + assertTrue(componentText.contains("does not contain")); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLocationTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLocationTest.java index 947539855f..f3be117462 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLocationTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDetailsLocationTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.tests.components.grid; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -30,9 +32,9 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.TestBenchElement; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridRowElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.testbench.parallel.TestCategory; @@ -156,7 +158,7 @@ public class GridDetailsLocationTest extends MultiBrowserTest { int visibleIndexOfSpacer) { waitForDetailsVisible(); WebElement details = getDetailsElement(visibleIndexOfSpacer); - Assert.assertEquals("Wrong details row height", expectedHeight, + assertEquals("Wrong details row height", expectedHeight, details.getSize().getHeight()); } @@ -167,11 +169,10 @@ public class GridDetailsLocationTest extends MultiBrowserTest { visibleIndexOfDeco); GridRowElement rowElement = getGrid().getRow(row); - Assert.assertEquals( - "Details deco top position does not match row top pos", + assertEquals("Details deco top position does not match row top pos", rowElement.getLocation().getY(), detailsDecoElement.getLocation().getY()); - Assert.assertEquals( + assertEquals( "Details deco bottom position does not match details bottom pos", detailsElement.getLocation().getY() + detailsElement.getSize().getHeight(), @@ -180,7 +181,7 @@ public class GridDetailsLocationTest extends MultiBrowserTest { } private void verifyLocation(Param param) { - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(By.className("v-Notification"))); TestBenchElement headerRow = getGrid().getHeaderRow(0); @@ -205,11 +206,13 @@ public class GridDetailsLocationTest extends MultiBrowserTest { + bottomBoundary + " decoratorBotton:" + detailsBottom, detailsBottom, bottomBoundary); - verifyDetailsRowHeight(param.getRowIndex(), param.useGenerator() - ? detailsDefinedHeight : detailsDefaultHeight, 0); + verifyDetailsRowHeight(param.getRowIndex(), + param.useGenerator() ? detailsDefinedHeight + : detailsDefaultHeight, + 0); verifyDetailsDecoratorLocation(param.getRowIndex(), 0, 0); - Assert.assertFalse("Notification was present", + assertFalse("Notification was present", isElementPresent(By.className("v-Notification"))); } @@ -236,7 +239,8 @@ public class GridDetailsLocationTest extends MultiBrowserTest { WebElement detailsElement = getDetailsElement(); return detailsElement.isDisplayed() && detailsElement.getSize().getHeight() > 3 - ? detailsElement : null; + ? detailsElement + : null; } catch (StaleElementReferenceException e) { return null; } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridHeightTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridHeightTest.java index 7c99f2e836..02b65533a4 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridHeightTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridHeightTest.java @@ -18,12 +18,12 @@ package com.vaadin.v7.tests.components.grid; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.hamcrest.number.IsCloseTo.closeTo; +import static org.junit.Assert.fail; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; @@ -135,7 +135,7 @@ public class GridHeightTest extends MultiBrowserTest { } sb.append(entry.getKey().getMessage()); } - Assert.fail(sb.toString()); + fail(sb.toString()); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSpacerDecoClipTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSpacerDecoClipTest.java index 73046aea28..f2ad86a4e7 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSpacerDecoClipTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSpacerDecoClipTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.SearchContext; @@ -56,7 +58,7 @@ public class GridSpacerDecoClipTest extends MultiBrowserTest { nearToBottomRow.doubleClick(); deco = getSpacerDeco(0); System.out.println("Lower deco.clip = " + deco.getCssValue("clip")); - Assert.assertNotEquals( + assertNotEquals( "Spacer deco clipping is not updated after opening another spacer", "auto", deco.getCssValue("clip")); } @@ -85,7 +87,7 @@ public class GridSpacerDecoClipTest extends MultiBrowserTest { String clip = deco.getCssValue("clip"); System.out.println("deco.rect = " + clip); - Assert.assertTrue( + assertTrue( "Part of lower Row Details is visible, its deco clip height should be positive, but it is negative", clip.indexOf('-') < 0); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSubPixelProblemWrappingTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSubPixelProblemWrappingTest.java index 3a86c86ecb..77c72df1ae 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSubPixelProblemWrappingTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSubPixelProblemWrappingTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridRowElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -51,7 +52,7 @@ public class GridSubPixelProblemWrappingTest extends MultiBrowserTest { int cell0Top = grid.getCell(rowIndex, 0).getLocation().y; int cell1Top = grid.getCell(rowIndex, 1).getLocation().y; - Assert.assertEquals(rowTop, cell0Top); - Assert.assertEquals(rowTop, cell1Top); + assertEquals(rowTop, cell0Top); + assertEquals(rowTop, cell1Top); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSwitchRenderersTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSwitchRenderersTest.java index 41277df684..71fefad756 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSwitchRenderersTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridSwitchRenderersTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -37,8 +38,7 @@ public class GridSwitchRenderersTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); - Assert.assertTrue( - "Initial rendering of column 1 is not unformatted text", + assertTrue("Initial rendering of column 1 is not unformatted text", cellTextIsUnformatted(grid.getCell(0, 1).getText())); // NOTE: must click at 5,5 because of Valo and rendering in Chrome @@ -46,12 +46,12 @@ public class GridSwitchRenderersTest extends MultiBrowserTest { CheckBoxElement cb = $(CheckBoxElement.class).first(); cb.click(5, 5); - Assert.assertTrue( + assertTrue( "Column 1 data has not been rendered with HTMLRenderer after renderer swap", cellTextIsHTMLFormatted(grid.getCell(0, 1).getText())); cb.click(5, 5); - Assert.assertTrue( + assertTrue( "Column 1 data has not been re-rendered as text after renderer swap", cellTextIsUnformatted(grid.getCell(0, 1).getText())); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridThemeChangeTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridThemeChangeTest.java index f96f75a664..1e85ade046 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridThemeChangeTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridThemeChangeTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.grid; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.remote.DesiredCapabilities; @@ -47,7 +48,7 @@ public class GridThemeChangeTest extends MultiBrowserTest { grid = $(GridElement.class).first(); int valoHeight = grid.getRow(0).getSize().getHeight(); - Assert.assertTrue( + assertTrue( "Row height should increase when changing from Reindeer to Valo", valoHeight > reindeerHeight); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithBrokenRendererTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithBrokenRendererTest.java index 90619254f2..5e99ecb703 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithBrokenRendererTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithBrokenRendererTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -33,7 +34,7 @@ public class GridWithBrokenRendererTest extends SingleBrowserTest { private void assertRow(GridElement grid, int row, String... texts) { for (int column = 0; column < texts.length; column++) { - Assert.assertEquals("Cell " + row + "," + column, texts[column], + assertEquals("Cell " + row + "," + column, texts[column], grid.getCell(row, column).getText()); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithoutRendererTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithoutRendererTest.java index 5ed29705bb..4d4cbafce1 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithoutRendererTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridWithoutRendererTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.grid; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -36,7 +37,7 @@ public class GridWithoutRendererTest extends SingleBrowserTest { // System.out.println(errorIndicator); List<WebElement> errorIndicator = findElements( By.xpath("//span[@class='v-errorindicator']")); - Assert.assertTrue("There should not be an error indicator", + assertTrue("There should not be an error indicator", errorIndicator.isEmpty()); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitiallyDisabledGridTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitiallyDisabledGridTest.java index cf23a7f379..6a4c361cbf 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitiallyDisabledGridTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/InitiallyDisabledGridTest.java @@ -1,6 +1,8 @@ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -17,8 +19,8 @@ public class InitiallyDisabledGridTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); GridCellElement col0 = grid.getCell(0, 0); GridCellElement col1 = grid.getCell(0, 1); - Assert.assertTrue(col0.getSize().getWidth() > 250); - Assert.assertTrue(col1.getSize().getWidth() > 250); + assertTrue(col0.getSize().getWidth() > 250); + assertTrue(col1.getSize().getWidth() > 250); } @Test @@ -29,6 +31,6 @@ public class InitiallyDisabledGridTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); grid.scrollToRow(80); GridCellElement col0 = grid.getCell(80, 0); - Assert.assertEquals("First 80", col0.getText()); + assertEquals("First 80", col0.getText()); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/JavaScriptRenderersTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/JavaScriptRenderersTest.java index 687c02b068..88d68d2b54 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/JavaScriptRenderersTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/JavaScriptRenderersTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -37,16 +39,15 @@ public class JavaScriptRenderersTest extends MultiBrowserTest { GridCellElement cell_2_2 = grid.getCell(2, 2); // Verify render functionality - Assert.assertEquals("Bean(2, 0)", cell_1_1.getText()); + assertEquals("Bean(2, 0)", cell_1_1.getText()); - Assert.assertEquals("string2", cell_2_2.getText()); + assertEquals("string2", cell_2_2.getText()); // Verify init functionality - Assert.assertEquals("1", cell_1_1.getAttribute("column")); + assertEquals("1", cell_1_1.getAttribute("column")); // Verify onbrowserevent cell_1_1.click(); - Assert.assertTrue( - cell_1_1.getText().startsWith("Clicked 1 with key 2 at")); + assertTrue(cell_1_1.getText().startsWith("Clicked 1 with key 2 at")); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullHeadersTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullHeadersTest.java index 9e438b6d07..46227f325b 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullHeadersTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/NullHeadersTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -29,10 +30,10 @@ public class NullHeadersTest extends SingleBrowserTest { GridElement grid = $(GridElement.class).first(); - Assert.assertEquals(1, grid.getHeaderCount()); - Assert.assertEquals(3, grid.getHeaderCells(0).size()); + assertEquals(1, grid.getHeaderCount()); + assertEquals(3, grid.getHeaderCells(0).size()); for (int i = 0; i < 3; i++) { - Assert.assertEquals("", grid.getHeaderCell(0, 0).getText()); + assertEquals("", grid.getHeaderCell(0, 0).getText()); } assertRow(grid, 0, "Finland", "foo", "1"); assertRow(grid, 1, "Swaziland", "bar", "2"); @@ -41,8 +42,7 @@ public class NullHeadersTest extends SingleBrowserTest { private void assertRow(GridElement grid, int row, String... contents) { for (int col = 0; col < contents.length; col++) { - Assert.assertEquals(contents[col], - grid.getCell(row, col).getText()); + assertEquals(contents[col], grid.getCell(row, col).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/ProgrammaticEditorControlTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/ProgrammaticEditorControlTest.java index 17ec4d393e..f37dfd198e 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/ProgrammaticEditorControlTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/ProgrammaticEditorControlTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + import org.junit.Test; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.SingleBrowserTest; @@ -49,13 +51,13 @@ public class ProgrammaticEditorControlTest extends SingleBrowserTest { private void assertEditorFieldContents(GridElement grid, String text) { TextFieldElement editorField = wrap(TextFieldElement.class, grid.getEditor().getField(0)); - Assert.assertEquals(text, editorField.getValue()); + assertEquals(text, editorField.getValue()); } private void assertEditorNotPresent(GridElement grid) { try { grid.getEditor(); - Assert.fail("Editor should not be present"); + fail("Editor should not be present"); } catch (Exception e) { } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/RemoveHiddenColumnTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/RemoveHiddenColumnTest.java index ecb5285401..730dc16650 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/RemoveHiddenColumnTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/RemoveHiddenColumnTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.ButtonElement; @@ -26,18 +27,17 @@ public class RemoveHiddenColumnTest extends SingleBrowserTest { private void removeColumns() { ButtonElement remove = $(ButtonElement.class).id("remove"); remove.click(); - Assert.assertEquals("1. Removed column 'First Name' (hidden)", - getLogRow(0)); + assertEquals("1. Removed column 'First Name' (hidden)", getLogRow(0)); assertNoErrorNotifications(); remove.click(); - Assert.assertEquals("2. Removed column 'Last Name'", getLogRow(0)); + assertEquals("2. Removed column 'Last Name'", getLogRow(0)); assertNoErrorNotifications(); remove.click(); - Assert.assertEquals("3. Removed column 'Email' (hidden)", getLogRow(0)); + assertEquals("3. Removed column 'Email' (hidden)", getLogRow(0)); assertNoErrorNotifications(); remove.click(); - Assert.assertEquals("4. Removed column 'Age'", getLogRow(0)); + assertEquals("4. Removed column 'Age'", getLogRow(0)); assertNoErrorNotifications(); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/SortableHeaderStylesTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/SortableHeaderStylesTest.java index 1c419d41bb..052ccda425 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/SortableHeaderStylesTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/SortableHeaderStylesTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.components.grid; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; @@ -27,9 +29,9 @@ public class SortableHeaderStylesTest extends SingleBrowserTest { public void testSortableHeaderStyles() { openTestURL(); - Assert.assertFalse(hasSortableStyle(0)); + assertFalse(hasSortableStyle(0)); for (int i = 1; i < 8; i++) { - Assert.assertTrue(hasSortableStyle(i)); + assertTrue(hasSortableStyle(i)); } OptionGroupElement sortableSelector = $(OptionGroupElement.class) @@ -37,11 +39,11 @@ public class SortableHeaderStylesTest extends SingleBrowserTest { // Toggle sortability sortableSelector.selectByText("lastName"); - Assert.assertFalse(hasSortableStyle(3)); + assertFalse(hasSortableStyle(3)); // Toggle back sortableSelector.selectByText("lastName"); - Assert.assertTrue(hasSortableStyle(3)); + assertTrue(hasSortableStyle(3)); } private boolean hasSortableStyle(int column) { diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnHidingTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnHidingTest.java index f038aa165b..6531acb993 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnHidingTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnHidingTest.java @@ -827,19 +827,19 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest { selectMenuPath("Component", "Row details", "Toggle details for...", "Row 1"); assertColumnHeaderOrder(0, 1, 2, 3, 4); - Assert.assertNotNull("Details not found", + assertNotNull("Details not found", getGridElement().getDetails(1)); toggleHideColumnAPI(0); assertColumnHeaderOrder(1, 2, 3, 4); - Assert.assertNotNull("Details not found", + assertNotNull("Details not found", getGridElement().getDetails(1)); toggleHideColumnAPI(0); assertColumnHeaderOrder(0, 1, 2, 3, 4); - Assert.assertNotNull("Details not found", + assertNotNull("Details not found", getGridElement().getDetails(1)); } @@ -884,16 +884,16 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest { toggleHideColumnAPI(1); getGridElement().scrollToRow(500); - Assert.assertEquals("(500, 0)", + assertEquals("(500, 0)", getGridElement().getCell(500, 0).getText()); - Assert.assertEquals("(500, 2)", + assertEquals("(500, 2)", getGridElement().getCell(500, 1).getText()); toggleHideColumnAPI(1); - Assert.assertEquals("(500, 0)", + assertEquals("(500, 0)", getGridElement().getCell(500, 0).getText()); - Assert.assertEquals("(500, 1)", + assertEquals("(500, 1)", getGridElement().getCell(500, 1).getText()); } @@ -902,25 +902,25 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest { toggleHidableColumnAPI(0); toggleHidableColumnAPI(1); - Assert.assertEquals("(500, 0)", + assertEquals("(500, 0)", getGridElement().getCell(500, 0).getText()); - Assert.assertEquals("(500, 1)", + assertEquals("(500, 1)", getGridElement().getCell(500, 1).getText()); toggleHideColumnAPI(0); toggleHideColumnAPI(1); - Assert.assertEquals("(500, 2)", + assertEquals("(500, 2)", getGridElement().getCell(500, 0).getText()); - Assert.assertEquals("(500, 3)", + assertEquals("(500, 3)", getGridElement().getCell(500, 1).getText()); toggleHideColumnAPI(0); toggleHideColumnAPI(1); - Assert.assertEquals("(500, 0)", + assertEquals("(500, 0)", getGridElement().getCell(500, 0).getText()); - Assert.assertEquals("(500, 1)", + assertEquals("(500, 1)", getGridElement().getCell(500, 1).getText()); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java index db10556069..db7be31eab 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.grid.basicfeatures; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -73,7 +74,7 @@ public class GridColumnResizeModeTest extends GridBasicFeaturesTest { // See that we got a resize event sleep(500); - Assert.assertEquals("Log shows resize event", getLogRow(0), + assertEquals("Log shows resize event", getLogRow(0), "3. ColumnResizeEvent: isUserOriginated? true"); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridCellStyleGeneratorTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridCellStyleGeneratorTest.java index 2168d92074..50768df867 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridCellStyleGeneratorTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridCellStyleGeneratorTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.components.grid.basicfeatures.client; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement.GridCellElement; @@ -37,16 +39,16 @@ public class GridCellStyleGeneratorTest extends GridBasicClientFeaturesTest { GridRowElement row2 = getGridElement().getRow(2); GridCellElement cell4_2 = getGridElement().getCell(4, 2); - Assert.assertTrue(hasCssClass(row2, "2")); - Assert.assertTrue(hasCssClass(cell4_2, "4_2")); + assertTrue(hasCssClass(row2, "2")); + assertTrue(hasCssClass(cell4_2, "4_2")); // Scroll down and verify that the old elements don't have the // stylename any more getGridElement().getRow(350); - Assert.assertFalse(hasCssClass(row2, "2")); - Assert.assertFalse(hasCssClass(cell4_2, "4_2")); + assertFalse(hasCssClass(row2, "2")); + assertFalse(hasCssClass(cell4_2, "4_2")); } @Test @@ -62,8 +64,8 @@ public class GridCellStyleGeneratorTest extends GridBasicClientFeaturesTest { GridRowElement row2 = getGridElement().getRow(2); GridCellElement cell4_2 = getGridElement().getCell(4, 2); - Assert.assertTrue(hasCssClass(row2, "2")); - Assert.assertTrue(hasCssClass(cell4_2, "4_2")); + assertTrue(hasCssClass(row2, "2")); + assertTrue(hasCssClass(cell4_2, "4_2")); // Disable the generator and check again selectCellStyleNameGenerator( @@ -71,8 +73,8 @@ public class GridCellStyleGeneratorTest extends GridBasicClientFeaturesTest { selectRowStyleNameGenerator( GridBasicClientFeaturesWidget.ROW_STYLE_GENERATOR_NONE); - Assert.assertFalse(hasCssClass(row2, "2")); - Assert.assertFalse(hasCssClass(cell4_2, "4_2")); + assertFalse(hasCssClass(row2, "2")); + assertFalse(hasCssClass(cell4_2, "4_2")); } @Test @@ -88,8 +90,8 @@ public class GridCellStyleGeneratorTest extends GridBasicClientFeaturesTest { GridRowElement row2 = getGridElement().getRow(2); GridCellElement cell4_2 = getGridElement().getCell(4, 2); - Assert.assertTrue(hasCssClass(row2, "2")); - Assert.assertTrue(hasCssClass(cell4_2, "4_2")); + assertTrue(hasCssClass(row2, "2")); + assertTrue(hasCssClass(cell4_2, "4_2")); // Change the generator and check again selectRowStyleNameGenerator( @@ -98,11 +100,11 @@ public class GridCellStyleGeneratorTest extends GridBasicClientFeaturesTest { GridBasicClientFeaturesWidget.CELL_STYLE_GENERATOR_SIMPLE); // Old styles removed? - Assert.assertFalse(hasCssClass(row2, "2")); - Assert.assertFalse(hasCssClass(cell4_2, "4_2")); + assertFalse(hasCssClass(row2, "2")); + assertFalse(hasCssClass(cell4_2, "4_2")); // New style present? - Assert.assertTrue(hasCssClass(cell4_2, "two")); + assertTrue(hasCssClass(cell4_2, "two")); } @Test @@ -118,21 +120,20 @@ public class GridCellStyleGeneratorTest extends GridBasicClientFeaturesTest { GridRowElement row2 = getGridElement().getRow(2); GridCellElement cell4_2 = getGridElement().getCell(4, 2); - Assert.assertTrue(hasCssClass(row2, "2")); - Assert.assertTrue(hasCssClass(cell4_2, "4_2")); + assertTrue(hasCssClass(row2, "2")); + assertTrue(hasCssClass(cell4_2, "4_2")); // Change primary stylename selectMenuPath("Component", "State", "Primary Stylename", "v-escalator"); // Styles still present - Assert.assertTrue(hasCssClass(row2, "2")); - Assert.assertTrue(hasCssClass(cell4_2, "4_2")); + assertTrue(hasCssClass(row2, "2")); + assertTrue(hasCssClass(cell4_2, "4_2")); // New styles present? - Assert.assertFalse(hasCssClass(row2, "v-escalator-row-2")); - Assert.assertFalse( - hasCssClass(cell4_2, "v-escalator-cell-content-4_2")); + assertFalse(hasCssClass(row2, "v-escalator-row-2")); + assertFalse(hasCssClass(cell4_2, "v-escalator-cell-content-4_2")); } private void selectCellStyleNameGenerator(String name) { diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java index 0321159bcd..58a97c4946 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java @@ -16,13 +16,13 @@ package com.vaadin.v7.tests.components.grid.basicfeatures.client; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Keys; import org.openqa.selenium.interactions.Actions; @@ -99,23 +99,23 @@ public class GridClientKeyEventsTest extends GridBasicClientFeaturesTest { // Focus cell above select all checkbox getGridElement().getHeaderCell(0, 0).click(); - Assert.assertFalse(isRowSelected(1)); + assertFalse(isRowSelected(1)); new Actions(getDriver()).sendKeys(" ").perform(); - Assert.assertFalse(isRowSelected(1)); + assertFalse(isRowSelected(1)); // Move down to select all checkbox cell new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform(); - Assert.assertFalse(isRowSelected(1)); + assertFalse(isRowSelected(1)); new Actions(getDriver()).sendKeys(" ").perform(); // select all - Assert.assertTrue(isRowSelected(1)); + assertTrue(isRowSelected(1)); new Actions(getDriver()).sendKeys(" ").perform(); // deselect all - Assert.assertFalse(isRowSelected(1)); + assertFalse(isRowSelected(1)); // Move down to header below select all checkbox cell new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform(); - Assert.assertFalse(isRowSelected(1)); + assertFalse(isRowSelected(1)); new Actions(getDriver()).sendKeys(" ").perform(); // deselect all - Assert.assertFalse(isRowSelected(1)); + assertFalse(isRowSelected(1)); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridSidebarContentTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridSidebarContentTest.java index 1d4ef1f171..9882752d60 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridSidebarContentTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/client/GridSidebarContentTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.grid.basicfeatures.client; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -31,7 +32,7 @@ public class GridSidebarContentTest extends GridBasicClientFeaturesTest { public void testSidebarWithHidableColumn() { openTestURL(); - Assert.assertEquals("Sidebar should not be initially present", 0, + assertEquals("Sidebar should not be initially present", 0, countBySelector(".v-grid-sidebar-button")); selectMenuPath("Component", "Columns", "Column 0", "Hidable"); @@ -41,12 +42,12 @@ public class GridSidebarContentTest extends GridBasicClientFeaturesTest { WebElement toggle = getSidebarPopup() .findElement(By.className("column-hiding-toggle")); - Assert.assertEquals("Column 0 should be togglable", "Header (0,0)", + assertEquals("Column 0 should be togglable", "Header (0,0)", toggle.getText()); selectMenuPath("Component", "Columns", "Column 0", "Hidable"); - Assert.assertEquals("Sidebar should disappear without toggable column", - 0, countBySelector(".v-grid-sidebar-button")); + assertEquals("Sidebar should disappear without toggable column", 0, + countBySelector(".v-grid-sidebar-button")); } @@ -64,7 +65,7 @@ public class GridSidebarContentTest extends GridBasicClientFeaturesTest { sidebarItem.click(); - Assert.assertEquals("Sidebar should be closed after clicking item 0", 0, + assertEquals("Sidebar should be closed after clicking item 0", 0, countBySelector(".v-grid-sidebar-content")); } @@ -76,7 +77,7 @@ public class GridSidebarContentTest extends GridBasicClientFeaturesTest { selectMenuPath("Component", "Sidebar", "Toggle sidebar visibility"); - Assert.assertEquals("Sidebar should be open", 1, + assertEquals("Sidebar should be open", 1, countBySelector(".v-grid-sidebar-content")); } @@ -125,18 +126,18 @@ public class GridSidebarContentTest extends GridBasicClientFeaturesTest { List<WebElement> menuItems = getSidebarPopup() .findElements(By.cssSelector(".v-grid-sidebar-content td")); - Assert.assertEquals("Expected " + items.length + " menu items", - items.length, menuItems.size()); + assertEquals("Expected " + items.length + " menu items", items.length, + menuItems.size()); for (int i = 0; i < items.length; i++) { String expectedItem = items[i]; if (expectedItem == null) { - Assert.assertEquals("Item " + i + " should be a separator", + assertEquals("Item " + i + " should be a separator", "gwt-MenuItemSeparator", menuItems.get(i).getAttribute("class")); } else { - Assert.assertEquals("Unexpected content for item " + i, - expectedItem, menuItems.get(i).getText()); + assertEquals("Unexpected content for item " + i, expectedItem, + menuItems.get(i).getText()); } } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java index 5d1d99c426..74a2950aeb 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java @@ -16,8 +16,8 @@ package com.vaadin.v7.tests.components.grid.basicfeatures.server; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import org.junit.Assert; import org.junit.Test; import com.vaadin.testbench.elements.GridElement.GridCellElement; @@ -39,8 +39,8 @@ public class GridCellStyleGeneratorTest extends GridBasicFeaturesTest { GridRowElement row = getGridElement().getRow(2); GridCellElement cell = getGridElement().getCell(3, 2); - Assert.assertTrue(hasCssClass(row, "row2")); - Assert.assertTrue(hasCssClass(cell, "Column_2")); + assertTrue(hasCssClass(row, "row2")); + assertTrue(hasCssClass(cell, "Column_2")); // Scroll down and verify that the old elements don't have the // stylename any more @@ -49,8 +49,8 @@ public class GridCellStyleGeneratorTest extends GridBasicFeaturesTest { row = getGridElement().getRow(352); cell = getGridElement().getCell(353, 2); - Assert.assertFalse(hasCssClass(row, "row352")); - Assert.assertFalse(hasCssClass(cell, "Column_2")); + assertFalse(hasCssClass(row, "row352")); + assertFalse(hasCssClass(cell, "Column_2")); } @Test @@ -66,16 +66,16 @@ public class GridCellStyleGeneratorTest extends GridBasicFeaturesTest { GridRowElement row2 = getGridElement().getRow(2); GridCellElement cell3_2 = getGridElement().getCell(3, 2); - Assert.assertTrue(hasCssClass(row2, "row2")); - Assert.assertTrue(hasCssClass(cell3_2, "Column_2")); + assertTrue(hasCssClass(row2, "row2")); + assertTrue(hasCssClass(cell3_2, "Column_2")); // Disable the generator and check again selectRowStyleNameGenerator(GridBasicFeatures.ROW_STYLE_GENERATOR_NONE); selectCellStyleNameGenerator( GridBasicFeatures.CELL_STYLE_GENERATOR_NONE); - Assert.assertFalse(hasCssClass(row2, "row2")); - Assert.assertFalse(hasCssClass(cell3_2, "Column_2")); + assertFalse(hasCssClass(row2, "row2")); + assertFalse(hasCssClass(cell3_2, "Column_2")); } @Test @@ -91,8 +91,8 @@ public class GridCellStyleGeneratorTest extends GridBasicFeaturesTest { GridRowElement row2 = getGridElement().getRow(2); GridCellElement cell3_2 = getGridElement().getCell(3, 2); - Assert.assertTrue(hasCssClass(row2, "row2")); - Assert.assertTrue(hasCssClass(cell3_2, "Column_2")); + assertTrue(hasCssClass(row2, "row2")); + assertTrue(hasCssClass(cell3_2, "Column_2")); // Change the generator and check again selectRowStyleNameGenerator(GridBasicFeatures.ROW_STYLE_GENERATOR_NONE); @@ -100,11 +100,11 @@ public class GridCellStyleGeneratorTest extends GridBasicFeaturesTest { GridBasicFeatures.CELL_STYLE_GENERATOR_PROPERTY_TO_STRING); // Old styles removed? - Assert.assertFalse(hasCssClass(row2, "row2")); - Assert.assertFalse(hasCssClass(cell3_2, "Column_2")); + assertFalse(hasCssClass(row2, "row2")); + assertFalse(hasCssClass(cell3_2, "Column_2")); // New style present? - Assert.assertTrue(hasCssClass(cell3_2, "Column-2")); + assertTrue(hasCssClass(cell3_2, "Column-2")); } @Test diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridClearContainerTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridClearContainerTest.java index 49f7321cf3..21f13f3c76 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridClearContainerTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridClearContainerTest.java @@ -15,11 +15,12 @@ */ package com.vaadin.v7.tests.components.grid.basicfeatures.server; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -40,12 +41,12 @@ public class GridClearContainerTest extends MultiBrowserTest { ButtonElement button = $(ButtonElement.class) .caption("Clear and re-add").first(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals(ERRORNOTE, "default", grid.getCell(0, 0).getText()); - Assert.assertEquals(ERRORNOTE, "default", grid.getCell(1, 0).getText()); + assertEquals(ERRORNOTE, "default", grid.getCell(0, 0).getText()); + assertEquals(ERRORNOTE, "default", grid.getCell(1, 0).getText()); button.click(); - Assert.assertEquals(ERRORNOTE, "Updated value 1", + assertEquals(ERRORNOTE, "Updated value 1", grid.getCell(0, 0).getText()); - Assert.assertEquals(ERRORNOTE, "Updated value 2", + assertEquals(ERRORNOTE, "Updated value 2", grid.getCell(1, 0).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java index f02c88f0e8..c27afc4fd0 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java @@ -322,7 +322,7 @@ public class GridColumnVisibilityTest extends GridBasicFeaturesTest { getColumnHidingToggle(3).click(); // Make sure that the new column contains the data it should - Assert.assertEquals("(999, 3)", + assertEquals("(999, 3)", getGridElement().getCell(999, 3).getText()); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java index fd56fbf2f2..b6c6a69c91 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridRowAddRemoveTest.java @@ -15,7 +15,9 @@ */ package com.vaadin.v7.tests.components.grid.basicfeatures.server; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import com.vaadin.testbench.elements.NotificationElement; @@ -32,8 +34,7 @@ public class GridRowAddRemoveTest extends GridBasicFeaturesTest { selectMenuPath("Component", "Body rows", "Remove all rows"); selectMenuPath("Component", "Body rows", "Add 18 rows"); - Assert.assertTrue( - "All added rows should be fetched in the same round trip.", + assertTrue("All added rows should be fetched in the same round trip.", logContainsText("Requested items 0 - 18")); } @@ -45,7 +46,7 @@ public class GridRowAddRemoveTest extends GridBasicFeaturesTest { selectMenuPath("Settings", "Clear log"); selectMenuPath("Component", "Body rows", "Add 18 rows"); - Assert.assertFalse("An error notification is present.", + assertFalse("An error notification is present.", isElementPresent(NotificationElement.class)); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java index 93aaa8a86a..fe0adfa112 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/LoadingIndicatorTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.components.grid.basicfeatures.server; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -35,7 +36,7 @@ public class LoadingIndicatorTest extends GridBasicFeaturesTest { GridElement gridElement = $(GridElement.class).first(); - Assert.assertFalse( + assertFalse( "Loading indicator should not be visible before disabling waitForVaadin", isLoadingIndicatorVisible()); @@ -58,7 +59,7 @@ public class LoadingIndicatorTest extends GridBasicFeaturesTest { // Wait for potentially triggered loading indicator to become visible Thread.sleep(500); - Assert.assertFalse( + assertFalse( "Loading indicator should not be visible when fetching rows that are not visible", isLoadingIndicatorVisible()); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java index 2ddb68988e..bb880826c7 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.components.nativeselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.NativeSelectElement; @@ -12,8 +13,8 @@ public class NativeSelectNullTest extends SingleBrowserTestPhantomJS2 { openTestURL(); NativeSelectElement select = $(NativeSelectElement.class).first(); select.selectByText("Item"); - Assert.assertEquals("1. Value: Item", getLogRow(0)); + assertEquals("1. Value: Item", getLogRow(0)); select.selectByText(""); - Assert.assertEquals("2. Value: null", getLogRow(0)); + assertEquals("2. Value: null", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java index e6588b9aa5..6ea390c82c 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.nativeselect; +import static org.junit.Assert.assertTrue; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -55,9 +56,9 @@ public class NativeSelectsAndChromeKeyboardNavigationTest String bodytext = getDriver().findElement(By.tagName("body")).getText(); - Assert.assertTrue(bodytext.contains("new value: 'Item 1'")); - Assert.assertTrue(bodytext.contains("new value: 'Item 2'")); - Assert.assertTrue(bodytext.contains("new value: 'Item 3'")); + assertTrue(bodytext.contains("new value: 'Item 1'")); + assertTrue(bodytext.contains("new value: 'Item 2'")); + assertTrue(bodytext.contains("new value: 'Item 3'")); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java index a9e7d1b624..fb5d09012c 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.components.nativeselect; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.interactions.Actions; @@ -49,11 +50,11 @@ public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest { // Chrome/PhantomJS if (BrowserUtil.isChrome(getDesiredCapabilities()) || BrowserUtil.isPhantomJS(getDesiredCapabilities())) { - Assert.assertEquals("4. FocusEvent", getLogRow(1)); - Assert.assertEquals("5. BlurEvent", getLogRow(0)); + assertEquals("4. FocusEvent", getLogRow(1)); + assertEquals("5. BlurEvent", getLogRow(0)); } else { - Assert.assertEquals("2. FocusEvent", getLogRow(1)); - Assert.assertEquals("3. BlurEvent", getLogRow(0)); + assertEquals("2. FocusEvent", getLogRow(1)); + assertEquals("3. BlurEvent", getLogRow(0)); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/textfield/TextChangeEventsTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/textfield/TextChangeEventsTest.java index 3efb8b8369..47cc3c1a26 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/textfield/TextChangeEventsTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/textfield/TextChangeEventsTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.components.textfield; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import com.vaadin.testbench.elements.TextAreaElement; @@ -16,14 +17,14 @@ public class TextChangeEventsTest extends SingleBrowserTest { TextAreaElement taDefault = $(TextAreaElement.class) .caption("Default text area").first(); taDefault.sendKeys("abc"); - Assert.assertEquals( + assertEquals( "1. Text change event for Default text area, text content currently:'abc' Cursor at index:3", getLogRow(0)); TextAreaElement taTimeout = $(TextAreaElement.class) .caption("Timeout 3s").first(); taTimeout.sendKeys("abc"); - Assert.assertEquals( + assertEquals( "2. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3", getLogRow(0)); @@ -36,21 +37,21 @@ public class TextChangeEventsTest extends SingleBrowserTest { TextFieldElement tfDefault = $(TextFieldElement.class) .caption("Default").first(); tfDefault.sendKeys("abc"); - Assert.assertEquals( + assertEquals( "1. Text change event for Default, text content currently:'abc' Cursor at index:3", getLogRow(0)); TextFieldElement tfEager = $(TextFieldElement.class).caption("Eager") .first(); tfEager.sendKeys("abc"); - Assert.assertEquals( + assertEquals( "2. Text change event for Eager, text content currently:'abc' Cursor at index:3", getLogRow(0)); TextFieldElement tfTimeout = $(TextFieldElement.class) .caption("Timeout 3s").first(); tfTimeout.sendKeys("abc"); - Assert.assertEquals( + assertEquals( "3. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3", getLogRow(0)); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeContextMenuAndIconsTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeContextMenuAndIconsTest.java index c404066473..11ab9f7018 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeContextMenuAndIconsTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeContextMenuAndIconsTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.tree; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; @@ -26,7 +27,6 @@ import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; -import com.vaadin.v7.tests.components.tree.Trees; public class TreeContextMenuAndIconsTest extends MultiBrowserTest { @@ -84,7 +84,7 @@ public class TreeContextMenuAndIconsTest extends MultiBrowserTest { // background image contains parts of other sprites => // just check that the menu is of correct size Dimension size = menu.getSize(); - Assert.assertEquals("Menu height with large icons", 74, size.height); + assertEquals("Menu height with large icons", 74, size.height); closeContextMenu(); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeHtmlContentAllowedTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeHtmlContentAllowedTest.java index e0a5cb766b..211253e1df 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeHtmlContentAllowedTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeHtmlContentAllowedTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.v7.tests.components.tree; +import static org.junit.Assert.assertEquals; + import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -33,8 +34,8 @@ public class TreeHtmlContentAllowedTest extends SingleBrowserTest { openTestURL(); CheckBoxElement toggle = $(CheckBoxElement.class).first(); - Assert.assertEquals("HTML content should be disabled by default", - "unchecked", toggle.getValue()); + assertEquals("HTML content should be disabled by default", "unchecked", + toggle.getValue()); // Markup is seen as plain text assertTreeCaptionTexts("Just text", "Some <b>html</b>", @@ -62,7 +63,7 @@ public class TreeHtmlContentAllowedTest extends SingleBrowserTest { private void assertHtmlElementSelected() { TreeElement tree = $(TreeElement.class).first(); - Assert.assertEquals(tree.getValue(), "Child element html"); + assertEquals(tree.getValue(), "Child element html"); } private void assertTreeCaptionTexts(String... captions) { @@ -70,9 +71,9 @@ public class TreeHtmlContentAllowedTest extends SingleBrowserTest { List<WebElement> nodes = tree .findElements(By.className("v-tree-node-caption")); - Assert.assertEquals(captions.length, nodes.size()); + assertEquals(captions.length, nodes.size()); for (int i = 0; i < captions.length; i++) { - Assert.assertEquals(captions[i], nodes.get(i).getText()); + assertEquals(captions[i], nodes.get(i).getText()); } } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeKeyboardNavigationToNoneTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeKeyboardNavigationToNoneTest.java index 8e84096aae..13dce2eb04 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeKeyboardNavigationToNoneTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/tree/TreeKeyboardNavigationToNoneTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.v7.tests.components.tree; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -53,7 +54,7 @@ public class TreeKeyboardNavigationToNoneTest extends MultiBrowserTest { } private void checkNotificationErrorAbsence(String item) { - Assert.assertFalse( + assertFalse( "Notification is found after using keyboard for navigation " + "from " + item + " tree item", isElementPresent(By.className("v-Notification"))); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java index d0bd71c590..f5563c3e55 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/upload/TestFileUploadTest.java @@ -15,6 +15,8 @@ */ package com.vaadin.v7.tests.components.upload; +import static org.junit.Assert.assertEquals; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -24,7 +26,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.List; -import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -59,7 +60,7 @@ public class TestFileUploadTest extends MultiBrowserTest { md5(getTempFileContents())); String actual = getLogRow(0); - Assert.assertEquals("Upload log row does not match expected", expected, + assertEquals("Upload log row does not match expected", expected, actual); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/window/UndefinedHeightSubWindowAndContentTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/window/UndefinedHeightSubWindowAndContentTest.java index 2e371c2c13..d9373993c9 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/window/UndefinedHeightSubWindowAndContentTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/window/UndefinedHeightSubWindowAndContentTest.java @@ -1,11 +1,12 @@ package com.vaadin.v7.tests.components.window; -import org.junit.Assert; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Keys; -import com.vaadin.testbench.elements.WindowElement; import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.elements.WindowElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class UndefinedHeightSubWindowAndContentTest extends MultiBrowserTest { @@ -21,13 +22,13 @@ public class UndefinedHeightSubWindowAndContentTest extends MultiBrowserTest { WindowElement window = $(WindowElement.class).first(); int height = window.getSize().getHeight(); - Assert.assertTrue("Window height with validation failure", + assertTrue("Window height with validation failure", 161 <= height && height <= 164); textField.setValue("valid"); textField.sendKeys(Keys.ENTER); height = window.getSize().getHeight(); - Assert.assertTrue("Window height with validation success", + assertTrue("Window height with validation success", 136 <= height && height <= 139); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/core/SpecialCharactersEncodingUITest.java b/uitest/src/test/java/com/vaadin/v7/tests/core/SpecialCharactersEncodingUITest.java index 59d09c8423..1c732ad7a3 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/core/SpecialCharactersEncodingUITest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/core/SpecialCharactersEncodingUITest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.core; -import org.junit.Assert; +import static org.junit.Assert.assertEquals; + import org.junit.Test; import org.openqa.selenium.WebElement; @@ -17,17 +18,15 @@ public class SpecialCharactersEncodingUITest extends SingleBrowserTest { openTestURL(); String textFieldValue = $(TextFieldElement.class).id("textfield") .getValue(); - Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, - textFieldValue); + assertEquals(SpecialCharactersEncodingUI.textWithZwnj, textFieldValue); LabelElement label = $(LabelElement.class).id("label"); String labelValue = getHtml(label); // getText() strips some characters - Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, - labelValue); + assertEquals(SpecialCharactersEncodingUI.textWithZwnj, labelValue); MenuBarElement menubar = $(MenuBarElement.class).first(); WebElement menuItem = menubar .findElement(By.className("v-menubar-menuitem-caption")); - Assert.assertEquals(SpecialCharactersEncodingUI.textWithZwnj, + assertEquals(SpecialCharactersEncodingUI.textWithZwnj, getHtml(menuItem)); } |