|
@@ -32,7 +32,7 @@ public class PhoneBookTest {
|
32
|
32
|
String actualPersonName = expectedPerson.getName();
|
33
|
33
|
String actualPersonPhoneNumber = expectedPerson.phoneNumberList.get(0);
|
34
|
34
|
|
35
|
|
- boolean actualPersonNameExists = this.phonebook.hashMap.containsKey("Jane");
|
|
35
|
+ boolean actualPersonNameExists = this.phonebook.treeMap.containsKey("Jane");
|
36
|
36
|
|
37
|
37
|
Assert.assertTrue(actualPersonNameExists);
|
38
|
38
|
}
|
|
@@ -42,16 +42,16 @@ public class PhoneBookTest {
|
42
|
42
|
public void addEntryTest() {
|
43
|
43
|
this.phonebook.addEntry("Adam", "(000) 000-0000", "(111) 111-1111");
|
44
|
44
|
|
45
|
|
- boolean actualPersonName = this.phonebook.hashMap.containsKey("Adam");
|
46
|
|
- boolean actualPhoneNumber = this.phonebook.hashMap.containsValue(this.phonebook.hashMap.get("Adam"));
|
|
45
|
+ boolean actualPersonName = this.phonebook.treeMap.containsKey("Adam");
|
|
46
|
+ boolean actualPhoneNumber = this.phonebook.treeMap.containsValue(this.phonebook.treeMap.get("Adam"));
|
47
|
47
|
Assert.assertTrue(actualPersonName);
|
48
|
48
|
Assert.assertTrue(actualPhoneNumber);
|
49
|
49
|
|
50
|
50
|
String expectedPhoneNumber1 = "(000) 000-0000";
|
51
|
51
|
String expectedPhoneNumber2 = "(111) 111-1111";
|
52
|
52
|
|
53
|
|
- String actualPhoneNumber1 = this.phonebook.hashMap.get("Adam").phoneNumberList.get(0);
|
54
|
|
- String actualPhoneNumber2 = this.phonebook.hashMap.get("Adam").phoneNumberList.get(1);
|
|
53
|
+ String actualPhoneNumber1 = this.phonebook.treeMap.get("Adam").phoneNumberList.get(0);
|
|
54
|
+ String actualPhoneNumber2 = this.phonebook.treeMap.get("Adam").phoneNumberList.get(1);
|
55
|
55
|
|
56
|
56
|
Assert.assertEquals(expectedPhoneNumber1, actualPhoneNumber1);
|
57
|
57
|
Assert.assertEquals(expectedPhoneNumber2, actualPhoneNumber2);
|
|
@@ -63,8 +63,8 @@ public class PhoneBookTest {
|
63
|
63
|
this.phonebook.addEntry("Bob", "(333) 444-5555");
|
64
|
64
|
this.phonebook.removeRecord("Bob");
|
65
|
65
|
|
66
|
|
- boolean actualPersonName = this.phonebook.hashMap.containsKey("Bob");
|
67
|
|
- boolean actualPersonObject = this.phonebook.hashMap.containsValue(this.phonebook.hashMap.get("Bob"));
|
|
66
|
+ boolean actualPersonName = this.phonebook.treeMap.containsKey("Bob");
|
|
67
|
+ boolean actualPersonObject = this.phonebook.treeMap.containsValue(this.phonebook.treeMap.get("Bob"));
|
68
|
68
|
|
69
|
69
|
Assert.assertFalse(actualPersonName);
|
70
|
70
|
Assert.assertFalse(actualPersonObject);
|
|
@@ -76,7 +76,7 @@ public class PhoneBookTest {
|
76
|
76
|
this.phonebook.addEntry("Gabriel", "(100) 000-0000", "(110) 000-0000");
|
77
|
77
|
|
78
|
78
|
System.out.println("getAllEntriesTest:");
|
79
|
|
- String expectedKeySet = "[Gabriel, Frank]";
|
|
79
|
+ String expectedKeySet = "[Frank, Gabriel]";
|
80
|
80
|
String actualKeySet = this.phonebook.getKeySet().toString();
|
81
|
81
|
|
82
|
82
|
Assert.assertEquals(expectedKeySet, actualKeySet);
|
|
@@ -87,12 +87,12 @@ public class PhoneBookTest {
|
87
|
87
|
this.phonebook.addEntry("Herbert", "(200) 000-0000", "(210) 000-0000");
|
88
|
88
|
this.phonebook.addEntry("Isabel", "(300) 000-0000", "(310) 000-0000");
|
89
|
89
|
|
90
|
|
- String expectedEntries = "Isabel" + "\n" +
|
91
|
|
- "\t" + "(300) 000-0000" + "\n" +
|
92
|
|
- "\t" + "(310) 000-0000" + "\n" +
|
93
|
|
- "Herbert" + "\n" +
|
|
90
|
+ String expectedEntries = "Herbert" + "\n" +
|
94
|
91
|
"\t" + "(200) 000-0000" + "\n" +
|
95
|
|
- "\t" + "(210) 000-0000" + "\n";
|
|
92
|
+ "\t" + "(210) 000-0000" + "\n" +
|
|
93
|
+ "Isabel" + "\n" +
|
|
94
|
+ "\t" + "(300) 000-0000" + "\n" +
|
|
95
|
+ "\t" + "(310) 000-0000" + "\n";
|
96
|
96
|
String actualEntries = this.phonebook.displayAllEntries().toString();
|
97
|
97
|
|
98
|
98
|
// System.out.println("displayAllEntriesTest:");
|
|
@@ -118,7 +118,7 @@ public class PhoneBookTest {
|
118
|
118
|
String expectedPhoneNumber = "(000) 111-2222";
|
119
|
119
|
|
120
|
120
|
String actualNameFromPhoneBook = "Ava";
|
121
|
|
- boolean actualPhoneNumberFromPhoneBook = this.phonebook.hashMap.get(actualNameFromPhoneBook).phoneNumberList.contains(expectedPhoneNumber);
|
|
121
|
+ boolean actualPhoneNumberFromPhoneBook = this.phonebook.treeMap.get(actualNameFromPhoneBook).phoneNumberList.contains(expectedPhoneNumber);
|
122
|
122
|
|
123
|
123
|
Assert.assertEquals(expectedName, this.phonebook.reverseLookup(givenPhoneNumber));
|
124
|
124
|
// Then
|