PropertyValidator { static Map<String, Object> toMap(Dictionary dic) { HashMap<String, Object> map = new HashMap<>(); if (dic != null) { Enumeration keys = dic.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); map.put(key, dic.get(key)); } } return map; }    }
@Test public void testToMap() throws Exception { Dictionary<String, String> dic = new Hashtable<>(); dic.put("key", "value"); assertThat(toMap(dic).size(), is(1)); assertThat(toMap(dic).keySet().contains("key"), is(true)); assertThat(toMap(dic).get("key"), Is.is("value")); assertThat(toMap(null), notNullValue()); assertThat(toMap(null).size(), is(0)); }