### Question:
GlobalAddressBook { public String addContact(Contact contact) { if(contact.getFirstName() == null) { throw new InvalidContactException(); } if(contact.getFirstName().length() < 1 && contact.getFirstName().trim().length() < 1) { throw new InvalidContactException(); } String id = idGenerator.newId(); contact.setId(id); addressBookMap.put(id, contact); return id; }  String addContact(Contact contact); List<Contact> getAll(); Contact getContact(String contactId); IdGenerator getIdGenerator(); void setIdGenerator(IdGenerator idGenerator);  }### Answer:
@Test public void testAddContact() { expectedContact.setFirstName("Pedro"); addressBook.addContact(expectedContact); List<Contact> contacts = addressBook.getAll(); assertEquals(1, contacts.size()); assertEquals("Pedro", contacts.get(0).getFirstName()); }
@Test(expected=InvalidContactException.class) public void testAddWithoutFirstName() { expectedContact.setSurname("Ballesteros"); addressBook.addContact(expectedContact); }