Search in sources :

Example 1 with ElementFactory

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));
}
Also used : GraphFactory(org.kie.workbench.common.stunner.core.factory.graph.GraphFactory) ElementFactory(org.kie.workbench.common.stunner.core.factory.graph.ElementFactory) Test(org.junit.Test)

Example 2 with ElementFactory

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());
}
Also used : DiagramFactory(org.kie.workbench.common.stunner.core.factory.diagram.DiagramFactory) DiagramFactory(org.kie.workbench.common.stunner.core.factory.diagram.DiagramFactory) Factory(org.kie.workbench.common.stunner.core.factory.Factory) DefinitionFactory(org.kie.workbench.common.stunner.core.factory.definition.DefinitionFactory) GraphFactory(org.kie.workbench.common.stunner.core.factory.graph.GraphFactory) ElementFactory(org.kie.workbench.common.stunner.core.factory.graph.ElementFactory) DefinitionFactory(org.kie.workbench.common.stunner.core.factory.definition.DefinitionFactory) ElementFactory(org.kie.workbench.common.stunner.core.factory.graph.ElementFactory) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ElementFactory (org.kie.workbench.common.stunner.core.factory.graph.ElementFactory)2 GraphFactory (org.kie.workbench.common.stunner.core.factory.graph.GraphFactory)2 Factory (org.kie.workbench.common.stunner.core.factory.Factory)1 DefinitionFactory (org.kie.workbench.common.stunner.core.factory.definition.DefinitionFactory)1 DiagramFactory (org.kie.workbench.common.stunner.core.factory.diagram.DiagramFactory)1