import static 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 { PhoneBook phoneBook = new PhoneBook(); public Map input = new TreeMap(); /** * Default constructor for test class PhoneBookTest */ @Test public void testConstructor() { PhoneBook phoneBook = new PhoneBook(); } @Test public void testAddingPhoneNumber(){ input.put("Amy","232-323-3233"); int expectedSize = 1; int actual1 = input.size(); //When assertEquals(expectedSize,actual1); } @Test public void testRemovingPhoneNumber(){ //Given input.put("Amy","232-323-3233"); //Then String expected = null; String actual = phoneBook.remove("Amy"); //When assertEquals(expected,actual); } @Test public void testLookUp(){ input.put("Amy","232-323-3233"); input.put("John","243-567-9963"); input.put("Brian","555-555-5555"); String expected = "Amy"+"232-323-3233"; boolean key = false; if(input.containsKey("Amy")){ key = true; } assertTrue(key); } @Test public void testReverseLookUp(){ input.put("Amy","232-323-3233"); input.put("John","243-567-9963"); input.put("Brian","555-555-5555"); String expected = "Amy"+"232-323-3233"; boolean value = false; if(input.containsValue("232-323-3233")){ value = true; } assertTrue(value); } }