package ru.job4j;

import java.util.*;

import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;

/**
 * Task 4.1.4
 * Test methods create iterator for iterators
 *
 * @author Anton Vasilyuk
 * @version 1.0
 * @since 0.1
 */

public class IteratorIteratorsTest {

    /**.
     * Iterator for write convert iterator iterators
     */
    private Iterator<Integer> convertIterator;

    /**.
     * Preparing for test method
     */
    @Before
    public void preparingForTesting() {
        List<Integer> listOne = new ArrayList(Arrays.asList(1, 2, 3));
        List<Integer> listTwo = new ArrayList(Arrays.asList(4, 5, 6));
        List<Integer> listThird = new ArrayList(Arrays.asList(7, 8));
        List<Iterator<Integer>> it = new ArrayList(Arrays.asList
                ((listOne.iterator()), listTwo.iterator(), listThird.iterator()));
        IteratorIterators iterators = new IteratorIterators();
        this.convertIterator = iterators.convert(it.iterator());
    }

    /**.
     * Test method hasNext
     */
    @Test
    public void whenNeedCheckNextElement() {
        boolean result = convertIterator.hasNext();
        assertThat(result, is(true));
    }

    /**.
     * Test method next
     */
    @Test
    public void whenNeedCheckMoveIterator() {
        convertIterator.next();
        convertIterator.next();
        convertIterator.next();
        convertIterator.next();
        Integer result = convertIterator.next();
        assertThat(result, is(5));
    }
}
@@ -1107,28 +1107,24 @@
 ic void when
-Need
 CheckNextEle
@@ -1127,16 +1127,37 @@
 tElement
+ThenHasNextReturnTrue
 () %7B%0A   
@@ -1278,17 +1278,20 @@
  method 
-n
+hasN
 ext%0A    
@@ -1328,249 +1328,965 @@
 when
-NeedCheckMoveIterator() %7B%0A        convertIterator.next();%0A        convertIterator.next();%0A        convertIterator.next();%0A        convertIterator.next();%0A        Integer result = convertIterator.next();%0A        assertThat(result, is(5));%0A    %7D%0A%7D
+IterateEightTimeThenHasNextReturnFalse() %7B%0A        for (int i = 0; i %3C 8; i++) %7B%0A            convertIterator.next();%0A        %7D%0A        boolean result = convertIterator.hasNext();%0A        assertThat(result, is(false));%0A    %7D%0A%0A    /**.%0A     * Test method next%0A     */%0A    @Test%0A    public void whenIterateFiveTimeArrayThenHasNextReturnFive() %7B%0A        convertIterator.next();%0A        convertIterator.next();%0A        convertIterator.next();%0A        convertIterator.next();%0A        Integer result = convertIterator.next();%0A        assertThat(result, is(5));%0A    %7D%0A%0A    /**.%0A     * Test method hasNext%0A     */%0A    @Test%0A    public void whenArrayIsNullThenHasNextReturnNEE() %7B%0A        Iterator%3CIterator%3CInteger%3E%3E value = null;%0A        IteratorIterators iter = new IteratorIterators();%0A        try %7B%0A            iter.hasNext();%0A        %7D catch (NoSuchElementException nee) %7B%0A            assertThat(nee.getMessage(), is(%22No element in this array.%22));%0A        %7D%0A    %7D%0A%7D%0A

add file for chapter_003_4.1.4