DozerBeanContainer implements BeanRegistry { public <T> T getBean(Class<T> type) { Collection<T> result = getBeans(type); if (result.isEmpty()) { throw new IllegalStateException("Bean is not registered : " + type.getName()); } if (result.size() > 1) { throw new IllegalStateException("More than one bean found of type : " + type.getName()); } return result.iterator().next(); }  void register(Class<?> type); T getBean(Class<T> type); Collection<T> getBeans(Class<T> type);  }
@Test(expected = IllegalStateException.class) public void notRegistered() { container.getBean(String.class); }