@Test public void shouldThrowExceptionWhenRegisteringDuplicateEntryUsingRegisterUnique() { mapRepository = new MapRepository<Object>(Object.class, new LinkedHashMap<RepositoryObjectKey, Object>()); mapRepository.registerUnique("TEST", new Object()); catchException(mapRepository).registerUnique("TEST", new Object()); assertThat(caughtException()).isInstanceOf(NonUniqueItemRegisteredException.class); }
public void registerUnique(RepositoryObjectKey key, V value) { if (repositoryMap.containsKey(key)) { throw new NonUniqueItemRegisteredException(containedClass, key); } register(key, value); }
MapRepository { public void registerUnique(RepositoryObjectKey key, V value) { if (repositoryMap.containsKey(key)) { throw new NonUniqueItemRegisteredException(containedClass, key); } register(key, value); } }
MapRepository { public void registerUnique(RepositoryObjectKey key, V value) { if (repositoryMap.containsKey(key)) { throw new NonUniqueItemRegisteredException(containedClass, key); } register(key, value); } MapRepository(Class<?> containedClass);  MapRepository(Class<?> containedClass, Map<RepositoryObjectKey, V> repositoryMapInstance); }
MapRepository { public void registerUnique(RepositoryObjectKey key, V value) { if (repositoryMap.containsKey(key)) { throw new NonUniqueItemRegisteredException(containedClass, key); } register(key, value); } MapRepository(Class<?> containedClass);  MapRepository(Class<?> containedClass, Map<RepositoryObjectKey, V> repositoryMapInstance); boolean contains(RepositoryObjectKey key); boolean contains(String key); V getItem(RepositoryObjectKey key); V getItem(String key); void register(RepositoryObjectKey key, V value); void register(String key, V value); void registerUnique(RepositoryObjectKey key, V value); void registerUnique(String key, V value); void registerAll(Map<RepositoryObjectKey, V> items); void registerAllOrdered(Map<String, V> items); void registerAllUnordered(Map<String, V> items); Map<String, V> getItemsUnordered(); Map<String, V> getItemsOrdered(); }
MapRepository { public void registerUnique(RepositoryObjectKey key, V value) { if (repositoryMap.containsKey(key)) { throw new NonUniqueItemRegisteredException(containedClass, key); } register(key, value); } MapRepository(Class<?> containedClass);  MapRepository(Class<?> containedClass, Map<RepositoryObjectKey, V> repositoryMapInstance); boolean contains(RepositoryObjectKey key); boolean contains(String key); V getItem(RepositoryObjectKey key); V getItem(String key); void register(RepositoryObjectKey key, V value); void register(String key, V value); void registerUnique(RepositoryObjectKey key, V value); void registerUnique(String key, V value); void registerAll(Map<RepositoryObjectKey, V> items); void registerAllOrdered(Map<String, V> items); void registerAllUnordered(Map<String, V> items); Map<String, V> getItemsUnordered(); Map<String, V> getItemsOrdered();  }