-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapProcessingTest.java
More file actions
45 lines (31 loc) · 978 Bytes
/
Copy pathMapProcessingTest.java
File metadata and controls
45 lines (31 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Created by mtumilowicz on 2018-11-09.
*/
public class MapProcessingTest {
@Test
public void forEach() {
Map<Integer, String> map = new HashMap<>();
map.put(1, "1");
map.put(2, "2");
map.put(3, "3");
map.forEach((key, value) -> System.out.println(key + ": " + value));
}
@Test
public void getOrDefault_found() {
Map<Integer, String> map = new HashMap<>();
map.put(1, "1");
String str = map.getOrDefault(1, "NOT-FOUND");
assertThat(str, is("1"));
}
@Test
public void getOrDefault_notFound() {
Map<Integer, String> map = new HashMap<>();
String str = map.getOrDefault(1, "NOT-FOUND");
assertThat(str, is("NOT-FOUND"));
}
}