ShuffleModel analyzed = shuffle(CoGroupStage.class);
ShuffleValueEmitter emitter = new ShuffleValueEmitter(environment);
Name name = emitter.emit(analyzed);
ClassLoader loader = start();
SegmentedWritable value = (SegmentedWritable) create(loader, name);
List<Segment> segments = analyzed.getSegments();
assertThat(segments.size(), is(2));
Segment seg1 = segments.get(0);
Segment seg2 = segments.get(1);
assertThat(seg1.getTerms().size(), is(2));
assertThat(seg2.getTerms().size(), is(2));
Ex1 ex1 = new Ex1();
ex1.setSid(1);
ex1.setValue(100);
ex1.setStringAsString("ex1");
setShuffleValue(seg1, value, ex1);
assertThat(value.getSegmentId(), is(seg1.getPortId()));
Object r1 = getShuffleValue(seg1, value);
assertThat(r1, is((Object) ex1));
Ex2 ex2 = new Ex2();
ex2.setSid(2);
ex2.setValue(200);
ex2.setStringAsString("ex2");
setShuffleValue(seg2, value, ex2);
assertThat(value.getSegmentId(), is(seg2.getPortId()));
Object r2 = getShuffleValue(seg2, value);
assertThat(r2, is((Object) ex2));
}