}
@SuppressWarnings("unchecked")
@Test
public void testBagOfAnnotationMerge() throws IOException {
TupleFactory tf = TupleFactory.getInstance();
DefaultDataBag textBag = new DefaultDataBag();
DefaultDataBag beginBag = new DefaultDataBag();
DefaultDataBag endBag = new DefaultDataBag();
DefaultDataBag typeBag = new DefaultDataBag();
textBag.add(tf.newTupleNoCopy(Arrays.asList(JOHN_SENTENCE)));
beginBag.add(tf.newTupleNoCopy(Arrays.asList(0)));
endBag.add(tf.newTupleNoCopy(Arrays.asList(10)));
typeBag.add(tf.newTupleNoCopy(Arrays.asList("person")));
textBag.add(tf.newTupleNoCopy(Arrays.asList(JOHN_SENTENCE)));
beginBag.add(tf.newTupleNoCopy(Arrays.asList(19)));
endBag.add(tf.newTupleNoCopy(Arrays.asList(36)));
typeBag.add(tf.newTupleNoCopy(Arrays.asList("organization")));
// all bags
Tuple input = tf.newTupleNoCopy(Arrays.asList(textBag, beginBag,
endBag, typeBag));
String merged = merger.exec(input);
assertEquals("<START:person> John Smith <END> works"
+ " at <START:organization> Smith Consulting <END> .", merged);
// all literals
input = tf.newTupleNoCopy(Arrays.asList(JOHN_SENTENCE, 0, 10, "person"));
merged = merger.exec(input);
assertEquals(
"<START:person> John Smith <END> works at Smith Consulting .",
merged);
// bags without types
input = tf.newTupleNoCopy(Arrays.asList(textBag, beginBag, endBag));
merged = merger.exec(input);
assertEquals(
"<START> John Smith <END> works at <START> Smith Consulting <END> .",
merged);
// bags with fixed type
input = tf.newTupleNoCopy(Arrays.asList(textBag, beginBag, endBag,
"entity"));
merged = merger.exec(input);
assertEquals("<START:entity> John Smith <END> works at"
+ " <START:entity> Smith Consulting <END> .", merged);
}