FormatterRegistry implements FormatterFactory { public void registerClass(Class<? extends Formatter> someClass) { registerNamedFormatter(someClass); registerDefaultFormatter(someClass); } FormatterRegistry(); @SuppressWarnings("unchecked") @PostConstruct void initBuildInFormatter(); void registerClass(Class<? extends Formatter> someClass); boolean hasFormatter(String formatterName); @Override Formatter createFormatter(String name, List<String> args); @Override Formatter createDefaultFormatter(Class<?> type);  }
@Test(expected = IllegalArgumentException.class) public void registerIllegalDefaultFormatter() { final Class<IllegalDefaultFormatter> formatterClass = IllegalDefaultFormatter.class; FormatterRegistry registry = new FormatterRegistry(); registry.registerClass(formatterClass); }