Search in sources :

Example 1 with TupleListCollector

use of cascading.tuple.TupleListCollector in project Impatient by Cascading.

the class ScrubTest method testScrub.

@Test
public void testScrub() {
    Fields fieldDeclaration = new Fields("doc_id", "token");
    Function scrub = new ScrubFunction(fieldDeclaration);
    Tuple[] arguments = new Tuple[] { // will be scrubed
    new Tuple("doc_1", "FoO"), // will be scrubed
    new Tuple("doc_1", " BAR "), // will be scrubed
    new Tuple("doc_1", "     ") };
    ArrayList<Tuple> expectResults = new ArrayList<Tuple>();
    expectResults.add(new Tuple("doc_1", "foo"));
    expectResults.add(new Tuple("doc_1", "bar"));
    TupleListCollector collector = invokeFunction(scrub, arguments, Fields.ALL);
    Iterator<Tuple> it = collector.iterator();
    ArrayList<Tuple> results = new ArrayList<Tuple>();
    while (it.hasNext()) results.add(it.next());
    assertEquals("Scrub result is not expected", expectResults, results);
}
Also used : Function(cascading.operation.Function) Fields(cascading.tuple.Fields) ArrayList(java.util.ArrayList) TupleListCollector(cascading.tuple.TupleListCollector) Tuple(cascading.tuple.Tuple) Test(org.junit.Test)

Aggregations

Function (cascading.operation.Function)1 Fields (cascading.tuple.Fields)1 Tuple (cascading.tuple.Tuple)1 TupleListCollector (cascading.tuple.TupleListCollector)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1