-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConcatenatedWordCount.test.java
47 lines (36 loc) · 1.67 KB
/
ConcatenatedWordCount.test.java
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
46
47
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ConcatenatedWordCountTest {
@Test
public void testGetConcatenateWordCount_MultipleOverlaps() {
List<String> stream1 = Arrays.asList("cat", "rat", "dog");
List<String> stream2 = Arrays.asList("cat", "dog", "cow", "dock");
Map<String, Integer> wordCountMap = ConcatenatedWordCount.getConcatenateWordCount(stream1, stream2);
assertEquals(2, wordCountMap.get("cat"));
assertEquals(1, wordCountMap.get("rat"));
assertEquals(2, wordCountMap.get("dog"));
assertEquals(1, wordCountMap.get("cow"));
assertEquals(1, wordCountMap.get("dock"));
}
@Test
public void testGetConcatenateWordCount_NoOverlaps() {
List<String> stream1 = Arrays.asList("bird", "mouse");
List<String> stream2 = Arrays.asList("cat", "dog");
Map<String, Integer> wordCountMap = ConcatenatedWordCount.getConcatenateWordCount(stream1, stream2);
assertEquals(1, wordCountMap.get("bird"));
assertEquals(1, wordCountMap.get("mouse"));
assertEquals(1, wordCountMap.get("cat"));
assertEquals(1, wordCountMap.get("dog"));
}
@Test
public void testGetConcatenateWordCount_EmptyLists() {
List<String> stream1 = Arrays.asList();
List<String> stream2 = Arrays.asList();
Map<String, Integer> wordCountMap = ConcatenatedWordCount.getConcatenateWordCount(stream1, stream2);
assertEquals(0, wordCountMap.size());
}
// ... Additional test cases as necessary ...
}