Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Nov 6, 2019
2 parents de831b8 + 4ee17e7 commit eee3713
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/test/java/org/cactoos/iterator/IteratorOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package org.cactoos.iterator;

import java.util.Iterator;
import java.util.NoSuchElementException;
import org.cactoos.iterable.IterableOf;
import org.hamcrest.core.IsNot;
Expand All @@ -34,9 +35,9 @@

/**
* Test case for {@link IteratorOf}.
*
* @since 0.30
* @checkstyle JavadocMethodCheck (500 lines)
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
public final class IteratorOfTest {

Expand All @@ -60,7 +61,12 @@ public void emptyIteratorThrowsException() {

@Test
public void nonEmptyIteratorDoesNotHaveNext() {
final IteratorOf<Integer> iterator = this.iteratorWithFetchedElements();
final Iterator<Integer> iterator = new IteratorOf<>(
1, 2, 3
);
while (iterator.hasNext()) {
iterator.next();
}
new Assertion<>(
"Must create non empty iterator",
iterator.hasNext(),
Expand All @@ -70,9 +76,15 @@ public void nonEmptyIteratorDoesNotHaveNext() {

@Test
public void nonEmptyIteratorThrowsException() {
final Iterator<Character> iterator = new IteratorOf<>(
'a', 'b'
);
while (iterator.hasNext()) {
iterator.next();
}
new Assertion<>(
"Must throw an exception if consumed",
() -> this.iteratorWithFetchedElements().next(),
() -> iterator.next(),
new Throws<>(NoSuchElementException.class)
).affirm();
}
Expand All @@ -91,18 +103,4 @@ public void convertStringsToIterator() {
)
).affirm();
}

// @todo #1166:30min According to this Yegor's post
// https://www.yegor256.com/2016/05/03/test-methods-must-share-nothing.html
// test methods must share nothing. Refactor this class by inlining the
// the code below and remove the method below.
private IteratorOf<Integer> iteratorWithFetchedElements() {
final IteratorOf<Integer> iterator = new IteratorOf<>(
1, 2, 3
);
iterator.next();
iterator.next();
iterator.next();
return iterator;
}
}

1 comment on commit eee3713

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on eee3713 Nov 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1166-50dc8796 disappeared from src/test/java/org/cactoos/iterator/IteratorOfTest.java, that's why I closed #1222. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.