Skip to content

Commit

Permalink
Only use static imports for JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 21, 2024
1 parent e5c8050 commit c7fc724
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;

import static org.apache.commons.collections4.functors.EqualPredicate.equalPredicate;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -54,6 +53,7 @@
import org.apache.commons.collections4.collection.TransformedCollection;
import org.apache.commons.collections4.collection.UnmodifiableCollection;
import org.apache.commons.collections4.functors.DefaultEquator;
import org.apache.commons.collections4.functors.EqualPredicate;
import org.apache.commons.collections4.functors.InstanceofPredicate;
import org.apache.commons.collections4.functors.UniquePredicate;
import org.apache.commons.collections4.queue.CircularFifoQueue;
Expand Down Expand Up @@ -250,10 +250,10 @@ public void exists() {
@Test
@Deprecated
public void find() {
Predicate<Number> testPredicate = equalPredicate((Number) 4);
Predicate<Number> testPredicate = EqualPredicate.equalPredicate((Number) 4);
Integer test = CollectionUtils.find(collectionA, testPredicate);
assertEquals(4, (int) test);
testPredicate = equalPredicate((Number) 45);
testPredicate = EqualPredicate.equalPredicate((Number) 45);
test = CollectionUtils.find(collectionA, testPredicate);
assertNull(test);
assertNull(CollectionUtils.find(null, testPredicate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.commons.collections4;

import static org.apache.commons.collections4.functors.EqualPredicate.equalPredicate;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -40,6 +39,7 @@
import java.util.Set;

import org.apache.commons.collections4.bag.HashBag;
import org.apache.commons.collections4.functors.EqualPredicate;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -302,10 +302,10 @@ public void testDuplicatSetAllSameInDeque() {

@Test
public void testFind() {
Predicate<Number> testPredicate = equalPredicate(4);
Predicate<Number> testPredicate = EqualPredicate.equalPredicate(4);
Integer test = IterableUtils.find(iterableA, testPredicate);
assertEquals(4, (int) test);
testPredicate = equalPredicate(45);
testPredicate = EqualPredicate.equalPredicate(45);
test = IterableUtils.find(iterableA, testPredicate);
assertNull(test);
assertNull(IterableUtils.find(null, testPredicate));
Expand Down Expand Up @@ -457,10 +457,10 @@ public void testGetFromIterableIndexOutOfBoundsException() throws Exception {

@Test
public void testIndexOf() {
Predicate<Number> testPredicate = equalPredicate((Number) 4);
Predicate<Number> testPredicate = EqualPredicate.equalPredicate((Number) 4);
int index = IterableUtils.indexOf(iterableA, testPredicate);
assertEquals(6, index);
testPredicate = equalPredicate((Number) 45);
testPredicate = EqualPredicate.equalPredicate((Number) 45);
index = IterableUtils.indexOf(iterableA, testPredicate);
assertEquals(-1, index);
assertEquals(-1, IterableUtils.indexOf(null, testPredicate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package org.apache.commons.collections4;

import static org.apache.commons.collections4.functors.EqualPredicate.equalPredicate;
import static org.apache.commons.collections4.functors.TruePredicate.INSTANCE;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
Expand Down Expand Up @@ -46,6 +44,8 @@
import java.util.Set;
import java.util.Vector;

import org.apache.commons.collections4.functors.EqualPredicate;
import org.apache.commons.collections4.functors.TruePredicate;
import org.apache.commons.collections4.iterators.ArrayIterator;
import org.apache.commons.collections4.iterators.EmptyIterator;
import org.apache.commons.collections4.iterators.EmptyListIterator;
Expand Down Expand Up @@ -725,7 +725,7 @@ public void testFilteredIterator() {
public void testFilteredListIterator() {
final List arrayList = new ArrayList();
arrayList.add("test");
final Predicate predicate = INSTANCE;
final Predicate predicate = TruePredicate.INSTANCE;
assertTrue(IteratorUtils.filteredListIterator(arrayList.listIterator(), predicate) instanceof ListIterator,
"create instance fail");
assertAll(
Expand All @@ -736,10 +736,10 @@ public void testFilteredListIterator() {

@Test
public void testFind() {
Predicate<Number> testPredicate = equalPredicate((Number) 4);
Predicate<Number> testPredicate = EqualPredicate.equalPredicate((Number) 4);
Integer test = IteratorUtils.find(iterableA.iterator(), testPredicate);
assertEquals(4, (int) test);
testPredicate = equalPredicate((Number) 45);
testPredicate = EqualPredicate.equalPredicate((Number) 45);
test = IteratorUtils.find(iterableA.iterator(), testPredicate);
assertNull(test);
assertNull(IteratorUtils.find(null, testPredicate));
Expand Down Expand Up @@ -861,10 +861,10 @@ public void testGetIterator() {

@Test
public void testIndexOf() {
Predicate<Number> testPredicate = equalPredicate((Number) 4);
Predicate<Number> testPredicate = EqualPredicate.equalPredicate((Number) 4);
int index = IteratorUtils.indexOf(iterableA.iterator(), testPredicate);
assertEquals(6, index);
testPredicate = equalPredicate((Number) 45);
testPredicate = EqualPredicate.equalPredicate((Number) 45);
index = IteratorUtils.indexOf(iterableA.iterator(), testPredicate);
assertEquals(-1, index);
assertEquals(-1, IteratorUtils.indexOf(null, testPredicate));
Expand Down
Loading

0 comments on commit c7fc724

Please sign in to comment.