public void simple() throws Exception {
ShuffleModel analyzed = shuffle(SimpleShuffleStage.class);
ShuffleFragmentEmitter emitter = new ShuffleFragmentEmitter(environment);
Name key = emitKey(analyzed);
Name value = emitValue(analyzed);
Segment segment = analyzed.getSegments().get(0);
CompiledShuffleFragment compiled = emitter.emit(segment, key, value, analyzed.getStageBlock());
ClassLoader loader = start();
MockResult<? extends SegmentedWritable> keys = MockResult.create();
MockResult<? extends SegmentedWritable> values = MockResult.create();
@SuppressWarnings("unchecked")
Result<Ex1> output = (Result<Ex1>) create(
loader,
compiled.getMapOutputType().getQualifiedName(),
MockOutput.create(keys, values));
Ex1 ex1 = new Ex1();
ex1.setSid(5);
ex1.setValue(100);
ex1.setStringAsString("ex1");
output.add(ex1);
List<? extends SegmentedWritable> keyList = keys.getResults();
List<? extends SegmentedWritable> valueList = values.getResults();
assertThat(keyList.size(), is(1));
assertThat(valueList.size(), is(1));
SegmentedWritable sKey = keyList.get(0);
SegmentedWritable sValue = valueList.get(0);
assertThat(sKey.getSegmentId(), is(segment.getPortId()));
assertThat(sValue.getSegmentId(), is(segment.getPortId()));
ExSummarized mapped = (ExSummarized) getShuffleValue(segment, sValue);
assertThat(mapped.getCount(), is(1L));
assertThat(mapped.getValue(), is(100L));
}