### Question:
Consumers { public static <T> Consumer<T> combine(List<Consumer<T>> consumers) { checkNotNull(consumers); checkArgument(Iterables.all(consumers, Predicates.notNull())); return consumers.stream().reduce(noop(), Consumer::andThen); } private  Consumers(); static Consumer<T> combine(List<Consumer<T>> consumers); static Consumer<T> filter(final Predicate<T> filter, final Consumer<T> consumer); @SuppressWarnings("unchecked") static Consumer<T> noop();  }### Answer:
@Test public void testCombine() { Consumer<Integer> work1 = createMock(INT_CLOSURE_CLZ); Consumer<Integer> work2 = createMock(INT_CLOSURE_CLZ); @SuppressWarnings("unchecked") Consumer<Integer> wrapper = Consumers.combine(ImmutableList.of(work1, work2)); work1.accept(1); work2.accept(1); work1.accept(2); work2.accept(2); control.replay(); wrapper.accept(1); wrapper.accept(2); }
@Test public void testCombineOneThrows() { Consumer<Integer> work1 = createMock(INT_CLOSURE_CLZ); Consumer<Integer> work2 = createMock(INT_CLOSURE_CLZ); Consumer<Integer> work3 = createMock(INT_CLOSURE_CLZ); @SuppressWarnings("unchecked") Consumer<Integer> wrapper = Consumers.combine(ImmutableList.of(work1, work2, work3)); work1.accept(1); expectLastCall().andThrow(new Thrown()); work1.accept(2); work2.accept(2); expectLastCall().andThrow(new Thrown()); work1.accept(3); work2.accept(3); work3.accept(3); expectLastCall().andThrow(new Thrown()); control.replay(); try { wrapper.accept(1); fail("Should have thrown."); } catch (Thrown e) { } try { wrapper.accept(2); fail("Should have thrown."); } catch (Thrown e) { } try { wrapper.accept(3); fail("Should have thrown."); } catch (Thrown e) { } }