package ru.job4j;

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

/**
 * Task 4.1.3
 * Create iterator for simple numbers
 *
 * @author Anton Vasilyuk
 * @version 1.0
 * @since 0.1
 */

public class IteratorSimpleNumbersTest {

    /**.
     * Method for check method Next
     */
    @Test
    public void whenNeedTakeAwayOnlySimpleNumbersThenDoIt() {
        int checkNum = 0;
        int[] array = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
        IteratorSimpleNumbers iter = new IteratorSimpleNumbers(array);
        int[] testArray = {2, 3, 5, 7, 11};
        int[] resultArray = new int[5];

        for (int i = 0; i < resultArray.length; i++) {
            resultArray[i] = (Integer) iter.next();
            if(resultArray[i] != testArray[i]) {checkNum++;}
        }
        boolean fact = true;
        boolean expect = true;
        if(checkNum != 0) {fact = false;}
        assertThat(fact, is(expect));

    }

}
@@ -35,16 +35,59 @@
 t.Test;%0A
+%0Aimport java.util.NoSuchElementException;%0A%0A
 import s
@@ -1000,13 +1000,1126 @@
 ));%0A
-%0A
     %7D%0A%0A
+    /**.%0A     * Test working hasNext%0A     */%0A    @Test%0A    public void whenIterateTwoTimeArrayThenHasNextReturnTrue() %7B%0A        int%5B%5D array = %7B2, 3, 4, 5%7D;%0A        IteratorSimpleNumbers iter = new IteratorSimpleNumbers(array);%0A        iter.next();%0A        iter.next();%0A        boolean result = iter.hasNext();%0A        assertThat(result, is(true));%0A    %7D%0A%0A    /**.%0A     * Test working hasNext if not simple numbers%0A     */%0A    @Test%0A    public void whenInArrayNotSimpleNumberThenHasNextReturnFalse() %7B%0A        int%5B%5D array = %7B4, 6, 8, 9%7D;%0A        IteratorSimpleNumbers iter = new IteratorSimpleNumbers(array);%0A        boolean result = iter.hasNext();%0A        assertThat(result, is(false));%0A    %7D%0A%0A    /**.%0A     * Test working hasNext if in array not numbers%0A     */%0A    @Test%0A    public void whenInArrayNoElementThenHasNextReturnNEE() %7B%0A        int%5B%5D value = null;%0A        IteratorSimpleNumbers iter = new IteratorSimpleNumbers(value);%0A        try %7B%0A            iter.hasNext();%0A        %7D catch (NoSuchElementException nee) %7B%0A            assertThat(nee.getMessage(), is(%22In this array not element%22));%0A        %7D%0A    %7D%0A
 %7D

add file for chapter_003_4.1.3