### Question:
DbAddressBook implements GlobalAddressBook { @Override public Contact getContact(String contactId) { Contact result = addressBookDao.getContact(contactId); if (result == null) { throw new InvalidIdException(); } return result; }  @Override String addContact(Contact contact); @Override Contact getContact(String contactId); AddressBookDao getAddressBookDao(); void setAddressBookDao(AddressBookDao addressBookDao); @Override List<Contact> getAll(); @Override void deleteContact(String id);  }### Answer:
@Test public void testGetSimpleContact() { expectedContact.setFirstName("Pedro"); when(mockAddressBookDao.getContact("idcontact")).thenReturn(expectedContact); Contact actualContact = addressBook.getContact("idcontact"); assertEquals("Pedro", actualContact.getFirstName()); }
@Test public void testGetContactInvalidId() { try { addressBook.getContact("INVALID"); fail("InvalidIdException expected"); } catch(InvalidIdException ex) { assertTrue(true); } }