Skip to content

Commit

Permalink
fix some errorprone warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
juherr committed Feb 18, 2024
1 parent a6699ef commit af6f1d6
Show file tree
Hide file tree
Showing 133 changed files with 509 additions and 545 deletions.
29 changes: 7 additions & 22 deletions testng-asserts/src/main/java/org/testng/FileAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public static void assertFile(File tstvalue, String message) {
}
}

/**
* @param tstvalue The actual file
* @see #assertFile(File, String)
*/
/** @param tstvalue The actual file See {@link #assertFile(File, String)} */
public static void assertFile(File tstvalue) {
assertFile(tstvalue, null);
}
Expand Down Expand Up @@ -95,8 +92,7 @@ public static void assertLength(File tstvalue, long expected, String message) {

/**
* @param tstvalue The actual file
* @param expected The expected length
* @see #assertLength(File, long, String)
* @param expected The expected length See {@link #assertLength(File, long, String)}
*/
public static void assertLength(File tstvalue, long expected) {
assertLength(tstvalue, expected, null);
Expand Down Expand Up @@ -126,8 +122,7 @@ public static void assertMinLength(File tstvalue, long expected, String message)

/**
* @param tstvalue The actual file
* @param expected The expected min length
* @see #assertMinLength(File, long, String)
* @param expected The expected min length See {@link #assertMinLength(File, long, String)}
*/
public static void assertMinLength(File tstvalue, long expected) {
assertMinLength(tstvalue, expected, null);
Expand Down Expand Up @@ -157,8 +152,7 @@ public static void assertMaxLength(File tstvalue, long expected, String message)

/**
* @param tstvalue The actual file
* @param expected The expected length
* @see #assertMaxLength(File, long, String)
* @param expected The expected length See {@link #assertMaxLength(File, long, String)}
*/
public static void assertMaxLength(File tstvalue, long expected) {
assertMaxLength(tstvalue, expected, null);
Expand All @@ -183,10 +177,7 @@ public static void assertReadable(File tstvalue, String message) {
}
}

/**
* @param tstvalue The actual file
* @see #assertReadable(File, String)
*/
/** @param tstvalue The actual file See {@link #assertReadable(File, String)} */
public static void assertReadable(File tstvalue) {
assertReadable(tstvalue, null);
}
Expand All @@ -210,10 +201,7 @@ public static void assertWriteable(File tstvalue, String message) {
}
}

/**
* @param tstvalue The actual file
* @see #assertWriteable(File, String)
*/
/** @param tstvalue The actual file See {@link #assertWriteable(File, String)} */
public static void assertWriteable(File tstvalue) {
assertReadable(tstvalue, null);
}
Expand All @@ -237,10 +225,7 @@ public static void assertReadWrite(File tstvalue, String message) {
}
}

/**
* @param tstvalue The actual file
* @see #assertReadWrite(File, String)
*/
/** @param tstvalue The actual file See {@link #assertReadWrite(File, String)} */
public static void assertReadWrite(File tstvalue) {
assertReadWrite(tstvalue, null);
}
Expand Down
2 changes: 1 addition & 1 deletion testng-asserts/src/test/java/org/testng/AssertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public int hashCode() {
}
}

