1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.io.function;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21
22 import java.io.IOException;
23 import java.util.concurrent.atomic.AtomicReference;
24
25 import org.junit.jupiter.api.Test;
26
27
28
29
30 public class IOTriConsumerTest {
31
32 @Test
33 public void testAccept() throws IOException {
34 final AtomicReference<String> ref = new AtomicReference<>();
35 final IOTriConsumer<String, Integer, Character> consumer = (s, i, b) -> ref.set(s + i + b);
36 consumer.accept("A", 1, 'b');
37 assertEquals("A1b", ref.get());
38 }
39
40 @Test
41 public void testAndThen() throws IOException {
42 final AtomicReference<String> ref = new AtomicReference<>();
43 final IOTriConsumer<String, Integer, Character> consumer1 = (s, i, b) -> ref.set(s + i + b);
44 final IOTriConsumer<String, Integer, Character> consumer2 = (s, i, b) -> ref.set(ref.get() + b + i + s);
45 consumer1.andThen(consumer2).accept("B", 2, 'b');
46 assertEquals("B2bb2B", ref.get());
47 }
48
49 @Test
50 public void testNoop() throws IOException {
51 IOTriConsumer.noop().accept(null, null, null);
52 }
53
54 }