### Question:
SecretSantaFinder { public Map<String, String> pair() { List<Family> families = new ArrayList<Family>(); if(2*maxFamilyMembers > totalNames){ return null; } for(String key: familyMembers.keySet()) { families.add(familyMembers.get(key)) ; } Collections.sort(families); List<String> receiveList = new ArrayList<String>(totalNames); List<String> sendList = new ArrayList<String>(totalNames); List<String> largestFamilyMembers = new ArrayList<String>(); Map<String, String> secretList = new HashMap<String,String>(); for(int i=0;i < families.size();i++) { List<String> names = families.get(i).members; receiveList.addAll(names); if(i== 0) { largestFamilyMembers = names; } else { sendList.addAll(names); } } sendList.addAll(largestFamilyMembers); for(int i=0;i < sendList.size();i++) { secretList.put(sendList.get(i), receiveList.get(i)); } return secretList; } SecretSantaFinder(String[] lists); Map<String, String> pair(); static void main(String[] args);  }### Answer:
@Test public void testTooManyInAFamily() { String names = "A Smith, B Smith, C Smith, D Andersen, E Andersen"; String[] nameList = names.split(","); SecretSantaFinder ssf = new SecretSantaFinder(nameList); assertEquals(ssf.pair(), null); }
@Test public void testUnique() { String names = "A Smith, B Smith, C Smith, D Andersen, E Andersen,F Andersen, G Jackson"; String[] nameList = names.split(","); SecretSantaFinder ssf = new SecretSantaFinder(nameList); Map<String,String> pairs = ssf.pair(); assertEquals(pairs.size(), 7); for(String key: pairs.keySet()) { assertFalse(key.equals(pairs.get(key))); String[] giver = key.split(" "); String[] receiver = pairs.get(key).split(" "); assertFalse(giver[1].equals(receiver[1])); } }