TestData.Value v1 = null;
TestData.Value v2 = null;
if (iter1.hasNext()) {
Record rec = iter1.next();
rec.getFieldInto(0, key);
v1 = rec.getField(1, TestData.Value.class);
}
else if (iter2.hasNext()) {
Record rec = iter2.next();
rec.getFieldInto(0, key);
v2 = rec.getField(1, TestData.Value.class);
}
else {
Assert.fail("No input on both sides.");
}
// assert that matches for this key exist
Assert.assertTrue("No matches for key " + key, expectedCoGroupsMap.containsKey(key));
Collection<TestData.Value> expValues1 = expectedCoGroupsMap.get(key).get(0);
Collection<TestData.Value> expValues2 = expectedCoGroupsMap.get(key).get(1);
if (v1 != null) {
expValues1.remove(v1);
}
else {
expValues2.remove(v2);
}
while(iter1.hasNext()) {
Record rec = iter1.next();
Assert.assertTrue("Value not in expected set of first input", expValues1.remove(rec.getField(1, TestData.Value.class)));
}
Assert.assertTrue("Expected set of first input not empty", expValues1.isEmpty());
while(iter2.hasNext()) {
Record rec = iter2.next();
Assert.assertTrue("Value not in expected set of second input", expValues2.remove(rec.getField(1, TestData.Value.class)));
}
Assert.assertTrue("Expected set of second input not empty", expValues2.isEmpty());
expectedCoGroupsMap.remove(key);
}