package com.tinkerpop.pipes.util;

import com.tinkerpop.pipes.IdentityPipe;
import junit.framework.TestCase;

import java.util.Arrays;
import java.util.List;

/**
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public class HasNextPipeTest extends TestCase {

    public void testPipeBasic() {
        List<String> names = Arrays.asList("marko", "povel", "peter", "josh");
        HasNextPipe<String> pipe1 = new HasNextPipe<String>(new IdentityPipe<String>());
        pipe1.setStarts(names);
        int counter = 0;
        while (pipe1.hasNext()) {
            counter++;
            assertTrue(pipe1.next());
        }
        assertEquals(counter, 4);
    }

}

@@ -128,16 +128,44 @@
 Arrays;%0A
+import java.util.ArrayList;%0A
 import j
@@ -700,10 +700,692 @@
 %0A    %7D%0A%0A
+    public void testPipeInline() %7B%0A        List%3CString%3E names = Arrays.asList(%22marko%22, %22povel%22, %22peter%22, %22josh%22);%0A        IdentityPipe%3CString%3E source_pipe = new IdentityPipe%3CString%3E();%0A        source_pipe.setStarts(names);%0A        HasNextPipe%3CString%3E pipe1 = new HasNextPipe%3CString%3E();%0A        pipe1.setStarts(source_pipe);%0A        assertTrue(pipe1.next());%0A        assertFalse(pipe1.hasNext());%0A%0A        pipe1.reset();%0A        source_pipe.setStarts(new ArrayList());%0A        assertFalse(pipe1.next());%0A        assertFalse(pipe1.hasNext());%0A%0A        pipe1.reset();%0A        source_pipe.setStarts(names);%0A        assertTrue(pipe1.next());%0A        assertFalse(pipe1.hasNext());%0A    %7D%0A%0A
 %7D%0A

Test reset on HasNextPipe.