class Asymmetric extends Contrived {
static class Asymmetric extends Contrived {

char character;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public User(String name, Integer age) {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!(o instanceof User)) return false;
User user = (User) o;
return Objects.equal(name, user.name) && Objects.equal(age, user.age);
}
Expand Down
34 changes: 18 additions & 16 deletions testng-asserts/src/test/java/test/asserttests/AssertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,64 +376,62 @@ public void checkCollectionNotEqualsFailsWhenDifferentOrder() {
@Test(description = "GITHUB-2540", expectedExceptions = AssertionError.class)
public void checkIteratorEqualsFailsWhenDifferentOrder() {

Iterator<String> iterator1 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator2 = (new LinkedHashSet<>(Arrays.asList("a", "c", "b"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "c", "b")).iterator();

assertEquals(iterator1, iterator2);
}

@Test(description = "GITHUB-2540")
public void checkIteratorEqualsNoOrder() {

Iterator<String> iterator1 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator2 = (new LinkedHashSet<>(Arrays.asList("a", "c", "b"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "c", "b")).iterator();

assertEqualsNoOrder(iterator1, iterator2);
}

@Test(expectedExceptions = AssertionError.class)
public void checkIteratorEqualsNoOrderIterator1SizeGreater() {

Iterator<String> iterator1 =
(new LinkedHashSet<>(Arrays.asList("a", "b", "c", "d"))).iterator();
Iterator<String> iterator2 = (new LinkedHashSet<>(Arrays.asList("a", "c", "b"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c", "d")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "c", "b")).iterator();

assertEqualsNoOrder(iterator1, iterator2);
}

@Test(expectedExceptions = AssertionError.class)
public void checkIteratorEqualsNoOrderIterator2SizeGreater() {

Iterator<String> iterator1 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator2 =
(new LinkedHashSet<>(Arrays.asList("a", "c", "b", "d"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "c", "b", "d")).iterator();

assertEqualsNoOrder(iterator1, iterator2);
}

@Test(description = "GITHUB-2540")
public void checkIteratorEquals() {

Iterator<String> iterator1 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator2 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();

assertEquals(iterator1, iterator2);
}

@Test(description = "GITHUB-2540")
public void checkIteratorNotEquals() {

Iterator<String> iterator1 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator2 = (new LinkedHashSet<>(Arrays.asList("a", "c", "b"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "c", "b")).iterator();

assertNotEquals(iterator1, iterator2);
}

@Test(description = "GITHUB-2540", expectedExceptions = AssertionError.class)
public void checkIteratorNotEqualsFailsWhenDifferentOrder() {

Iterator<String> iterator1 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator2 = (new LinkedHashSet<>(Arrays.asList("a", "b", "c"))).iterator();
Iterator<String> iterator1 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();
Iterator<String> iterator2 = new LinkedHashSet<>(Arrays.asList("a", "b", "c")).iterator();

assertNotEquals(iterator1, iterator2);
}
Expand Down Expand Up @@ -609,13 +607,15 @@ protected void assertMapsEqual(Map m1, Map m2) {
assertNotEquals((Object) m1, (Object) m2);
succeeded = true;
} catch (AssertionError expected) {
// Ignore
}
assertFalse(succeeded, "Maps reported as not equal when equal: " + m1 + " / " + m2);

try {
assertNotEquals(m1, m2);
succeeded = true;
} catch (AssertionError expected) {
// Ignore
}
assertFalse(succeeded, "Maps reported as not equal when equal: " + m1 + " / " + m2);
}
Expand All @@ -626,13 +626,15 @@ protected void assertMapsNotEqual(Map m1, Map m2) {
assertEquals((Object) m1, (Object) m2);
succeeded = true;
} catch (AssertionError expected) {
// Ignore
}
assertFalse(succeeded, "Maps reported as equal when not equal: " + m1 + " / " + m2);

try {
assertEquals(m1, m2);
succeeded = true;
} catch (AssertionError expected) {
// Ignore
}
assertFalse(succeeded, "Maps reported as equal when not equal: " + m1 + " / " + m2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ public static <K> List<K> newArrayList() {
return new ArrayList<>();
}

@Deprecated
public static <K> List<K> newLinkedList() {
return new LinkedList<>();
}

@Deprecated
public static <K> List<K> newLinkedList(Collection<K> c) {
return new LinkedList<>(c);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Maps {
public final class Maps {
private Maps() {}

public static <K, V> Map<K, V> newHashMap() {
return new HashMap<>();
}

@Deprecated
public static <K, V> Map<K, V> newHashtable() {
return new Hashtable<>();
}
Expand Down
10 changes: 3 additions & 7 deletions testng-core-api/src/main/java/org/testng/IAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

/** A trait that is used by all interfaces that lets the user add or remove their own attributes. */
public interface IAttributes {
/**
* @param name The name of the attribute to return
* @return The attribute
*/
/** @param name The name of the attribute to return Returns the attribute */
Object getAttribute(String name);

/**
Expand All @@ -18,14 +15,13 @@ public interface IAttributes {
*/
void setAttribute(String name, Object value);

/** @return all the attributes names. */
/** Returns all the attributes names. */
Set<String> getAttributeNames();

/**
* Remove the attribute
*
* @param name The attribute name
* @return the attribute value if found, null otherwise
* @param name The attribute name Returns the attribute value if found, null otherwise
*/
Object removeAttribute(String name);
}
12 changes: 6 additions & 6 deletions testng-core-api/src/main/java/org/testng/IClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
/** <code>IClass</code> represents a test class and a collection of its instances. */
public interface IClass {

/** @return this test class name. This is the name of the corresponding Java class. */
/** Returns this test class name. This is the name of the corresponding Java class. */
String getName();

/** @return the &lt;test&gt; tag this class was found in. */
/** Returns the &lt;test&gt; tag this class was found in. */
XmlTest getXmlTest();

/** @return the *lt;class&gt; tag this class was found in. */
/** Returns the *lt;class&gt; tag this class was found in. */
XmlClass getXmlClass();

/** @return its test name if this class implements org.testng.ITest, null otherwise. */
/** Returns its test name if this class implements org.testng.ITest, null otherwise. */
String getTestName();

/** @return the Java class corresponding to this IClass. */
/** Returns the Java class corresponding to this IClass. */
Class<?> getRealClass();

/**
* Returns all the instances the methods will be invoked upon. This will typically be an array of
* one object in the absence of a @Factory annotation.
*
* @param create flag if a new set of instances must be returned (if set to <code>false</code>)
* @return All the instances the methods will be invoked upon.
* Returns all the instances the methods will be invoked upon.
*/
Object[] getInstances(boolean create);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public interface IConfigureCallBack {
*/
void runConfigurationMethod(ITestResult testResult);

/** @return the parameters that will be used to invoke the configuration method. */
/** Returns the parameters that will be used to invoke the configuration method. */
Object[] getParameters();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public interface IHookCallBack {
*/
void runTestMethod(ITestResult testResult);

/** @return the parameters that will be used to invoke the test method. */
/** Returns the parameters that will be used to invoke the test method. */
Object[] getParameters();
}
8 changes: 4 additions & 4 deletions testng-core-api/src/main/java/org/testng/IInvokedMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
*/
public interface IInvokedMethod {

/** @return true if this method is a test method */
/** Returns true if this method is a test method */
boolean isTestMethod();

/** @return true if this method is a configuration method (@BeforeXXX or @AfterXXX) */
/** Returns true if this method is a configuration method (@BeforeXXX or @AfterXXX) */
boolean isConfigurationMethod();

/** @return the test method */
/** Returns the test method */
ITestNGMethod getTestMethod();

ITestResult getTestResult();

/** @return the date when this method was run */
/** Returns the date when this method was run */
long getDate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface IMethodSelector {
* getUserData().
* @param method The test method
* @param isTestMethod true if this is a @Test method, false if it's a configuration method
* @return true if this method should be included in the test run, false otherwise
* Returns true if this method should be included in the test run, false otherwise
*/
boolean includeMethod(IMethodSelectorContext context, ITestNGMethod method, boolean isTestMethod);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IModuleFactory {
/**
* @param context The current test context
* @param testClass The test class
* @return The Guice module that should be used to get an instance of this test class.
* Returns the Guice module that should be used to get an instance of this test class.
*/
Module createModule(ITestContext context, Class<?> testClass);
}
Loading

0 comments on commit af6f1d6

Please sign in to comment.