Assert.assertEquals("b", (String) out.get(1));
}
@Test
public void testBiggerBag() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("1", "max");
DataBag input = BagFactory.getInstance().newDefaultBag();
DataBag dbSmaller = BagFactory.getInstance().newDefaultBag();
dbSmaller.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has three items")));
dbSmaller.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has three items")));
dbSmaller.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has three items")));
input.add(TupleFactory.getInstance().newTuple(
Arrays.asList(dbSmaller, "smaller")));
DataBag dbBigger = BagFactory.getInstance().newDefaultBag();
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
input.add(TupleFactory.getInstance().newTuple(
Arrays.asList(dbBigger, "bigger")));
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
// DataBags are ordered by size, so the bigger one will be the one
// containing 4 items
Assert.assertEquals("bigger", out.get(1));
}