import org.junit.Assert; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.*; /** * The test class PhoneBookTest. * * @author (your name) * @version (a version number or a date) */ public class PhoneBookTest { TreeMap phoneBook = new TreeMap<>(); /** * Default constructor for test class PhoneBookTest */ public PhoneBookTest() { } /** * Sets up the test fixture. * * Called before every test case method. */ @Before public void setUp() { PhoneBook pb = new PhoneBook(phoneBook); } /** * Tears down the test fixture. * * Called after every test case method. */ @After public void tearDown() { } // add entries @Test public void testOne() { String expected = "Dog 222-444-5555\nZebra 111-222-3333\n"; PhoneBook pb = new PhoneBook(phoneBook); pb.add("Zebra", "111-222-3333"); pb.add("Dog", "222-444-5555"); String actual = pb.display(); Assert.assertEquals(expected, actual); } @Test public void testTwo() { String expected = "Dog 222-444-5555\n"; PhoneBook pb = new PhoneBook(phoneBook); pb.add("Zebra", "111-222-3333"); pb.add("Dog", "222-444-5555"); pb.remove("Zebra"); String actual = pb.display(); Assert.assertEquals(expected, actual); } @Test public void TestThree() { String expected = "222-444-5555"; PhoneBook pb = new PhoneBook(phoneBook); pb.add("Zebra", "111-222-3333"); pb.add("Dog", "222-444-5555"); String actual = pb.lookup("Dog"); Assert.assertEquals(expected, actual); } @Test public void TestFour() { String expected = "Dog"; PhoneBook pb = new PhoneBook(phoneBook); pb.add("Zebra", "111-222-3333"); pb.add("Dog", "222-444-5555"); String actual = pb.reverseLookup("222-444-5555"); Assert.assertEquals(expected, actual); } }