### Question:
AddressFetcher { public Map<Role, List<InternetAddress>> getProgramEmails(SPProgramID progId, IDBDatabaseService db) { ISPProgram prog = db.lookupProgramByID(progId); if (prog == null) return EMPTY_ADDRESS_MAP; SPProgram dataObj = (SPProgram) prog.getDataObject(); Map<Role, List<InternetAddress>> res = new TreeMap<Role, List<InternetAddress>>(); res.put(Role.NGO, Collections.unmodifiableList(parseAddresses(dataObj.getPrimaryContactEmail(), progId))); res.put(Role.CS, Collections.unmodifiableList(parseAddresses(dataObj.getContactPerson(), progId))); SPProgram.PIInfo piInfo = dataObj.getPIInfo(); if (piInfo == null) { res.put(Role.PI, EMPTY_ADDRESS_LIST); } else { res.put(Role.PI, Collections.unmodifiableList(parseAddresses(piInfo.getEmail(), progId))); } return res; } private  AddressFetcher(); static List<InternetAddress> parseAddresses(String addrListStr, SPProgramID progId); Map<Role, List<InternetAddress>> getProgramEmails(SPProgramID progId, IDBDatabaseService db); static final AddressFetcher INSTANCE; }### Answer:
@Test public void testEmpty() { progBuilder.build(); Map<AddressFetcher.Role, List<InternetAddress>> res; res = AddressFetcher.INSTANCE.getProgramEmails(progId, odb); assertEmails(new String[0], res.get(AddressFetcher.Role.PI)); assertEmails(new String[0], res.get(AddressFetcher.Role.NGO)); assertEmails(new String[0], res.get(AddressFetcher.Role.CS)); }
@Test public void testOne() { progBuilder.pi("swalker@gemini.edu").ngo("swalker2m@mac.com").cs("swalker2m@yahoo.com").build(); Map<AddressFetcher.Role, List<InternetAddress>> res; res = AddressFetcher.INSTANCE.getProgramEmails(progId, odb); assertEmails(new String[] {"swalker@gemini.edu"}, res.get(AddressFetcher.Role.PI)); assertEmails(new String[] {"swalker2m@mac.com" }, res.get(AddressFetcher.Role.NGO)); assertEmails(new String[] {"swalker2m@yahoo.com"}, res.get(AddressFetcher.Role.CS)); }
@Test public void testMultiple() { progBuilder.pi("swalker@gemini.edu, swalker2m@mac.com").cs("swalker2m@yahoo.com").build(); Map<AddressFetcher.Role, List<InternetAddress>> res; res = AddressFetcher.INSTANCE.getProgramEmails(progId, odb); assertEmails(new String[] {"swalker@gemini.edu", "swalker2m@mac.com"}, res.get(AddressFetcher.Role.PI)); assertEmails(new String[0], res.get(AddressFetcher.Role.NGO)); assertEmails(new String[] {"swalker2m@yahoo.com"}, res.get(AddressFetcher.Role.CS)); }