-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetMostCommonFromMergeTest.java
More file actions
69 lines (54 loc) · 2.26 KB
/
GetMostCommonFromMergeTest.java
File metadata and controls
69 lines (54 loc) · 2.26 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.dtcc.exams.assessment.part2;
import com.dtcc.exams.part2.ArrayUtility;
import org.junit.Assert;
import org.junit.Test;
public class GetMostCommonFromMergeTest {
@Test
public void integerTest() {
// Given
Integer expected = 7;
Integer[] inputArray = {1, 2, expected, 8, 4, 5, expected, 0, 9, 8, expected};
Integer[] arrayToMerge = {1, 2, expected, 8, 4, 5, expected, 0, 9, 8};
ArrayUtility<Integer> arrayUtility = new ArrayUtility<>(inputArray);
// When
Integer actual = arrayUtility.getMostCommonFromMerge(arrayToMerge, expected);
// Then
Assert.assertEquals(expected, actual);
}
@Test
public void longTest() {
// Given
Long expected = 8L;
Long[] inputArray = {1L, 2L, expected, 8L, 4L, 5L, expected, 0L, 9L, 8L, expected};
Long[] arrayToMerge = {1L, 2L, expected, 8L, 4L, 5L, expected, 0L, 9L, 8L, expected};
ArrayUtility<Long> arrayUtility = new ArrayUtility<>(inputArray);
// When
Long actual = arrayUtility.getMostCommonFromMerge(arrayToMerge, expected);
// Then
Assert.assertEquals(expected, actual);
}
@Test
public void stringTest() {
// Given
String expected = "a";
String[] inputArray = {"1", "2", expected, "8", "4", "5", expected, "0", "9", "8", expected};
String[] arrayToMerge = {"1", "2", expected, "8", "4", "5", expected, "0", "9", "8", expected, expected};
ArrayUtility<String> arrayUtility = new ArrayUtility<>(inputArray);
// When
String actual = arrayUtility.getMostCommonFromMerge(arrayToMerge, expected);
// Then
Assert.assertEquals(expected, actual);
}
@Test
public void objectTest() {
// Given
Object expected = "a";
Object[] inputArray = {"1", "2", expected, "8", "4", "5", expected, "0", "9", "8", expected};
Object[] arrayToMerge = {"1", "2", expected, "8", "4", "5", expected, "0", "9", "8", expected, expected, expected};
ArrayUtility<Object> arrayUtility = new ArrayUtility<>(inputArray);
// When
Object actual = arrayUtility.getMostCommonFromMerge(arrayToMerge, expected);
// Then
Assert.assertEquals(expected, actual);
}
}