### Question:
FactoryRegistryImpl implements TypeFactoryRegistry<T> { @Override public boolean remove(final T item) { if (item instanceof DefinitionFactory) { return definitionFactories.remove(item); } else if (item instanceof ElementFactory) { return null != graphFactories.remove(((ElementFactory) item).getFactoryType()); } else if (item instanceof DiagramFactory) { return diagramFactories.remove(item); } return false; } FactoryRegistryImpl(final AdapterManager adapterManager); @Override DefinitionFactory<?> getDefinitionFactory(final String id); @Override ElementFactory<?, ?, ?> getElementFactory(final Class<? extends ElementFactory> type); @Override @SuppressWarnings("unchecked") DiagramFactory<?, ?> getDiagramFactory(final String defSetId,
                                                  final Class<? extends Metadata> metadataType); @Override @SuppressWarnings("unchecked") void register(final T item); @Override boolean remove(final T item); @Override void clear(); @Override boolean contains(final T item); @Override boolean isEmpty(); @Override @SuppressWarnings("unchecked") Collection<T> getAllFactories(); @Override DefinitionFactory<?> getDefinitionFactory(final Class<?> type);  }### Answer:
@Test public void testRemove() { tested.register(elementFactory); tested.register(definitionFactory); assertFalse(tested.remove(missingFactory)); assertTrue(tested.contains(elementFactory)); assertTrue(tested.contains(definitionFactory)); assertTrue(tested.remove(elementFactory)); assertFalse(tested.contains(elementFactory)); assertTrue(tested.contains(definitionFactory)); assertFalse(tested.remove(null)); assertTrue(tested.contains(definitionFactory)); assertTrue(tested.remove(definitionFactory)); assertFalse(tested.contains(definitionFactory)); assertArrayEquals(new Object[0], tested.getAllFactories().toArray()); }