### Question:
Sets { public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }  static final Set fromMap(Map map, Object... keys); static final Set<String> fromCommaSeparatedValues(String csv);  }### Answer:
@Test public void testFromMap() { Map m = new HashMap() {{ put("A", 1); put("B", 2); put("C", 3); }}; Set s = Sets.fromMap(m, "A", "C"); assertTrue(s.contains(1)); assertFalse(s.contains(2)); assertTrue(s.contains(3)); assertEquals(2, s.size()); }
@Test public void testFromMap_NullMap() { assertEquals(Collections.EMPTY_SET, Sets.fromMap(null, "A")); }
@Test public void testFromMap_NullKeys() { assertEquals(Collections.EMPTY_SET, Sets.fromMap(new HashMap(), null)); }
@Test public void testFromMap_MissingKey() { Map m = new HashMap() {{ put("A", 1); }}; Set s = Sets.fromMap(m, "A", "D"); assertTrue(s.contains(1)); assertEquals(1, s.size()); }
@Test public void testFromMap_KeyMappedToNull() { Map m = new HashMap() {{ put("A", 1); put("B", null); }}; Set s = Sets.fromMap(m, "A", "B"); assertTrue(s.contains(1)); assertTrue(s.contains(null)); assertEquals(2, s.size()); }