diff --git a/java/client/test/org/openqa/selenium/ElementAttributeTest.java b/java/client/test/org/openqa/selenium/ElementAttributeTest.java index ae7bf2ae1622e..4de97ab180f79 100644 --- a/java/client/test/org/openqa/selenium/ElementAttributeTest.java +++ b/java/client/test/org/openqa/selenium/ElementAttributeTest.java @@ -280,7 +280,6 @@ public void testShouldCorrectlyReportValueOfColspan() { } // This is a test-case re-creating issue 900. - @SuppressWarnings("unchecked") @Ignore(SELENESE) @Test public void testShouldReturnValueOfOnClickAttribute() { diff --git a/java/client/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java b/java/client/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java index d4f91b8d864f0..32953f1ecba05 100644 --- a/java/client/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java +++ b/java/client/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java @@ -97,7 +97,7 @@ public void shouldBeAbleToReturnAnArrayLiteralFromAnAsyncScript() { Object result = executor.executeAsyncScript("arguments[arguments.length - 1]([]);"); assertNotNull("Expected not to be null!", result); assertThat(result, instanceOf(List.class)); - assertTrue(((List) result).isEmpty()); + assertTrue(((List) result).isEmpty()); } @JavascriptEnabled @@ -108,7 +108,7 @@ public void shouldBeAbleToReturnAnArrayObjectFromAnAsyncScript() { Object result = executor.executeAsyncScript("arguments[arguments.length - 1](new Array());"); assertNotNull("Expected not to be null!", result); assertThat(result, instanceOf(List.class)); - assertTrue(((List) result).isEmpty()); + assertTrue(((List) result).isEmpty()); } @JavascriptEnabled @@ -124,7 +124,7 @@ public void shouldBeAbleToReturnArraysOfPrimitivesFromAsyncScripts() { assertNotNull(result); assertThat(result, instanceOf(List.class)); - Iterator results = ((List) result).iterator(); + Iterator results = ((List) result).iterator(); assertNull(results.next()); assertEquals(123, ((Number) results.next()).longValue()); assertEquals("abc", results.next()); @@ -155,7 +155,7 @@ public void shouldBeAbleToReturnArraysOfWebElementsFromAsyncScripts() { assertNotNull(result); assertThat(result, instanceOf(List.class)); - List list = (List) result; + List list = (List) result; assertEquals(2, list.size()); assertThat(list.get(0), instanceOf(WebElement.class)); assertThat(list.get(1), instanceOf(WebElement.class)); diff --git a/java/client/test/org/openqa/selenium/environment/GlobalTestEnvironment.java b/java/client/test/org/openqa/selenium/environment/GlobalTestEnvironment.java index a844832ec34d8..24f25689c3ef5 100644 --- a/java/client/test/org/openqa/selenium/environment/GlobalTestEnvironment.java +++ b/java/client/test/org/openqa/selenium/environment/GlobalTestEnvironment.java @@ -36,6 +36,7 @@ public static void set(TestEnvironment environment) { GlobalTestEnvironment.environment = environment; } + @SuppressWarnings("unchecked") public static synchronized T get( Class startThisIfNothingIsAlreadyRunning) { if (environment == null) { diff --git a/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java b/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java index aea583c420707..b05542217d65e 100644 --- a/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java +++ b/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java @@ -295,6 +295,7 @@ public void testMovingIntoAnImageEnclosedInALink() { waitFor(pageTitleToBe(driver, "We Arrive Here")); } + @SuppressWarnings("unchecked") private Map getElementSize(WebElement element) { return (Map) ((JavascriptExecutor) driver).executeScript( "return arguments[0].getBoundingClientRect()", element); diff --git a/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java b/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java index c18118a68773b..740403da22d84 100644 --- a/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java +++ b/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java @@ -107,10 +107,10 @@ public void testShouldConvertCollections() throws Exception { public void testShouldConvertNumbersAsLongs() throws Exception { String json = new BeanToJsonConverter().convert(new Exception()); - Map map = new JsonToBeanConverter().convert(Map.class, json); + Map map = new JsonToBeanConverter().convert(Map.class, json); - List stack = (List) map.get("stackTrace"); - Map line = (Map) stack.get(0); + List stack = (List) map.get("stackTrace"); + Map line = (Map) stack.get(0); Object o = line.get("lineNumber"); assertTrue("line number is of type: " + o.getClass(), o instanceof Long); @@ -423,7 +423,7 @@ public String[] getNames() { private static class BeanWithCollection { @SuppressWarnings("unused") - public Set getSomething() { + public Set getSomething() { Set integers = new HashSet(); integers.add(1); integers.add(43); @@ -434,7 +434,7 @@ public Set getSomething() { private static class BeanWithNullCollection { @SuppressWarnings("unused") - public List getList() { + public List getList() { return null; } } diff --git a/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java b/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java index 6fec13405c622..ad94efb89be90 100644 --- a/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java +++ b/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java @@ -68,13 +68,12 @@ public void testCanPopulateAMap() throws Exception { assertThat(map, hasEntry("foodstuff", "cheese")); } - @SuppressWarnings("unchecked") @Test public void testCanPopulateAMapThatContainsNull() throws Exception { JSONObject toConvert = new JSONObject(); toConvert.put("foo", JSONObject.NULL); - Map converted = new JsonToBeanConverter().convert(Map.class, toConvert.toString()); + Map converted = new JsonToBeanConverter().convert(Map.class, toConvert.toString()); assertEquals(1, converted.size()); assertTrue(converted.containsKey("foo")); assertNull(converted.get("foo")); @@ -101,15 +100,14 @@ public void testWillSilentlyDiscardUnusedFieldsWhenPopulatingABean() throws Exce assertThat(bean.getValue(), is("time")); } - @SuppressWarnings("unchecked") @Test public void testShouldSetPrimitiveValuesToo() throws Exception { JSONObject toConvert = new JSONObject(); toConvert.put("magicNumber", 3); - Map map = new JsonToBeanConverter().convert(Map.class, toConvert.toString()); + Map map = new JsonToBeanConverter().convert(Map.class, toConvert.toString()); - assertThat(3L, is(map.get("magicNumber"))); + assertEquals(3L, map.get("magicNumber")); } @Test @@ -153,25 +151,23 @@ public void testShouldBeAbleToInstantiateBooleans() throws Exception { assertFalse(second); } - @SuppressWarnings("unchecked") @Test public void testShouldUseAMapToRepresentComplexObjects() throws Exception { JSONObject toModel = new JSONObject(); toModel.put("thing", "hairy"); toModel.put("hairy", "true"); - Map modelled = (Map) new JsonToBeanConverter().convert(Object.class, toModel); + Map modelled = (Map) new JsonToBeanConverter().convert(Object.class, toModel); assertEquals(2, modelled.size()); } - @SuppressWarnings("unchecked") @Test public void testShouldConvertAResponseWithAnElementInIt() throws Exception { String json = "{\"value\":{\"value\":\"\",\"text\":\"\",\"selected\":false,\"enabled\":true,\"id\":\"three\"},\"context\":\"con\",\"sessionId\":\"sess\",\"error\":false}"; Response converted = new JsonToBeanConverter().convert(Response.class, json); - Map value = (Map) converted.getValue(); + Map value = (Map) converted.getValue(); assertEquals("three", value.get("id")); } @@ -205,7 +201,6 @@ public void testShouldBeAbleToSetAnObjectToABoolean() throws Exception { assertThat((Boolean) response.getValue(), is(true)); } - @SuppressWarnings("unchecked") @Test public void testCanHandleValueBeingAnArray() throws Exception { String[] value = {"Cheese", "Peas"}; @@ -219,7 +214,7 @@ public void testCanHandleValueBeingAnArray() throws Exception { Response converted = new JsonToBeanConverter().convert(Response.class, json); assertEquals("bar", response.getSessionId()); - assertEquals(2, ((List) converted.getValue()).size()); + assertEquals(2, ((List) converted.getValue()).size()); assertEquals(1512, response.getStatus()); } @@ -229,19 +224,19 @@ public void testShouldConvertObjectsInArraysToMaps() throws Exception { Cookie cookie = new Cookie("foo", "bar", "/rooted", date); String rawJson = new BeanToJsonConverter().convert(Collections.singletonList(cookie)); - List list = new JsonToBeanConverter().convert(List.class, rawJson); + List list = new JsonToBeanConverter().convert(List.class, rawJson); Object first = list.get(0); assertTrue(first instanceof Map); - Map map = (Map) first; + Map map = (Map) first; assertMapEntry(map, "name", "foo"); assertMapEntry(map, "value", "bar"); assertMapEntry(map, "path", "/rooted"); assertMapEntry(map, "expiry", TimeUnit.MILLISECONDS.toSeconds(date.getTime())); } - private void assertMapEntry(Map map, String key, Object expected) { + private void assertMapEntry(Map map, String key, Object expected) { assertTrue("Missing key: " + key, map.containsKey(key)); assertEquals("Wrong value for key: " + key + ": " + map.get(key).getClass().getName(), expected, map.get(key)); @@ -252,8 +247,8 @@ public void testShouldConvertAnArrayBackIntoAnArray() throws Exception { Exception e = new Exception(); String converted = new BeanToJsonConverter().convert(e); - Map reconstructed = new JsonToBeanConverter().convert(Map.class, converted); - List trace = (List) reconstructed.get("stackTrace"); + Map reconstructed = new JsonToBeanConverter().convert(Map.class, converted); + List trace = (List) reconstructed.get("stackTrace"); assertTrue(trace.get(0) instanceof Map); } @@ -331,7 +326,7 @@ public void testShouldNotParseQuotedJsonObjectsAsActualJsonObjects() throws JSON Object convertedOuter = new JsonToBeanConverter().convert(Map.class, jsonStr); assertThat(convertedOuter, instanceOf(Map.class)); - Object convertedInner = ((Map) convertedOuter).get("inner"); + Object convertedInner = ((Map) convertedOuter).get("inner"); assertNotNull(convertedInner); assertThat(convertedInner, instanceOf(String.class)); assertThat(convertedInner.toString(), equalTo(inner.toString())); diff --git a/java/client/test/org/openqa/selenium/remote/internal/WebElementToJsonConverterTest.java b/java/client/test/org/openqa/selenium/remote/internal/WebElementToJsonConverterTest.java index 7f09b1f640943..f1ded8eb091be 100644 --- a/java/client/test/org/openqa/selenium/remote/internal/WebElementToJsonConverterTest.java +++ b/java/client/test/org/openqa/selenium/remote/internal/WebElementToJsonConverterTest.java @@ -92,6 +92,7 @@ public void unwrapsWrappedElements_multipleLevelsOfWrapping() { assertIsWebElementObject(value, "abc123"); } + @SuppressWarnings("unchecked") @Test public void convertsSimpleCollections() { Object converted = CONVERTER.apply(Lists.newArrayList(null, "abc", true, 123, Math.PI)); @@ -101,6 +102,7 @@ public void convertsSimpleCollections() { assertContentsInOrder(list, null, "abc", true, 123, Math.PI); } + @SuppressWarnings("unchecked") @Test public void convertsNestedCollections_simpleValues() { List innerList = Lists.newArrayList(123, "abc"); @@ -211,7 +213,6 @@ public void convertsAMapWithAWebElement() { assertIsWebElementObject(map.get("one"), "abc123"); } - @SuppressWarnings("unchecked") @Test public void convertsAnArray() { Object value = CONVERTER.apply(new Object[] { @@ -219,18 +220,17 @@ public void convertsAnArray() { }); assertThat(value, instanceOf(Collection.class)); - assertContentsInOrder(Lists.newArrayList((Collection) value), + assertContentsInOrder(Lists.newArrayList((Collection) value), "abc123", true, 123, Math.PI); } - @SuppressWarnings("unchecked") @Test public void convertsAnArrayWithAWebElement() { RemoteWebElement element = new RemoteWebElement(); element.setId("abc123"); Object value = CONVERTER.apply(new Object[] { element }); - assertContentsInOrder(Lists.newArrayList((Collection) value), + assertContentsInOrder(Lists.newArrayList((Collection) value), ImmutableMap.of("ELEMENT", "abc123")); } diff --git a/java/client/test/org/openqa/selenium/support/PageFactoryTest.java b/java/client/test/org/openqa/selenium/support/PageFactoryTest.java index 056f9d66d1b06..c681eb75947f4 100644 --- a/java/client/test/org/openqa/selenium/support/PageFactoryTest.java +++ b/java/client/test/org/openqa/selenium/support/PageFactoryTest.java @@ -231,6 +231,7 @@ public static class GrottyPage2 { public static class UnmarkedListPage { private List elements; private List objects; + @SuppressWarnings("rawtypes") private List untyped; // This list deliberately left untyped } diff --git a/java/client/test/org/openqa/selenium/support/events/EventFiringWebDriverTest.java b/java/client/test/org/openqa/selenium/support/events/EventFiringWebDriverTest.java index dab4e545dc5f6..fab466306b2b6 100644 --- a/java/client/test/org/openqa/selenium/support/events/EventFiringWebDriverTest.java +++ b/java/client/test/org/openqa/selenium/support/events/EventFiringWebDriverTest.java @@ -285,7 +285,7 @@ public void shouldUnpackElementArgsWhenCallingScripts() { @Test public void testShouldUnpackListOfElementArgsWhenCallingScripts() { final ExececutingDriver mockedDriver = mock(ExececutingDriver.class); - final List aList = mock(List.class); + final List aList = mock(List.class); checking(new Expectations() {{ one(aList).size(); @@ -306,7 +306,7 @@ public void testShouldUnpackListOfElementArgsWhenCallingScripts() { @Test public void testShouldUnpackMapOfElementArgsWhenCallingScripts() { final ExececutingDriver mockedDriver = mock(ExececutingDriver.class); - final Map aMap = mock(Map.class); + final Map aMap = mock(Map.class); checking(new Expectations() {{ one(aMap).keySet(); diff --git a/java/client/test/org/openqa/selenium/support/pagefactory/internal/LocatingElementListHandlerTest.java b/java/client/test/org/openqa/selenium/support/pagefactory/internal/LocatingElementListHandlerTest.java index 93e34d0f77b81..cf7d2d2b0bc76 100644 --- a/java/client/test/org/openqa/selenium/support/pagefactory/internal/LocatingElementListHandlerTest.java +++ b/java/client/test/org/openqa/selenium/support/pagefactory/internal/LocatingElementListHandlerTest.java @@ -37,6 +37,8 @@ import java.util.List; public class LocatingElementListHandlerTest extends MockTestBase { + + @SuppressWarnings("unchecked") @Test public void shouldAlwaysLocateTheElementPerCall() { final ElementLocator locator = mock(ElementLocator.class); diff --git a/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java b/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java index dcba245e5dcfc..db8b1f2e06e69 100644 --- a/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java +++ b/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java @@ -67,7 +67,7 @@ public void shouldSilentlyCaptureNoSuchElementExceptions() { }}); TickingClock clock = new TickingClock(500); - Wait wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); + Wait wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); assertSame(element, wait.until(condition)); } @@ -84,7 +84,7 @@ public void shouldSilentlyCaptureNoSuchFrameExceptions() { }}); TickingClock clock = new TickingClock(500); - Wait wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); + Wait wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); wait.until(condition); } @@ -101,7 +101,7 @@ public void shouldSilentlyCaptureNoSuchWindowExceptions() { }}); TickingClock clock = new TickingClock(500); - Wait wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); + Wait wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); wait.until(condition); }