|
|
@@ -1,11 +1,12 @@
|
|
1
|
1
|
import org.junit.Ignore;
|
|
2
|
2
|
import org.junit.Test;
|
|
3
|
3
|
|
|
4
|
|
-import java.util.Arrays;
|
|
|
4
|
+import java.util.Collection;
|
|
5
|
5
|
import java.util.HashMap;
|
|
6
|
|
-import java.util.List;
|
|
7
|
6
|
import java.util.Map;
|
|
8
|
7
|
|
|
|
8
|
+import org.hamcrest.Matcher;
|
|
|
9
|
+import static org.hamcrest.collection.IsIterableContainingInOrder.*;
|
|
9
|
10
|
import static org.hamcrest.CoreMatchers.*;
|
|
10
|
11
|
import static org.junit.Assert.*;
|
|
11
|
12
|
|
|
|
@@ -69,14 +70,22 @@ public class SchoolTest {
|
|
69
|
70
|
@Ignore
|
|
70
|
71
|
@Test
|
|
71
|
72
|
public void sortsSchool() {
|
|
|
73
|
+ school.add("Kyle", 4);
|
|
|
74
|
+ school.add("Zed", 4);
|
|
|
75
|
+ school.add("Adam", 4);
|
|
72
|
76
|
school.add("Jennifer", 4);
|
|
73
|
77
|
school.add("Kareem", 6);
|
|
74
|
78
|
school.add("Christopher", 4);
|
|
75
|
|
- school.add("Kyle", 3);
|
|
76
|
|
- Map<Integer, List<String>> sortedStudents = new HashMap<Integer, List<String>>();
|
|
77
|
|
- sortedStudents.put(6, Arrays.asList("Kareem"));
|
|
78
|
|
- sortedStudents.put(4, Arrays.asList("Christopher", "Jennifer"));
|
|
79
|
|
- sortedStudents.put(3, Arrays.asList("Kyle"));
|
|
80
|
|
- assertEquals(school.sort(), sortedStudents);
|
|
|
79
|
+ school.add("Kylie", 3);
|
|
|
80
|
+ Map<Integer, Matcher> sortedStudents = new HashMap<Integer, Matcher>();
|
|
|
81
|
+ sortedStudents.put(6, contains("Kareem"));
|
|
|
82
|
+ sortedStudents.put(4, contains("Adam", "Christopher", "Jennifer", "Kyle", "Zed"));
|
|
|
83
|
+ sortedStudents.put(3, contains("Kylie"));
|
|
|
84
|
+
|
|
|
85
|
+ Map schoolStudents = school.sort();
|
|
|
86
|
+ for (Map.Entry<?, Matcher> entry : sortedStudents.entrySet()) {
|
|
|
87
|
+
|
|
|
88
|
+ assertThat((Collection) schoolStudents.get(entry.getKey()), entry.getValue());
|
|
|
89
|
+ }
|
|
81
|
90
|
}
|
|
82
|
91
|
}
|