|
@@ -1,4 +1,4 @@
|
1
|
|
-
|
|
1
|
+import java.util.*;
|
2
|
2
|
import static org.junit.Assert.*;
|
3
|
3
|
import org.junit.After;
|
4
|
4
|
import org.junit.Before;
|
|
@@ -13,37 +13,37 @@ import org.junit.Test;
|
13
|
13
|
public class PhoneBookTest
|
14
|
14
|
{
|
15
|
15
|
@Test
|
16
|
|
- public void testAdd(){
|
|
16
|
+ public void testAddEntry(){
|
17
|
17
|
//given
|
18
|
18
|
PhoneBook phoneBook = new PhoneBook();
|
19
|
19
|
|
20
|
20
|
//actual
|
21
|
|
- phoneBook.add("eric", "3025884804");
|
|
21
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
22
|
22
|
String actual = phoneBook.lookup("eric");
|
23
|
23
|
|
24
|
24
|
//expected
|
25
|
|
- String expected = "3025884804";
|
|
25
|
+ String expected = "3025884804, 3025884805, 3025884806";
|
26
|
26
|
|
27
|
27
|
//test
|
28
|
28
|
assertEquals(expected, actual);
|
29
|
29
|
}
|
30
|
30
|
|
31
|
31
|
@Test
|
32
|
|
- public void testAddMultiple(){
|
|
32
|
+ public void testAddEntryMultiple(){
|
33
|
33
|
//given
|
34
|
34
|
PhoneBook phoneBook = new PhoneBook();
|
35
|
35
|
|
36
|
36
|
//actual
|
37
|
|
- phoneBook.add("eric", "3025884804");
|
38
|
|
- phoneBook.add("john", "3025844804");
|
39
|
|
- phoneBook.add("jane", "3025884704");
|
|
37
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
|
38
|
+ phoneBook.addEntry("john", "3025844804", "3025884705");
|
|
39
|
+ phoneBook.addEntry("jane", "3025884704");
|
40
|
40
|
String actual = phoneBook.lookup("eric");
|
41
|
41
|
String actual1 = phoneBook.lookup("john");
|
42
|
42
|
String actual2 = phoneBook.lookup("jane");
|
43
|
43
|
|
44
|
44
|
//expected
|
45
|
|
- String expected = "3025884804";
|
46
|
|
- String expected1 = "3025844804";
|
|
45
|
+ String expected = "3025884804, 3025884805, 3025884806";
|
|
46
|
+ String expected1 = "3025844804, 3025884705";
|
47
|
47
|
String expected2 = "3025884704";
|
48
|
48
|
|
49
|
49
|
//test
|
|
@@ -51,13 +51,13 @@ public class PhoneBookTest
|
51
|
51
|
}
|
52
|
52
|
|
53
|
53
|
@Test
|
54
|
|
- public void testRemove(){
|
|
54
|
+ public void testRemoveEntry(){
|
55
|
55
|
//given
|
56
|
56
|
PhoneBook phoneBook = new PhoneBook();
|
57
|
57
|
|
58
|
58
|
//actual
|
59
|
|
- phoneBook.add("eric", "3025884804");
|
60
|
|
- phoneBook.remove("eric");
|
|
59
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
|
60
|
+ phoneBook.removeEntry("eric");
|
61
|
61
|
String actual = phoneBook.lookup("eric");
|
62
|
62
|
|
63
|
63
|
//expected
|
|
@@ -68,16 +68,16 @@ public class PhoneBookTest
|
68
|
68
|
}
|
69
|
69
|
|
70
|
70
|
@Test
|
71
|
|
- public void testRemoveMultiple(){
|
|
71
|
+ public void testRemoveEntryMultiple(){
|
72
|
72
|
//given
|
73
|
73
|
PhoneBook phoneBook = new PhoneBook();
|
74
|
74
|
|
75
|
75
|
//actual
|
76
|
|
- phoneBook.add("eric", "3025884804");
|
77
|
|
- phoneBook.add("john", "3025844804");
|
78
|
|
- phoneBook.add("jane", "3025884704");
|
79
|
|
- phoneBook.remove("john");
|
80
|
|
- phoneBook.remove("eric");
|
|
76
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
|
77
|
+ phoneBook.addEntry("john", "3025844804", "3025884705");
|
|
78
|
+ phoneBook.addEntry("jane", "3025884704");
|
|
79
|
+ phoneBook.removeEntry("john");
|
|
80
|
+ phoneBook.removeEntry("eric");
|
81
|
81
|
String actual = phoneBook.lookup("john");
|
82
|
82
|
String actual1 = phoneBook.lookup("eric");
|
83
|
83
|
String actual2 = phoneBook.lookup("jane");
|
|
@@ -99,11 +99,11 @@ public class PhoneBookTest
|
99
|
99
|
PhoneBook phoneBook = new PhoneBook();
|
100
|
100
|
|
101
|
101
|
//actual
|
102
|
|
- phoneBook.add("eric", "3025884804");
|
103
|
|
- phoneBook.add("john", "3025844804");
|
104
|
|
- phoneBook.add("jane", "3025884704");
|
105
|
|
- String actual = phoneBook.reverseLookup("3025884804");
|
106
|
|
- String actual1 = phoneBook.reverseLookup("3025844804");
|
|
102
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
|
103
|
+ phoneBook.addEntry("john", "3025844804", "3025884705");
|
|
104
|
+ phoneBook.addEntry("jane", "3025884704");
|
|
105
|
+ String actual = phoneBook.reverseLookup("3025884804", "3025884805", "3025884806");
|
|
106
|
+ String actual1 = phoneBook.reverseLookup("3025844804", "3025884705");
|
107
|
107
|
String actual2 = phoneBook.reverseLookup("3025884704");
|
108
|
108
|
String actual3 = phoneBook.reverseLookup("4025884704");
|
109
|
109
|
|
|
@@ -117,5 +117,74 @@ public class PhoneBookTest
|
117
|
117
|
assertEquals(expected, actual);
|
118
|
118
|
assertEquals(expected1, actual1);
|
119
|
119
|
assertEquals(expected2, actual2);
|
|
120
|
+ assertEquals(expected3, actual3);
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+ @Test
|
|
124
|
+ public void testAddNumberToEntry(){
|
|
125
|
+ //given
|
|
126
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
127
|
+
|
|
128
|
+ //actual
|
|
129
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
|
130
|
+ phoneBook.addNumberToEntry("eric", "3025884807");
|
|
131
|
+ String actual = phoneBook.lookup("eric");
|
|
132
|
+
|
|
133
|
+ //expected
|
|
134
|
+ String expected = "3025884804, 3025884805, 3025884806, 3025884807";
|
|
135
|
+
|
|
136
|
+ //test
|
|
137
|
+ assertEquals(expected, actual);
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+ @Test
|
|
141
|
+ public void testAddNumberToEntryMultiple(){
|
|
142
|
+ //given
|
|
143
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
144
|
+
|
|
145
|
+ //actual
|
|
146
|
+ phoneBook.addEntry("john", "3025884804", "3025884705");
|
|
147
|
+ phoneBook.addNumberToEntry("john", "3025884788", "3025884789");
|
|
148
|
+ String actual = phoneBook.lookup("john");
|
|
149
|
+
|
|
150
|
+ //expected
|
|
151
|
+ String expected = "3025884804, 3025884705, 3025884788, 3025884789";
|
|
152
|
+
|
|
153
|
+ //test
|
|
154
|
+ assertEquals(expected, actual);
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ @Test
|
|
158
|
+ public void testRemoveNumberFromEntry(){
|
|
159
|
+ //given
|
|
160
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
161
|
+
|
|
162
|
+ //actual
|
|
163
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806");
|
|
164
|
+ phoneBook.removeNumberFromEntry("eric", "3025884805");
|
|
165
|
+ String actual = phoneBook.lookup("eric");
|
|
166
|
+
|
|
167
|
+ //expected
|
|
168
|
+ String expected = "3025884804, 3025884806";
|
|
169
|
+
|
|
170
|
+ //test
|
|
171
|
+ assertEquals(expected, actual);
|
|
172
|
+ }
|
|
173
|
+
|
|
174
|
+ @Test
|
|
175
|
+ public void testRemoveNumberFromEntryMultiple(){
|
|
176
|
+ //given
|
|
177
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
178
|
+
|
|
179
|
+ //actual
|
|
180
|
+ phoneBook.addEntry("eric", "3025884804", "3025884805", "3025884806", "3025884807");
|
|
181
|
+ phoneBook.removeNumberFromEntry("eric", "3025884804", "3025884806");
|
|
182
|
+ String actual = phoneBook.lookup("eric");
|
|
183
|
+
|
|
184
|
+ //expected
|
|
185
|
+ String expected = "3025884805, 3025884807";
|
|
186
|
+
|
|
187
|
+ //test
|
|
188
|
+ assertEquals(expected, actual);
|
120
|
189
|
}
|
121
|
190
|
}
|