DefaultPluginContext implements PluginContext { @Override @Nullable public <T> T removePlugin(T plugin) { Objects.requireNonNull(plugin, "Plugin to remove cannot be null"); final String name = AnnotationProcessor.getPluginName(plugin); return removePlugin(name); } DefaultPluginContext();  DefaultPluginContext(Map<String, Object> registry); @Override @Nullable T getPlugin(String pluginName); @Override @Nullable T getPlugin(Class<T> pluginClass); @Override Collection<PluginRef> getAllPlugins(); @Override void addPlugin(T plugin); @Override void addPlugin(String name, T plugin); @Override @Nullable T removePlugin(T plugin); @Override @Nullable T removePlugin(String pluginName); @Override boolean hasPlugin(String pluginName); @Override boolean hasPlugin(Class<T> pluginClass);  }
@Test public void shouldRemovePluginFromName() { registry.put("test", plugin); final TestPlugin test = context.removePlugin("test"); assertFalse(registry.containsKey("test")); assertEquals(plugin, test); }
@Test public void shouldRemovePluginFromInstance() { registry.put("test", plugin); final TestPlugin test = context.removePlugin(plugin); assertFalse(registry.containsKey("test")); assertEquals(plugin, test); }