use of org.kie.workbench.common.stunner.core.factory.graph.ElementFactory in project kie-wb-common by kiegroup.
the class FactoryRegistryImplTest method testRegisterGraphFactory.
@Test
public void testRegisterGraphFactory() {
Class<? extends ElementFactory> factoryType = GraphFactory.class;
ElementFactory graphFactory1 = createGraphFactory(factoryType);
ElementFactory graphFactory2 = createGraphFactory(factoryType);
ElementFactory delegateGraphFactory = createDelegateGraphFactory(factoryType);
FactoryRegistryImpl factory = new FactoryRegistryImpl(adapter);
factory.register(null);
assertTrue(factory.getAllFactories().isEmpty());
factory.registerGraphFactory(graphFactory1);
assertEquals(graphFactory1, factory.getElementFactory(factoryType));
factory.clear();
factory.registerGraphFactory(delegateGraphFactory);
assertEquals(delegateGraphFactory, factory.getElementFactory(factoryType));
factory.clear();
factory.registerGraphFactory(graphFactory1);
factory.registerGraphFactory(graphFactory2);
assertEquals(graphFactory1, factory.getElementFactory(factoryType));
factory.registerGraphFactory(graphFactory1);
factory.registerGraphFactory(delegateGraphFactory);
assertEquals(delegateGraphFactory, factory.getElementFactory(factoryType));
}
use of org.kie.workbench.common.stunner.core.factory.graph.ElementFactory in project kie-wb-common by kiegroup.
the class FactoryRegistryImplTest method testRegister.
@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());
}
Aggregations