Esempio n. 1
0
 @Test
 public void canAdaptFunction() {
   final Function<Triple<O, O, O>, Triple<O, O, O>> function = Function.identity();
   final TriFunction<O, O, O, Triple<O, O, O>> adapted = Tuples.Triples.untupled(function);
   Triple<O, O, O> got = adapted.apply(O.ONE, O.ONE, O.ONE);
   Assert.assertEquals(Triple.of(O.ONE, O.ONE, O.ONE), got);
 }
Esempio 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);
 }
Esempio n. 3
0
 @Test
 public void canAdaptConsumer() {
   final Box<Triple<O, O, O>> box = Box.empty();
   final Consumer<Triple<O, O, O>> consumer = Spies.spy(new Noop<Triple<O, O, O>>(), box);
   final TriConsumer<O, O, O> adapted = Tuples.Triples.untupled(consumer);
   adapted.accept(O.ONE, O.ANOTHER, O.YET_ANOTHER);
   Assert.assertEquals(Triple.of(O.ONE, O.ANOTHER, O.YET_ANOTHER), box.getContent());
 }
Esempio 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());
 }
Esempio 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)));
 }