use of cascading.operation.Function 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);
}