コード例 #1
0
 @Test
 public void canAdaptBiConsumer() {
   final Box<O> first = Box.empty();
   final Box<O> second = Box.empty();
   final BiConsumer<O, O> spy = Spies.spy(new BinaryNoop<O, O>(), first, second);
   final Consumer<Pair<O, O>> consumer = Tuples.tupled(spy);
   consumer.accept(Pair.of(O.ONE, O.ANOTHER));
   Assert.assertEquals(O.ONE, first.getContent());
   Assert.assertEquals(O.ANOTHER, second.getContent());
 }
コード例 #2
0
 @Test
 public void canAdaptTriConsumer() {
   final Box<O> first = Box.empty();
   final Box<O> second = Box.empty();
   final Box<O> third = Box.empty();
   final TriConsumer<O, O, O> spy = Spies.spy(new TernaryNoop<O, O, O>(), first, second, third);
   final Consumer<Triple<O, O, O>> consumer = Tuples.tupled(spy);
   consumer.accept(Triple.of(O.ONE, O.ANOTHER, O.YET_ANOTHER));
   Assert.assertEquals(O.ONE, first.getContent());
   Assert.assertEquals(O.ANOTHER, second.getContent());
   Assert.assertEquals(O.YET_ANOTHER, third.getContent());
 }
コード例 #3
0
 @Test
 public void canAdaptConsumer() {
   final Box<Pair<O, O>> box = Box.empty();
   final Consumer<Pair<O, O>> consumer = Spies.spy(new Noop<Pair<O, O>>(), box);
   final BiConsumer<O, O> adapted = Tuples.Pairs.untupled(consumer);
   adapted.accept(O.ONE, O.ANOTHER);
   Assert.assertEquals(Pair.of(O.ONE, O.ANOTHER), box.getContent());
 }