Esempio n. 1
0
 @Test
 public void canAdaptBiFunction() {
   final Function<Pair<O, O>, Pair<O, O>> function = Tuples.tupled(new BinaryIdentity<O, O>());
   final Pair<O, O> expected = Pair.of(O.ONE, O.ANOTHER);
   final Pair<O, O> got = function.apply(expected);
   Assert.assertEquals(expected, got);
 }
Esempio n. 2
0
 @Test
 public void canAdaptFunction() {
   final Function<Pair<O, O>, Pair<O, O>> function = Function.identity();
   final BiFunction<O, O, Pair<O, O>> adapted = Tuples.Pairs.untupled(function);
   Pair<O, O> got = adapted.apply(O.ONE, O.ONE);
   Assert.assertEquals(Pair.of(O.ONE, O.ONE), got);
 }
Esempio n. 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());
 }
Esempio n. 4
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());
 }
Esempio n. 5
0
 @Test
 public void canAdaptBiPredicate() {
   final Predicate<Pair<O, O>> predicate = Tuples.tupled(new BinaryAlways<O, O>());
   Assert.assertTrue(predicate.test(Pair.of(O.IGNORED, O.IGNORED)));
 }