diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1cf9dd6b1..1b607d75a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -291,6 +291,9 @@
Bump easymock from 4.2 to 4.3 #226.
+
+ Simplify Assertion.
+
diff --git a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java
index 0c3ac4484..ba7f02d47 100644
--- a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java
+++ b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java
@@ -104,7 +104,7 @@ public abstract class AbstractObjectTest extends BulkTest {
public void testEqualsNull() {
final Object obj = makeObject();
- assertEquals(false, obj.equals(null)); // make sure this doesn't throw NPE either
+ assertFalse(obj.equals(null)); // make sure this doesn't throw NPE either
}
public void testObjectHashCodeEqualsSelfHashCode() {
@@ -124,9 +124,7 @@ public abstract class AbstractObjectTest extends BulkTest {
assertEquals(
"[2] When two objects are equal, their hashCodes should be also.",
obj1.hashCode(), obj2.hashCode());
- assertTrue(
- "When obj1.equals(obj2) is true, then obj2.equals(obj1) should also be true",
- obj2.equals(obj1));
+ assertEquals("When obj1.equals(obj2) is true, then obj2.equals(obj1) should also be true", obj2, obj1);
}
}
diff --git a/src/test/java/org/apache/commons/collections4/ArrayStackTest.java b/src/test/java/org/apache/commons/collections4/ArrayStackTest.java
index d69d5e2b9..e96940ab5 100644
--- a/src/test/java/org/apache/commons/collections4/ArrayStackTest.java
+++ b/src/test/java/org/apache/commons/collections4/ArrayStackTest.java
@@ -66,7 +66,7 @@ public class ArrayStackTest extends AbstractArrayListTest {
final ArrayStack stack = makeObject();
stack.push((E) "First Item");
- assertTrue("Stack is not empty", !stack.empty());
+ assertFalse("Stack is not empty", stack.empty());
assertEquals("Stack size is one", 1, stack.size());
assertEquals("Top item is 'First Item'",
"First Item", (String) stack.peek());
diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
index 98bfd370c..9f5e2010b 100644
--- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
@@ -311,12 +311,12 @@ public class CollectionUtilsTest extends MockTestCase {
public void collect() {
final Transformer transformer = TransformerUtils.constantTransformer(2L);
Collection collection = CollectionUtils.collect(iterableA, transformer);
- assertTrue(collection.size() == collectionA.size());
+ assertEquals(collection.size(), collectionA.size());
assertCollectResult(collection);
ArrayList list;
list = CollectionUtils.collect(collectionA, transformer, new ArrayList());
- assertTrue(list.size() == collectionA.size());
+ assertEquals(list.size(), collectionA.size());
assertCollectResult(list);
Iterator iterator = null;
@@ -324,12 +324,12 @@ public class CollectionUtilsTest extends MockTestCase {
iterator = iterableA.iterator();
list = CollectionUtils.collect(iterator, transformer, list);
- assertTrue(collection.size() == collectionA.size());
+ assertEquals(collection.size(), collectionA.size());
assertCollectResult(collection);
iterator = collectionA.iterator();
collection = CollectionUtils.collect(iterator, transformer);
- assertTrue(collection.size() == collectionA.size());
+ assertEquals(collection.size(), collectionA.size());
assertTrue(collection.contains(2L) && !collection.contains(1));
collection = CollectionUtils.collect((Iterator) null, (Transformer) null);
assertTrue(collection.isEmpty());
@@ -2140,9 +2140,9 @@ public class CollectionUtilsTest extends MockTestCase {
@Test
public void testSizeIsEmpty_Map() {
final Map map = new HashMap<>();
- assertEquals(true, CollectionUtils.sizeIsEmpty(map));
+ assertTrue(CollectionUtils.sizeIsEmpty(map));
map.put("1", "a");
- assertEquals(false, CollectionUtils.sizeIsEmpty(map));
+ assertFalse(CollectionUtils.sizeIsEmpty(map));
}
// -----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
index 687e54366..48975f09e 100644
--- a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java
@@ -57,7 +57,7 @@ public class EnumerationUtilsTest {
} catch (final IndexOutOfBoundsException e) {
// expected
}
- assertTrue(!en.hasMoreElements());
+ assertFalse(en.hasMoreElements());
}
@Test
diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java
index e4206cbb5..f662401eb 100644
--- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java
@@ -75,13 +75,13 @@ public abstract class AbstractOrderedBidiMapTest extends AbstractBidiMapTe
public void testNextKey() {
resetEmpty();
OrderedBidiMap bidi = (OrderedBidiMap) map;
- assertEquals(null, bidi.nextKey(getOtherKeys()[0]));
+ assertNull(bidi.nextKey(getOtherKeys()[0]));
if (!isAllowNullKey()) {
try {
- assertEquals(null, bidi.nextKey(null)); // this is allowed too
+ assertNull(bidi.nextKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
} else {
- assertEquals(null, bidi.nextKey(null));
+ assertNull(bidi.nextKey(null));
}
resetFull();
@@ -93,7 +93,7 @@ public abstract class AbstractOrderedBidiMapTest extends AbstractBidiMapTe
assertEquals(confirmedObject, bidi.nextKey(confirmedLast));
confirmedLast = confirmedObject;
}
- assertEquals(null, bidi.nextKey(confirmedLast));
+ assertNull(bidi.nextKey(confirmedLast));
if (!isAllowNullKey()) {
try {
@@ -101,20 +101,20 @@ public abstract class AbstractOrderedBidiMapTest extends AbstractBidiMapTe
fail();
} catch (final NullPointerException ex) {}
} else {
- assertEquals(null, bidi.nextKey(null));
+ assertNull(bidi.nextKey(null));
}
}
public void testPreviousKey() {
resetEmpty();
OrderedBidiMap bidi = getMap();
- assertEquals(null, bidi.previousKey(getOtherKeys()[0]));
+ assertNull(bidi.previousKey(getOtherKeys()[0]));
if (!isAllowNullKey()) {
try {
- assertEquals(null, bidi.previousKey(null)); // this is allowed too
+ assertNull(bidi.previousKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
} else {
- assertEquals(null, bidi.previousKey(null));
+ assertNull(bidi.previousKey(null));
}
resetFull();
@@ -128,7 +128,7 @@ public abstract class AbstractOrderedBidiMapTest extends AbstractBidiMapTe
assertEquals(confirmedObject, bidi.previousKey(confirmedLast));
confirmedLast = confirmedObject;
}
- assertEquals(null, bidi.previousKey(confirmedLast));
+ assertNull(bidi.previousKey(confirmedLast));
if (!isAllowNullKey()) {
try {
@@ -136,7 +136,7 @@ public abstract class AbstractOrderedBidiMapTest extends AbstractBidiMapTe
fail();
} catch (final NullPointerException ex) {}
} else {
- assertEquals(null, bidi.previousKey(null));
+ assertNull(bidi.previousKey(null));
}
}
diff --git a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
index dfd809691..50983309f 100644
--- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
+++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
@@ -851,7 +851,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest {
resetEmpty();
final E[] elements = getFullElements();
for (final E element : elements) {
- assertTrue("Shouldn't remove nonexistent element", !getCollection().remove(element));
+ assertFalse("Shouldn't remove nonexistent element", getCollection().remove(element));
verify();
}
@@ -895,12 +895,10 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest {
}
resetEmpty();
- assertTrue("Empty collection removeAll should return false for empty input",
- !getCollection().removeAll(Collections.EMPTY_SET));
+ assertFalse("Empty collection removeAll should return false for empty input", getCollection().removeAll(Collections.EMPTY_SET));
verify();
- assertTrue("Empty collection removeAll should return false for nonempty input",
- !getCollection().removeAll(new ArrayList<>(getCollection())));
+ assertFalse("Empty collection removeAll should return false for nonempty input", getCollection().removeAll(new ArrayList<>(getCollection())));
verify();
resetFull();
diff --git a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java
index a0e8a06e8..2309f36e9 100644
--- a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java
+++ b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java
@@ -334,9 +334,9 @@ public class CompositeCollectionTest extends AbstractCollectionTest {
final Collection removing = new ArrayList<>(one);
c.addComposited(one, two);
c.removeAll(removing);
- assertTrue(!c.contains("1"));
- assertTrue(!one.contains("1"));
- assertTrue(!two.contains("1"));
+ assertFalse(c.contains("1"));
+ assertFalse(one.contains("1"));
+ assertFalse(two.contains("1"));
c.removeAll(null);
assertFalse(c.contains("1"));
assertFalse(one.contains("1"));
@@ -356,13 +356,13 @@ public class CompositeCollectionTest extends AbstractCollectionTest {
final Predicate predicate = e -> e == "1";
c.addComposited(one, two);
c.removeIf(predicate);
- assertTrue(!c.contains("1"));
- assertTrue(!one.contains("1"));
- assertTrue(!two.contains("1"));
+ assertFalse(c.contains("1"));
+ assertFalse(one.contains("1"));
+ assertFalse(two.contains("1"));
c.removeIf(null);
- assertTrue(!c.contains("1"));
- assertTrue(!one.contains("1"));
- assertTrue(!two.contains("1"));
+ assertFalse(c.contains("1"));
+ assertFalse(one.contains("1"));
+ assertFalse(two.contains("1"));
}
@SuppressWarnings("unchecked")
diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java
index e6c41c556..94963de1c 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractIteratorTest.java
@@ -105,7 +105,7 @@ public abstract class AbstractIteratorTest extends AbstractObjectTest {
final Iterator it = makeEmptyIterator();
// hasNext() should return false
- assertEquals("hasNext() should return false for empty iterators", false, it.hasNext());
+ assertFalse("hasNext() should return false for empty iterators", it.hasNext());
// next() should throw a NoSuchElementException
try {
@@ -129,7 +129,7 @@ public abstract class AbstractIteratorTest extends AbstractObjectTest {
final Iterator it = makeObject();
// hasNext() must be true (ensure makeFullIterator is correct!)
- assertEquals("hasNext() should return true for at least one element", true, it.hasNext());
+ assertTrue("hasNext() should return true for at least one element", it.hasNext());
// next() must not throw exception (ensure makeFullIterator is correct!)
try {
diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java
index 19dbae10f..5c1608b93 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java
@@ -95,9 +95,9 @@ public abstract class AbstractListIteratorTest extends AbstractIteratorTest it = makeEmptyIterator();
- assertEquals(false, it.hasNext());
+ assertFalse(it.hasNext());
assertEquals(0, it.nextIndex());
- assertEquals(false, it.hasPrevious());
+ assertFalse(it.hasPrevious());
assertEquals(-1, it.previousIndex());
// next() should throw a NoSuchElementException
@@ -126,8 +126,8 @@ public abstract class AbstractListIteratorTest extends AbstractIteratorTest extends AbstractIteratorTest extends AbstractIteratorTest extends AbstractIteratorTest
}
final MapIterator it = makeEmptyIterator();
- assertEquals(false, it.hasNext());
+ assertFalse(it.hasNext());
// next() should throw a NoSuchElementException
try {
@@ -161,9 +161,9 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
final MapIterator it = makeObject();
final Map map = getMap();
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
final Set set = new HashSet<>();
while (it.hasNext()) {
// getKey
@@ -193,7 +193,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
final MapIterator it = makeObject();
final Map map = getMap();
final Map confirmed = getConfirmedMap();
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
final K key = it.next();
final V value = it.getValue();
@@ -209,11 +209,11 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
assertSame("Key must not change after setValue", key, it.getKey());
assertSame("Value must be changed after setValue", newValue, it.getValue());
assertSame("setValue must return old value", value, old);
- assertEquals("Map must contain key", true, map.containsKey(key));
+ assertTrue("Map must contain key", map.containsKey(key));
// test against confirmed, as map may contain value twice
assertEquals("Map must not contain old value",
confirmed.containsValue(old), map.containsValue(old));
- assertEquals("Map must contain new value", true, map.containsValue(newValue));
+ assertTrue("Map must contain new value", map.containsValue(newValue));
verify();
it.setValue(newValue); // same value - should be OK
@@ -234,7 +234,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
final MapIterator it = makeObject();
final Map map = getMap();
final Map confirmed = getConfirmedMap();
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
final K key = it.next();
if (!supportsRemove()) {
@@ -248,7 +248,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
it.remove();
confirmed.remove(key);
- assertEquals(false, map.containsKey(key));
+ assertFalse(map.containsKey(key));
verify();
try {
@@ -266,7 +266,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
final MapIterator it = makeObject();
final Map confirmed = getConfirmedMap();
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
final K key = it.next();
it.setValue(newValue);
@@ -288,7 +288,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
final MapIterator it = makeObject();
final Map confirmed = getConfirmedMap();
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
final K key = it.next();
it.remove();
@@ -309,7 +309,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest
final MapIterator it = makeObject();
final Map confirmed = getConfirmedMap();
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
final K key = it.next();
it.remove();
diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
index 9037e6c4c..80d6a57da 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java
@@ -65,7 +65,7 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt
super.testEmptyMapIterator();
final OrderedMapIterator it = makeEmptyIterator();
- assertEquals(false, it.hasPrevious());
+ assertFalse(it.hasPrevious());
try {
it.previous();
fail();
@@ -86,8 +86,8 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt
final OrderedMapIterator it = makeObject();
final Map map = getMap();
- assertEquals(true, it.hasNext());
- assertEquals(false, it.hasPrevious());
+ assertTrue(it.hasNext());
+ assertFalse(it.hasPrevious());
final Set set = new HashSet<>();
while (it.hasNext()) {
// getKey
@@ -103,7 +103,7 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt
}
assertTrue("Value must be in map", map.containsValue(value));
- assertEquals(true, it.hasPrevious());
+ assertTrue(it.hasPrevious());
verify();
}
@@ -121,7 +121,7 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt
}
assertTrue("Value must be in map", map.containsValue(value));
- assertEquals(true, it.hasNext());
+ assertTrue(it.hasNext());
verify();
}
@@ -141,8 +141,8 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt
assertEquals("keySet() not consistent", new ArrayList<>(map.keySet()), new ArrayList<>(map.keySet()));
final Iterator it2 = map.keySet().iterator();
- assertEquals(true, it.hasNext());
- assertEquals(true, it2.hasNext());
+ assertTrue(it.hasNext());
+ assertTrue(it2.hasNext());
final List list = new ArrayList<>();
while (it.hasNext()) {
final K key = it.next();
diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
index e7acf4947..d1ae4898a 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java
@@ -67,14 +67,12 @@ public class ArrayIterator2Test extends AbstractIteratorTest {
assertEquals("Iteration value is correct", testValue, iterValue);
}
- assertTrue("Iterator should now be empty", !iter.hasNext());
+ assertFalse("Iterator should now be empty", iter.hasNext());
try {
iter.next();
} catch (final Exception e) {
- assertTrue(
- "NoSuchElementException must be thrown",
- e.getClass().equals(new NoSuchElementException().getClass()));
+ assertEquals("NoSuchElementException must be thrown", e.getClass(), new NoSuchElementException().getClass());
}
}
diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
index 74d51f18d..24b7a3d00 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java
@@ -19,6 +19,8 @@ package org.apache.commons.collections4.iterators;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* Tests the ArrayIterator to ensure that the next() method will actually
* perform the iteration rather than the hasNext() method.
@@ -56,15 +58,9 @@ public class ArrayIteratorTest extends AbstractIteratorTest {
assertEquals("Iteration value is correct", testValue, iterValue);
}
- assertTrue("Iterator should now be empty", !iter.hasNext());
+ assertFalse("Iterator should now be empty", iter.hasNext());
- try {
- iter.next();
- } catch (final Exception e) {
- assertTrue(
- "NoSuchElementException must be thrown",
- e.getClass().equals(new NoSuchElementException().getClass()));
- }
+ assertThrows(NoSuchElementException.class, iter::next, "NoSuchElementException must be thrown");
}
public void testNullArray() {
diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java
index 0cf8bf32c..1c86b6591 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.commons.collections4.iterators;
-import java.util.Arrays;
import java.util.ListIterator;
import java.util.NoSuchElementException;
+import static org.junit.Assert.assertArrayEquals;
+
/**
* Test the ArrayListIterator class.
*
@@ -71,14 +72,12 @@ public class ArrayListIteratorTest extends ArrayIteratorTest {
assertEquals("Iteration value is correct", testValue, iterValue);
}
- assertTrue("Iterator should now be empty", !iter.hasPrevious());
+ assertFalse("Iterator should now be empty", iter.hasPrevious());
try {
iter.previous();
} catch (final Exception e) {
- assertTrue(
- "NoSuchElementException must be thrown",
- e.getClass().equals(new NoSuchElementException().getClass()));
+ assertEquals("NoSuchElementException must be thrown", e.getClass(), new NoSuchElementException().getClass());
}
}
@@ -101,7 +100,7 @@ public class ArrayListIteratorTest extends ArrayIteratorTest {
x++;
}
- assertTrue("The two arrays should have the same value, i.e. {0,1,2}", Arrays.equals(testData, result));
+ assertArrayEquals("The two arrays should have the same value, i.e. {0,1,2}", testData, result);
// a call to set() before a call to next() or previous() should throw an IllegalStateException
iter = makeArrayListIterator(testArray);
diff --git a/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java
index 52689f522..00c14df8d 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java
@@ -102,7 +102,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest {
assertEquals(even, iter.next());
assertEquals(0, iter.getIteratorIndex());
}
- assertTrue(!iter.hasNext());
+ assertFalse(iter.hasNext());
}
public void testIterateEvenOdd() {
@@ -112,7 +112,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest {
assertEquals(Integer.valueOf(i), iter.next());
assertEquals(i % 2, iter.getIteratorIndex());
}
- assertTrue(!iter.hasNext());
+ assertFalse(iter.hasNext());
}
public void testIterateOddEven() {
@@ -122,7 +122,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest {
assertEquals(Integer.valueOf(i), iter.next());
assertEquals(i % 2 == 0 ? 1 : 0, iter.getIteratorIndex());
}
- assertTrue(!iter.hasNext());
+ assertFalse(iter.hasNext());
}
public void testIterateEvenEven() {
@@ -137,7 +137,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest {
assertEquals(even, iter.next());
assertEquals(1, iter.getIteratorIndex());
}
- assertTrue(!iter.hasNext());
+ assertFalse(iter.hasNext());
}
public void testIterateFibEvenOdd() {
@@ -203,7 +203,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest {
assertEquals(Integer.valueOf(21), iter.next()); // fib 21
assertEquals(0, iter.getIteratorIndex());
- assertTrue(!iter.hasNext());
+ assertFalse(iter.hasNext());
}
public void testRemoveFromSingle() {
diff --git a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
index 461f9f245..cae41e384 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java
@@ -121,11 +121,11 @@ public class FilterIteratorTest extends AbstractIteratorTest {
final FilterIterator filterIterator = new FilterIterator<>(iter1);
filterIterator.setPredicate(truePredicate());
// this iterator has elements
- assertEquals(true, filterIterator.hasNext());
+ assertTrue(filterIterator.hasNext());
// this iterator has no elements
filterIterator.setIterator(iter2);
- assertEquals(false, filterIterator.hasNext());
+ assertFalse(filterIterator.hasNext());
}
/**
@@ -138,15 +138,15 @@ public class FilterIteratorTest extends AbstractIteratorTest {
final FilterIterator filterIterator = new FilterIterator<>(iter);
filterIterator.setPredicate(truePredicate());
// this predicate matches
- assertEquals(true, filterIterator.hasNext());
+ assertTrue(filterIterator.hasNext());
// this predicate doesn't match
filterIterator.setPredicate(NotNullPredicate.notNullPredicate());
- assertEquals(false, filterIterator.hasNext());
+ assertFalse(filterIterator.hasNext());
}
private void verifyNoMoreElements() {
- assertTrue(!iterator.hasNext());
+ assertFalse(iterator.hasNext());
try {
iterator.next();
fail("NoSuchElementException expected");
@@ -179,7 +179,7 @@ public class FilterIteratorTest extends AbstractIteratorTest {
if (iterator.hasNext()) {
final Object last = iterator.next();
iterator.remove();
- assertTrue("Base of FilterIterator still contains removed element.", !list.contains(last));
+ assertFalse("Base of FilterIterator still contains removed element.", list.contains(last));
}
}
diff --git a/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java
index ac4e36717..7ca03fd6c 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java
@@ -136,7 +136,7 @@ public class FilterListIteratorTest {
assertEquals(Integer.valueOf(3), filtered.previous());
assertEquals(Integer.valueOf(0), filtered.previous());
- assertTrue(!filtered.hasPrevious());
+ assertFalse(filtered.hasPrevious());
assertEquals(Integer.valueOf(0), filtered.next());
assertEquals(Integer.valueOf(3), filtered.next());
@@ -146,7 +146,7 @@ public class FilterListIteratorTest {
assertEquals(Integer.valueOf(15), filtered.next());
assertEquals(Integer.valueOf(18), filtered.next());
- assertTrue(!filtered.hasNext());
+ assertFalse(filtered.hasNext());
assertEquals(Integer.valueOf(18), filtered.previous());
assertEquals(Integer.valueOf(15), filtered.previous());
@@ -276,7 +276,7 @@ public class FilterListIteratorTest {
filtered.next();
}
assertTrue(filtered.hasPrevious());
- assertTrue(!filtered.hasNext());
+ assertFalse(filtered.hasNext());
assertEquals(expected.previous(), filtered.previous());
}
diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
index 9c45e33d0..ac50b72ef 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java
@@ -79,13 +79,12 @@ public class IteratorChainTest extends AbstractIteratorTest {
assertEquals( "Iteration value is correct", testValue, iterValue );
}
- assertTrue("Iterator should now be empty", !iter.hasNext());
+ assertFalse("Iterator should now be empty", iter.hasNext());
try {
iter.next();
} catch (final Exception e) {
- assertTrue("NoSuchElementException must be thrown",
- e.getClass().equals(new NoSuchElementException().getClass()));
+ assertEquals("NoSuchElementException must be thrown", e.getClass(), new NoSuchElementException().getClass());
}
}
@@ -135,7 +134,7 @@ public class IteratorChainTest extends AbstractIteratorTest {
}
assertTrue("List is empty", list1.isEmpty());
- assertTrue("List is empty", list2.size() == 1);
+ assertEquals("List is empty", 1, list2.size());
assertTrue("List is empty", list3.isEmpty());
}
@@ -154,12 +153,12 @@ public class IteratorChainTest extends AbstractIteratorTest {
assertEquals("B", chain.next());
assertTrue("should have next", chain.hasNext());
assertEquals("C", chain.next());
- assertTrue("should not have next", !chain.hasNext());
+ assertFalse("should not have next", chain.hasNext());
}
public void testEmptyChain() {
final IteratorChain