Reducers { public static Double sumReducer(List<Double> values) { double result = values.stream() .filter(Objects::nonNull) .reduce(0.0, (a, b) -> a + b); return result; } private  Reducers(); static Double sumReducer(List<Double> values);  }
@Test public void testSumReducer() { Double[][] testLists = new Double[][] { {}, {null, null}, {1.0, null}, {1.0, 2.1} }; Double[] results = new Double[] { 0.0, 0.0, 1.0, 3.1 }; for (int i = 0; i < results.length; i++) { Double[] test = testLists[i]; Double expResult = results[i]; Double result = Reducers.sumReducer(Arrays.asList(test)); Assert.assertEquals(expResult, result); } }