|
@@ -175,57 +175,57 @@ public class ListMapTest {
|
175
|
175
|
}
|
176
|
176
|
|
177
|
177
|
// I commented this out because it takes a long time to run. Uncomment it when implement your put method, uncomment this test
|
178
|
|
-// @Test
|
179
|
|
-// public void testPutAndGet_WithManyItems(){
|
180
|
|
-// // Given
|
181
|
|
-// int numberOfEntries = 70000;
|
182
|
|
-//
|
183
|
|
-// for (int i = 0; i < numberOfEntries; i++) {
|
184
|
|
-// myMap.put(new User(i), new Cart(i));
|
185
|
|
-// }
|
186
|
|
-//
|
187
|
|
-//
|
188
|
|
-// for (int i = 0; i < numberOfEntries; i++) {
|
189
|
|
-// // When
|
190
|
|
-// Cart actualCart = myMap.get(new User(i));
|
191
|
|
-// Cart expectedCart = new Cart(i);
|
192
|
|
-//
|
193
|
|
-// // Then
|
194
|
|
-// Assert.assertEquals(actualCart, expectedCart);
|
195
|
|
-// }
|
196
|
|
-// }
|
|
178
|
+ @Test
|
|
179
|
+ public void testPutAndGet_WithManyItems(){
|
|
180
|
+ // Given
|
|
181
|
+ int numberOfEntries = 70000;
|
|
182
|
+
|
|
183
|
+ for (int i = 0; i < numberOfEntries; i++) {
|
|
184
|
+ myMap.put(new User(i), new Cart(i));
|
|
185
|
+ }
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+ for (int i = 0; i < numberOfEntries; i++) {
|
|
189
|
+ // When
|
|
190
|
+ Cart actualCart = myMap.get(new User(i));
|
|
191
|
+ Cart expectedCart = new Cart(i);
|
|
192
|
+
|
|
193
|
+ // Then
|
|
194
|
+ Assert.assertEquals(actualCart, expectedCart);
|
|
195
|
+ }
|
|
196
|
+ }
|
197
|
197
|
|
198
|
198
|
// BONUS
|
199
|
|
-// @Test
|
200
|
|
-// public void testRemove(){
|
201
|
|
-// // Given
|
202
|
|
-// User user1 = new User("Lena");
|
203
|
|
-// Cart cart1 = new Cart(11);
|
204
|
|
-//
|
205
|
|
-// User user2 = new User("Jamal");
|
206
|
|
-// Cart cart2 = new Cart(21);
|
207
|
|
-//
|
208
|
|
-// User user3 = new User("Kelvin");
|
209
|
|
-// Cart cart3 = new Cart(31);
|
210
|
|
-//
|
211
|
|
-// // When
|
212
|
|
-// myMap.put(user1, cart1);
|
213
|
|
-// myMap.put(user2, cart2);
|
214
|
|
-// myMap.put(user3, cart3);
|
215
|
|
-//
|
216
|
|
-// // Then
|
217
|
|
-// Cart actualCart = myMap.remove(user2);
|
218
|
|
-//
|
219
|
|
-// Assert.assertEquals(cart2, actualCart);
|
220
|
|
-// Assert.assertNull(myMap.get(user2));
|
221
|
|
-// }
|
222
|
|
-//
|
223
|
|
-// @Test
|
224
|
|
-// public void testRemove_CartNotInTheMap(){
|
225
|
|
-// // Given
|
226
|
|
-// User user1 = new User("Lena");
|
227
|
|
-//
|
228
|
|
-// // When & Then
|
229
|
|
-// Assert.assertNull(myMap.remove(user1));
|
230
|
|
-// }
|
|
199
|
+ @Test
|
|
200
|
+ public void testRemove(){
|
|
201
|
+ // Given
|
|
202
|
+ User user1 = new User("Lena");
|
|
203
|
+ Cart cart1 = new Cart(11);
|
|
204
|
+
|
|
205
|
+ User user2 = new User("Jamal");
|
|
206
|
+ Cart cart2 = new Cart(21);
|
|
207
|
+
|
|
208
|
+ User user3 = new User("Kelvin");
|
|
209
|
+ Cart cart3 = new Cart(31);
|
|
210
|
+
|
|
211
|
+ // When
|
|
212
|
+ myMap.put(user1, cart1);
|
|
213
|
+ myMap.put(user2, cart2);
|
|
214
|
+ myMap.put(user3, cart3);
|
|
215
|
+
|
|
216
|
+ // Then
|
|
217
|
+ Cart actualCart = myMap.remove(user2);
|
|
218
|
+
|
|
219
|
+ Assert.assertEquals(cart2, actualCart);
|
|
220
|
+ Assert.assertNull(myMap.get(user2));
|
|
221
|
+ }
|
|
222
|
+
|
|
223
|
+ @Test
|
|
224
|
+ public void testRemove_CartNotInTheMap(){
|
|
225
|
+ // Given
|
|
226
|
+ User user1 = new User("Lena");
|
|
227
|
+
|
|
228
|
+ // When & Then
|
|
229
|
+ Assert.assertNull(myMap.remove(user1));
|
|
230
|
+ }
|
231
|
231
|
}
|