PerformanceReducer extends Reducer<Text, IntWritable, Text, Text> { double performance(long onTime, long notOnTime) { if (onTime == 0) { return 0d; } double all = onTime + notOnTime; return (onTime / all) * 100; }  void reduce(Text key, Iterable<IntWritable> values, Context context); void setMaxElements(int maxElements); TreeBidiMap<Double, String> getCache(); static Logger log; }
@Test public void giveOnTimeAndNotOntim_whenPerformance_thenPercentage() { assertTrue(reducer.performance(40, 60) == 40.); assertTrue(reducer.performance(99, 1) == 99.); }