Use for-each.
This commit is contained in:
parent
057ab56f3e
commit
7772907e3a
|
@ -813,11 +813,11 @@ public class MapUtilsTest {
|
|||
MapUtils.populateMap(map, list, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
|
||||
assertEquals(list.size(), map.size());
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
assertTrue(map.containsKey(Integer.valueOf(list.get(i))));
|
||||
assertFalse(map.containsKey(list.get(i)));
|
||||
assertTrue(map.containsValue(list.get(i)));
|
||||
assertEquals(list.get(i), map.get(Integer.valueOf(list.get(i))));
|
||||
for (String element : list) {
|
||||
assertTrue(map.containsKey(Integer.valueOf(element)));
|
||||
assertFalse(map.containsKey(element));
|
||||
assertTrue(map.containsValue(element));
|
||||
assertEquals(element, map.get(Integer.valueOf(element)));
|
||||
}
|
||||
|
||||
// Now test both Key-Value transform population
|
||||
|
@ -825,11 +825,11 @@ public class MapUtilsTest {
|
|||
MapUtils.populateMap(map, list, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER);
|
||||
|
||||
assertEquals(list.size(), map.size());
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
assertTrue(map.containsKey(Integer.valueOf(list.get(i))));
|
||||
assertFalse(map.containsKey(list.get(i)));
|
||||
assertTrue(map.containsValue(Integer.valueOf(list.get(i))));
|
||||
assertEquals(Integer.valueOf(list.get(i)), map.get(Integer.valueOf(list.get(i))));
|
||||
for (String element : list) {
|
||||
assertTrue(map.containsKey(Integer.valueOf(element)));
|
||||
assertFalse(map.containsKey(element));
|
||||
assertTrue(map.containsValue(Integer.valueOf(element)));
|
||||
assertEquals(Integer.valueOf(element), map.get(Integer.valueOf(element)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,9 +866,9 @@ public class MapUtilsTest {
|
|||
MapUtils.populateMap(map, list, (Transformer<X, Integer>) input -> input.key, TransformerUtils.<X>nopTransformer());
|
||||
assertEquals(list.size(), map.totalSize());
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
assertTrue(map.containsKey(list.get(i).key));
|
||||
assertTrue(map.containsValue(list.get(i)));
|
||||
for (X element : list) {
|
||||
assertTrue(map.containsKey(element.key));
|
||||
assertTrue(map.containsValue(element));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -752,7 +752,7 @@ public abstract class AbstractCollectionTest<E> extends AbstractObjectTest {
|
|||
|
||||
resetFull();
|
||||
it1 = getCollection().iterator();
|
||||
for (int i = 0; i < getCollection().size(); i++) {
|
||||
for (E element : getCollection()) {
|
||||
assertTrue("Iterator for full collection should haveNext", it1.hasNext());
|
||||
it1.next();
|
||||
}
|
||||
|
|
|
@ -97,9 +97,9 @@ public class CollatingIteratorTest extends AbstractIteratorTest<Integer> {
|
|||
public void testIterateEven() {
|
||||
final CollatingIterator<Integer> iter = new CollatingIterator<>(comparator);
|
||||
iter.addIterator(evens.iterator());
|
||||
for (int i = 0; i < evens.size(); i++) {
|
||||
for (Integer even : evens) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(evens.get(i), iter.next());
|
||||
assertEquals(even, iter.next());
|
||||
assertEquals(0, iter.getIteratorIndex());
|
||||
}
|
||||
assertTrue(!iter.hasNext());
|
||||
|
@ -129,12 +129,12 @@ public class CollatingIteratorTest extends AbstractIteratorTest<Integer> {
|
|||
final CollatingIterator<Integer> iter = new CollatingIterator<>(comparator);
|
||||
iter.addIterator(evens.iterator());
|
||||
iter.addIterator(evens.iterator());
|
||||
for (int i = 0; i < evens.size(); i++) {
|
||||
for (Integer even : evens) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(evens.get(i), iter.next());
|
||||
assertEquals(even, iter.next());
|
||||
assertEquals(0, iter.getIteratorIndex());
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(evens.get(i), iter.next());
|
||||
assertEquals(even, iter.next());
|
||||
assertEquals(1, iter.getIteratorIndex());
|
||||
}
|
||||
assertTrue(!iter.hasNext());
|
||||
|
|
|
@ -80,9 +80,9 @@ public class ZippingIteratorTest extends AbstractIteratorTest<Integer> {
|
|||
public void testIterateEven() {
|
||||
@SuppressWarnings("unchecked")
|
||||
final ZippingIterator<Integer> iter = new ZippingIterator<>(evens.iterator());
|
||||
for (int i = 0; i < evens.size(); i++) {
|
||||
for (Integer even : evens) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(evens.get(i), iter.next());
|
||||
assertEquals(even, iter.next());
|
||||
}
|
||||
assertTrue(!iter.hasNext());
|
||||
}
|
||||
|
@ -113,11 +113,11 @@ public class ZippingIteratorTest extends AbstractIteratorTest<Integer> {
|
|||
|
||||
public void testIterateEvenEven() {
|
||||
final ZippingIterator<Integer> iter = new ZippingIterator<>(evens.iterator(), evens.iterator());
|
||||
for (int i = 0; i < evens.size(); i++) {
|
||||
for (Integer even : evens) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(evens.get(i), iter.next());
|
||||
assertEquals(even, iter.next());
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(evens.get(i), iter.next());
|
||||
assertEquals(even, iter.next());
|
||||
}
|
||||
assertTrue(!iter.hasNext());
|
||||
}
|
||||
|
|
|
@ -129,10 +129,10 @@ public class SequencesComparatorTest {
|
|||
|
||||
final ExecutionVisitor<String> ev = new ExecutionVisitor<>();
|
||||
|
||||
for (int i = 0; i < shadokSentences.size(); ++i) {
|
||||
for (List<String> element : shadokSentences) {
|
||||
for (final List<String> shadokSentence : shadokSentences) {
|
||||
ev.setList(shadokSentences.get(i));
|
||||
new SequencesComparator<>(shadokSentences.get(i),
|
||||
ev.setList(element);
|
||||
new SequencesComparator<>(element,
|
||||
shadokSentence).getScript().visit(ev);
|
||||
|
||||
final StringBuilder concat = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue