### Question:
FactoryRegistryImpl implements TypeFactoryRegistry<T> { @Override @SuppressWarnings("unchecked") public void register(final T item) { if (item instanceof DefinitionFactory) { definitionFactories.add((DefinitionFactory<?>) item); } else if (item instanceof ElementFactory) { registerGraphFactory((ElementFactory) item); } else if (item instanceof DiagramFactory) { diagramFactories.add((DiagramFactory<?, ?>) item); } } 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 testRegister() { DefinitionFactory definitionFactory = mock(DefinitionFactory.class); ElementFactory graphFactory = mock(ElementFactory.class); DiagramFactory diagramFactory = mock(DiagramFactory.class); Factory randomFactory = mock(Factory.class); FactoryRegistryImpl factory = new FactoryRegistryImpl(adapter); factory.register(definitionFactory); factory.register(graphFactory); factory.register(diagramFactory); factory.register(randomFactory); Collection<?> factories = factory.getAllFactories(); assertEquals(3, factories.stream().count()); }