### Question:
PluralFormDictinary { public String lookup(String word) { for (Map.Entry<Pattern, String> entry : patternMap.entrySet()) { Pattern pattern = entry.getKey(); Matcher matcher = pattern.matcher(word); if (!matcher.matches()) { continue; } matcher.reset(); StringBuffer buf = new StringBuffer(); String replacement = entry.getValue(); for (; matcher.find();) { matcher.appendReplacement(buf, replacement); if (matcher.hitEnd()) { break; } } matcher.appendTail(buf); return buf.toString(); } return null; } PluralFormDictinary();  PluralFormDictinary(LinkedHashMap<String, String> dictinary); String lookup(String word);  }### Answer:
@Test public void testLookup() throws Exception { LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); map.put("^person$", "people"); map.put("(.*)$", "$1s"); PluralFormDictinary dictinary = new PluralFormDictinary(map); assertEquals("people", dictinary.lookup("person")); assertEquals("employees", dictinary.lookup("employee")); }
@Test public void testLookup_notFound() throws Exception { PluralFormDictinary dictinary = new PluralFormDictinary(); assertNull(dictinary.lookup("employee")); }