Skip to content

Commit 912013d

Browse files
Alessandro Baffajtigger
authored andcommitted
Remove Guava and use JUnit assert (exercism#170)
* remove Guava and use JUnit assert * reassign old to Collection.unmodifiable * reassign variable expected
1 parent ea0d2b7 commit 912013d

1 file changed

Lines changed: 101 additions & 55 deletions

File tree

Lines changed: 101 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,125 @@
1-
import com.google.common.collect.ImmutableMap;
21
import org.junit.Test;
3-
import org.junit.Ignore;
42

5-
import java.util.Arrays;
6-
import java.util.List;
7-
import java.util.Map;
3+
import java.util.*;
4+
5+
import static org.junit.Assert.assertEquals;
86

9-
import static org.assertj.core.api.Assertions.assertThat;
107

118
public class EtlTest {
129
private final Etl etl = new Etl();
1310

14-
1511
@Test
1612
public void testTransformOneValue() {
17-
Map<Integer, List<String>> old = ImmutableMap.of(1, Arrays.asList("A"));
18-
Map<String, Integer> expected = ImmutableMap.of("a", 1);
13+
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
14+
{
15+
put(1, Arrays.asList("A"));
16+
}
17+
};
18+
old = Collections.unmodifiableMap(old);
19+
20+
Map<String, Integer> expected = new HashMap<String, Integer>() {
21+
{
22+
put("a", 1);
23+
}
24+
};
25+
expected = Collections.unmodifiableMap(expected);
1926

20-
assertThat(etl.transform(old)).isEqualTo(expected);
27+
assertEquals(etl.transform(old), expected);
2128
}
2229

23-
@Ignore
2430
@Test
2531
public void testTransformMoreValues() {
26-
Map<Integer, List<String>> old = ImmutableMap.of(
27-
1, Arrays.asList("A", "E", "I", "O", "U")
28-
);
29-
Map<String, Integer> expected = ImmutableMap.of(
30-
"a", 1,
31-
"e", 1,
32-
"i", 1,
33-
"o", 1,
34-
"u", 1
35-
);
36-
37-
assertThat(etl.transform(old)).isEqualTo(expected);
32+
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
33+
{
34+
put(1, Arrays.asList("A", "E", "I", "O", "U"));
35+
}
36+
};
37+
old = Collections.unmodifiableMap(old);
38+
39+
Map<String, Integer> expected = new HashMap<String, Integer>() {
40+
{
41+
put("a", 1);
42+
put("e", 1);
43+
put("i", 1);
44+
put("o", 1);
45+
put("u", 1);
46+
}
47+
};
48+
expected = Collections.unmodifiableMap(expected);
49+
50+
assertEquals(etl.transform(old), expected);
3851
}
3952

40-
@Ignore
4153
@Test
4254
public void testMoreKeys() {
43-
Map<Integer, List<String>> old = ImmutableMap.of(
44-
1, Arrays.asList("A", "E"),
45-
2, Arrays.asList("D", "G")
46-
);
47-
Map<String, Integer> expected = ImmutableMap.of(
48-
"a", 1,
49-
"e", 1,
50-
"d", 2,
51-
"g", 2
52-
);
53-
54-
assertThat(etl.transform(old)).isEqualTo(expected);
55+
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
56+
{
57+
put(1, Arrays.asList("A", "E"));
58+
put(2, Arrays.asList("D", "G"));
59+
}
60+
};
61+
old = Collections.unmodifiableMap(old);
62+
63+
Map<String, Integer> expected = new HashMap<String, Integer>() {
64+
{
65+
put("a", 1);
66+
put("e", 1);
67+
put("d", 2);
68+
put("g", 2);
69+
}
70+
};
71+
expected = Collections.unmodifiableMap(expected);
72+
73+
assertEquals(etl.transform(old), expected);
5574
}
5675

57-
@Ignore
5876
@Test
5977
public void testFullDataset() {
60-
Map<Integer, List<String>> old = ImmutableMap.<Integer, List<String>>builder().
61-
put(1, Arrays.asList("A", "E", "I", "O", "U", "L", "N", "R", "S", "T")).
62-
put(2, Arrays.asList("D", "G")).
63-
put(3, Arrays.asList("B", "C", "M", "P")).
64-
put(4, Arrays.asList("F", "H", "V", "W", "Y")).
65-
put(5, Arrays.asList("K")).
66-
put(8, Arrays.asList("J", "X")).
67-
put(10, Arrays.asList("Q", "Z")).
68-
build();
69-
Map<String, Integer> expected = ImmutableMap.<String, Integer>builder().
70-
put("a", 1).put("b", 3).put("c", 3).put("d", 2).put("e", 1).
71-
put("f", 4).put("g", 2).put("h", 4).put("i", 1).put("j", 8).
72-
put("k", 5).put("l", 1).put("m", 3).put("n", 1).put("o", 1).
73-
put("p", 3).put("q", 10).put("r", 1).put("s", 1).put("t", 1).
74-
put("u", 1).put("v", 4).put("w", 4).put("x", 8).put("y", 4).
75-
put("z", 10).build();
76-
77-
assertThat(etl.transform(old)).isEqualTo(expected);
78+
Map<Integer, List<String>> old = new HashMap<Integer, List<String>>() {
79+
{
80+
put(1, Arrays.asList("A", "E", "I", "O", "U", "L", "N", "R", "S", "T"));
81+
put(2, Arrays.asList("D", "G"));
82+
put(3, Arrays.asList("B", "C", "M", "P"));
83+
put(4, Arrays.asList("F", "H", "V", "W", "Y"));
84+
put(5, Arrays.asList("K"));
85+
put(8, Arrays.asList("J", "X"));
86+
put(10, Arrays.asList("Q", "Z"));
87+
}
88+
};
89+
old = Collections.unmodifiableMap(old);
90+
91+
Map<String, Integer> expected = new HashMap<String, Integer>() {
92+
{
93+
put("a", 1);
94+
put("b", 3);
95+
put("c", 3);
96+
put("d", 2);
97+
put("e", 1);
98+
put("f", 4);
99+
put("g", 2);
100+
put("h", 4);
101+
put("i", 1);
102+
put("j", 8);
103+
put("k", 5);
104+
put("l", 1);
105+
put("m", 3);
106+
put("n", 1);
107+
put("o", 1);
108+
put("p", 3);
109+
put("q", 10);
110+
put("r", 1);
111+
put("s", 1);
112+
put("t", 1);
113+
put("u", 1);
114+
put("v", 4);
115+
put("w", 4);
116+
put("x", 8);
117+
put("y", 4);
118+
put("z", 10);
119+
}
120+
};
121+
expected = Collections.unmodifiableMap(expected);
122+
123+
assertEquals(etl.transform(old), expected);
78124
}
79125
}

0 commit comments

Comments
 (0)