### Question:
MapRegistry implements DynamicRegistry<T> { public T getItemByKey(final String key) { return items.get(key); } MapRegistry(final KeyProvider<T> keyProvider,
                final Map<String, T> items); @Override void register(final T item); boolean remove(final T item); @Override boolean contains(final T item); @Override boolean isEmpty(); Collection<T> getItems(); void clear(); T getItemByKey(final String key);  }### Answer:
@Test public void testGetItemByKey() { final String s1 = "an string 1"; final String s2 = "an string 2"; tested = new MapRegistry<Object>(keyProvider, new HashMap<String, Object>(2) {{ put(s1, s1); put(s2, s2); }}); Object o1 = tested.getItemByKey(s1); Object o2 = tested.getItemByKey(s2); assertEquals(s1, o1); assertEquals(s2, o2); }