Ejemplo 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);
 }
Ejemplo n.º 2
0
 @Test
 public void canAdaptTriFunction() {
   final Function<Triple<O, O, O>, Triple<O, O, O>> function =
       Tuples.tupled(new TernaryIdentity<>());
   final Triple<O, O, O> expected = Triple.of(O.ONE, O.ANOTHER, O.ANOTHER);
   final Triple<O, O, O> got = function.apply(expected);
   Assert.assertEquals(expected, got);
 }
Ejemplo n.º 3
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());
 }
Ejemplo n.º 4
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());
 }
Ejemplo n.º 5
0
 @Test
 public void canAdaptTernaryPredicate() {
   final Predicate<Triple<O, O, O>> predicate = Tuples.tupled(new TernaryAlways<O, O, O>());
   Assert.assertTrue(predicate.test(Triple.of(O.IGNORED, O.IGNORED, O.IGNORED)));
 }
Ejemplo n.º 6
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)));
 }