1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.text.lookup;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertNull;
23
24 import java.util.HashMap;
25 import java.util.Map;
26 import java.util.concurrent.ConcurrentHashMap;
27 import java.util.function.Function;
28
29 import org.junit.jupiter.api.Test;
30
31
32
33
34 class FunctionStringLookupTest {
35
36 @Test
37 void testConcurrentHashMapNull() {
38 assertNull(FunctionStringLookup.on(new ConcurrentHashMap<>()).apply(null));
39 }
40
41 @Test
42 void testHashMapNull() {
43 assertNull(FunctionStringLookup.on(new HashMap<>()).apply(null));
44 }
45
46 @Test
47 void testNullFunction() {
48 assertNull(FunctionStringLookup.on((Function<String, Object>) null).apply(null));
49 }
50
51 @Test
52 void testOne() {
53 final String key = "key";
54 final String value = "value";
55 final Map<String, String> map = new HashMap<>();
56 map.put(key, value);
57 assertEquals(value, FunctionStringLookup.on(map).apply(key));
58 }
59
60 @Test
61 void testToString() {
62
63 assertFalse(FunctionStringLookup.on(new HashMap<>()).toString().isEmpty());
64 }
65
66 }