com.emarsys.ecommon.test.testng
Class IteratorHelper<T>

java.lang.Object
  extended by com.emarsys.ecommon.test.testng.IteratorHelper<T>

public class IteratorHelper<T>
extends java.lang.Object

Helper class for dealing with Iterators in TestNG unit test cases.

Author:
Michael "kULO" Kulovits

Nested Class Summary
static class IteratorHelper.IteratorFunctor<T>
           
 
Constructor Summary
IteratorHelper(java.lang.Iterable<T> it)
           
IteratorHelper(java.lang.Iterable<T> it, java.lang.Class<? extends java.lang.Exception> expectedExceptionClass)
           
 
Method Summary
static
<T> void
assertEquals(java.util.Iterator<T> expected, java.util.Iterator<T> actual)
          Asserts (using the test-ng Assert class) that the passed Iterators represent the same element sequence, i.e.
static
<T> void
assertEquals(java.util.Iterator<T> expected, java.util.Iterator<T> actual, java.util.Comparator<T> comp)
           
 java.lang.Iterable<T> getIterable()
           
 java.util.Iterator<T> getIterator()
           
 boolean isExpectErrors()
           
 void iterate(IteratorHelper.IteratorFunctor<T> func)
           
static
<T> java.util.List<T>
list(java.util.Iterator<T> it)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorHelper

public IteratorHelper(java.lang.Iterable<T> it)
Parameters:
it -

IteratorHelper

public IteratorHelper(java.lang.Iterable<T> it,
                      java.lang.Class<? extends java.lang.Exception> expectedExceptionClass)
Method Detail

assertEquals

public static <T> void assertEquals(java.util.Iterator<T> expected,
                                    java.util.Iterator<T> actual)
Asserts (using the test-ng Assert class) that the passed Iterators represent the same element sequence, i.e. that their iteration will result in the same elements retrieved.

Type Parameters:
T -
Parameters:
expected -
actual -

assertEquals

public static <T> void assertEquals(java.util.Iterator<T> expected,
                                    java.util.Iterator<T> actual,
                                    java.util.Comparator<T> comp)

isExpectErrors

public boolean isExpectErrors()
Returns:
the expectErrors

getIterable

public java.lang.Iterable<T> getIterable()
Returns:
the iterable

getIterator

public java.util.Iterator<T> getIterator()
Returns:
the iterator

iterate

public void iterate(IteratorHelper.IteratorFunctor<T> func)
             throws java.lang.Exception
Parameters:
func -
Throws:
java.lang.Exception

list

public static <T> java.util.List<T> list(java.util.Iterator<T> it)
Type Parameters:
T -
Parameters:
it -
Returns:


Copyright © 2010 emarsys AG. All Rights Reserved.