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 java.util.HashMap;
21 import java.util.Map;
22 import java.util.concurrent.ConcurrentHashMap;
23 import java.util.function.Function;
24
25 import org.junit.jupiter.api.Assertions;
26 import org.junit.jupiter.api.Test;
27
28
29
30
31 class FunctionStringLookupTest {
32
33 @Test
34 void testConcurrentHashMapNull() {
35 Assertions.assertNull(FunctionStringLookup.on(new ConcurrentHashMap<>()).apply(null));
36 }
37
38 @Test
39 void testHashMapNull() {
40 Assertions.assertNull(FunctionStringLookup.on(new HashMap<>()).apply(null));
41 }
42
43 @Test
44 void testNullFunction() {
45 Assertions.assertNull(FunctionStringLookup.on((Function<String, Object>) null).apply(null));
46 }
47
48 @Test
49 void testOne() {
50 final String key = "key";
51 final String value = "value";
52 final Map<String, String> map = new HashMap<>();
53 map.put(key, value);
54 Assertions.assertEquals(value, FunctionStringLookup.on(map).apply(key));
55 }
56
57 @Test
58 void testToString() {
59
60 Assertions.assertFalse(FunctionStringLookup.on(new HashMap<>()).toString().isEmpty());
61 }
62
63 }