ReducerInfoHandler extends AnnotationHandlerBase { @SuppressWarnings("rawtypes") protected void configureOutputKeyValue(Job job, Class<? extends Reducer> reducerClass, ReducerInfo reducer) { MaraAnnotationUtil util = MaraAnnotationUtil.INSTANCE; Type[] params = util.getGenericTypeParams(reducerClass, Reducer.class); if (reducer != null && reducer.output().key() != void.class) { job.setOutputKeyClass(reducer.output().key()); } else if (params != null && params.length == 4){ job.setOutputKeyClass((Class<?>)params[2]); } if (reducer != null && reducer.output().value() != void.class) { job.setOutputValueClass(reducer.output().value()); } else if (params != null && params.length == 4){ job.setOutputValueClass((Class<?>)params[3]); } }  @Override boolean accept(Annotation annotation); @Override @SuppressWarnings({ "rawtypes" }) void process(Annotation annotation, Job job, Object target);  }
@Test public void testConfigureReducerIntText() { handler.configureOutputKeyValue(job, TestReducerIntText.class, null); verify(job).setOutputKeyClass(IntWritable.class); verify(job).setOutputValueClass(Text.class); }
@Test public void testConfigureReducerLongText() { handler.configureOutputKeyValue(job, TestReducerLongText.class, null); verify(job).setOutputKeyClass(LongWritable.class); verify(job).setOutputValueClass(Text.class); }
@Test public void testConfigureReducerTextText() { handler.configureOutputKeyValue(job, TestReducerTextText.class, null); verify(job).setOutputKeyClass(Text.class); verify(job).setOutputValueClass(Text.class); }
@Test public void testConfigureReducerSubclassing() { handler.configureOutputKeyValue(job, TestReducerSubclassTest.class, null); verify(job).setOutputKeyClass(Text.class); verify(job).setOutputValueClass(Text.class); }
@Test public void testConfigureReducerNoGenerics() { handler.configureOutputKeyValue(job, TestReducerNoGenericsTest.class, null); verify(job, never()).setOutputKeyClass(any(Class.class)); verify(job, never()).setOutputValueClass(any(Class.class)); }