@Test public void registerByInstanceNull() { when(registry).register((LanguageDriver) null); then(caughtException()).isInstanceOf(IllegalArgumentException.class) .hasMessage("null is not a valid Language Driver"); }
public void register(Class<? extends LanguageDriver> cls) { if (cls == null) { throw new IllegalArgumentException("null is not a valid Language Driver"); } if (!LANGUAGE_DRIVER_MAP.containsKey(cls)) { try { LANGUAGE_DRIVER_MAP.put(cls, cls.newInstance()); } catch (Exception ex) { throw new ScriptingException("Failed to load language driver for " + cls.getName(), ex); } } }
LanguageDriverRegistry { public void register(Class<? extends LanguageDriver> cls) { if (cls == null) { throw new IllegalArgumentException("null is not a valid Language Driver"); } if (!LANGUAGE_DRIVER_MAP.containsKey(cls)) { try { LANGUAGE_DRIVER_MAP.put(cls, cls.newInstance()); } catch (Exception ex) { throw new ScriptingException("Failed to load language driver for " + cls.getName(), ex); } } } }
LanguageDriverRegistry { public void register(Class<? extends LanguageDriver> cls) { if (cls == null) { throw new IllegalArgumentException("null is not a valid Language Driver"); } if (!LANGUAGE_DRIVER_MAP.containsKey(cls)) { try { LANGUAGE_DRIVER_MAP.put(cls, cls.newInstance()); } catch (Exception ex) { throw new ScriptingException("Failed to load language driver for " + cls.getName(), ex); } } }  }
LanguageDriverRegistry { public void register(Class<? extends LanguageDriver> cls) { if (cls == null) { throw new IllegalArgumentException("null is not a valid Language Driver"); } if (!LANGUAGE_DRIVER_MAP.containsKey(cls)) { try { LANGUAGE_DRIVER_MAP.put(cls, cls.newInstance()); } catch (Exception ex) { throw new ScriptingException("Failed to load language driver for " + cls.getName(), ex); } } }  void register(Class<? extends LanguageDriver> cls); void register(LanguageDriver instance); LanguageDriver getDriver(Class<? extends LanguageDriver> cls); LanguageDriver getDefaultDriver(); Class<? extends LanguageDriver> getDefaultDriverClass(); void setDefaultDriverClass(Class<? extends LanguageDriver> defaultDriverClass); }
LanguageDriverRegistry { public void register(Class<? extends LanguageDriver> cls) { if (cls == null) { throw new IllegalArgumentException("null is not a valid Language Driver"); } if (!LANGUAGE_DRIVER_MAP.containsKey(cls)) { try { LANGUAGE_DRIVER_MAP.put(cls, cls.newInstance()); } catch (Exception ex) { throw new ScriptingException("Failed to load language driver for " + cls.getName(), ex); } } }  void register(Class<? extends LanguageDriver> cls); void register(LanguageDriver instance); LanguageDriver getDriver(Class<? extends LanguageDriver> cls); LanguageDriver getDefaultDriver(); Class<? extends LanguageDriver> getDefaultDriverClass(); void setDefaultDriverClass(Class<? extends LanguageDriver> defaultDriverClass);  }