Search in sources :

Example 1 with BPMNTestDefinitionFactory

use of org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory in project kie-wb-common by kiegroup.

the class GraphBuilderTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    when(diagram.getPlane()).thenReturn(plane);
    List<RootElement> rootElements = Collections.singletonList(process);
    List<BPMNDiagram> diagrams = Collections.singletonList(diagram);
    when(definitions.getId()).thenReturn(DIAGRAM_UUID);
    when(definitions.getRootElements()).thenReturn(rootElements);
    when(definitions.getDiagrams()).thenReturn(diagrams);
    when(definitions.getRelationships()).thenReturn(Collections.emptyList());
    definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
    StunnerTestingGraphBackendAPI api = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory());
    TypedFactoryManager typedFactoryManager = new TypedFactoryManager(api.getFactoryManager());
    Metadata metadata = new MetadataImpl.MetadataImplBuilder(BindableAdapterUtils.getDefinitionSetId(BPMNDefinitionSet.class)).build();
    Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = api.getFactoryManager().newDiagram(definitionResolver.getDefinitions().getId(), BPMN_ID, metadata);
    graph = diagram.getGraph();
    graphBuilder = new GraphBuilder(graph, api.getDefinitionManager(), typedFactoryManager, api.getRuleManager(), api.commandFactory, api.commandManager);
}
Also used : TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) StunnerTestingGraphBackendAPI(org.kie.workbench.common.stunner.core.backend.StunnerTestingGraphBackendAPI) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) RootElement(org.eclipse.bpmn2.RootElement) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Before(org.junit.Before)

Example 2 with BPMNTestDefinitionFactory

use of org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method setUp.

@Before
public void setUp() throws Exception {
    parentNode = new BpmnNode.Simple(new NodeImpl<>("ParentNode"), basePropertyReader);
    when(diagram.getPlane()).thenReturn(plane);
    List<RootElement> rootElements = Collections.singletonList(process);
    List<BPMNDiagram> diagrams = Collections.singletonList(diagram);
    when(definitions.getRootElements()).thenReturn(rootElements);
    when(definitions.getDiagrams()).thenReturn(diagrams);
    when(definitions.getRelationships()).thenReturn(Collections.emptyList());
    when(plane.getPlaneElement()).thenReturn(new ArrayList<>());
    definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
    StunnerTestingGraphBackendAPI api = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory());
    TypedFactoryManager typedFactoryManager = new TypedFactoryManager(api.getFactoryManager());
    factory = new ConverterFactory(definitionResolver, typedFactoryManager);
    converterDelegate = new ProcessConverterDelegate(typedFactoryManager, propertyReaderFactory, definitionResolver, factory);
}
Also used : TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) StunnerTestingGraphBackendAPI(org.kie.workbench.common.stunner.core.backend.StunnerTestingGraphBackendAPI) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) BaseConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) RootElement(org.eclipse.bpmn2.RootElement) Before(org.junit.Before)

Example 3 with BPMNTestDefinitionFactory

use of org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerBaseTest method init.

@SuppressWarnings("unchecked")
protected void init() {
    initMocks(this);
    cloneManager = mock(CloneManager.class);
    try {
        api = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory());
    } catch (Exception e) {
        fail("Cannot instantiate DefinitionSet [message=" + e.getMessage() + "]");
    }
    BackendBindableMorphAdapter<Object> morphAdapter = new BackendBindableMorphAdapter(api.getDefinitionUtils(), api.getFactoryManager(), cloneManager, singletonList(new BaseTaskMorphPropertyDefinition()));
    doReturn(morphAdapter).when(api.getAdapterRegistry()).getMorphAdapter(eq(UserTask.class));
    doReturn(morphAdapter).when(api.getAdapterRegistry()).getMorphAdapter(eq(NoneTask.class));
    doReturn(morphAdapter).when(api.getAdapterRegistry()).getMorphAdapter(eq(ScriptTask.class));
    doReturn(morphAdapter).when(api.getAdapterRegistry()).getMorphAdapter(eq(BusinessRuleTask.class));
    workItemDefinitionMockRegistry = new WorkItemDefinitionMockRegistry();
    WorkItemDefinitionLookupService widService = mock(WorkItemDefinitionLookupService.class);
    when(widService.execute(any(Metadata.class))).thenReturn(workItemDefinitionMockRegistry.items());
    marshaller = new BPMNDirectDiagramMarshaller(new XMLEncoderDiagramMetadataMarshaller(), api.getDefinitionManager(), api.getRuleManager(), widService, api.getFactoryManager(), api.commandFactory, api.commandManager, dataTypeCacheServer);
}
Also used : CloneManager(org.kie.workbench.common.stunner.core.definition.clone.CloneManager) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) WorkItemDefinitionMockRegistry(org.kie.workbench.common.stunner.bpmn.WorkItemDefinitionMockRegistry) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BackendBindableMorphAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.bind.BackendBindableMorphAdapter) WorkItemDefinitionLookupService(org.kie.workbench.common.stunner.bpmn.workitem.service.WorkItemDefinitionLookupService) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) BPMNDirectDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller) BaseTaskMorphPropertyDefinition(org.kie.workbench.common.stunner.bpmn.definition.morph.BaseTaskMorphPropertyDefinition)

Example 4 with BPMNTestDefinitionFactory

use of org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    // Setup context.
    widRegistry = new WorkItemDefinitionMockRegistry();
    widService = mock(WorkItemDefinitionLookupService.class);
    when(widService.execute(any(Metadata.class))).thenReturn(widRegistry.items());
    stunnerAPI = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory(widRegistry));
    xmlEncoder = new XMLEncoderDiagramMetadataMarshaller();
    // Setup tested instance.
    tested = new BPMNDirectDiagramMarshaller(xmlEncoder, stunnerAPI.getDefinitionManager(), stunnerAPI.getRuleManager(), widService, stunnerAPI.getFactoryManager(), stunnerAPI.commandFactory, stunnerAPI.commandManager, dataTypeCacheServer);
}
Also used : WorkItemDefinitionLookupService(org.kie.workbench.common.stunner.bpmn.workitem.service.WorkItemDefinitionLookupService) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) BPMNDirectDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) WorkItemDefinitionMockRegistry(org.kie.workbench.common.stunner.bpmn.WorkItemDefinitionMockRegistry) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Before(org.junit.Before)

Example 5 with BPMNTestDefinitionFactory

use of org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory in project kie-wb-common by kiegroup.

the class NoWIDCustomTaskResolutionTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    // Setup context.
    widRegistry = new WorkItemDefinitionRegistry() {

        @Override
        public Collection<WorkItemDefinition> items() {
            return Collections.EMPTY_LIST;
        }

        @Override
        public WorkItemDefinition get(String name) {
            return null;
        }
    };
    widService = mock(WorkItemDefinitionLookupService.class);
    when(widService.execute(any(Metadata.class))).thenReturn(widRegistry.items());
    stunnerAPI = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory(widRegistry));
    xmlEncoder = new XMLEncoderDiagramMetadataMarshaller();
    // Setup tested instance.
    tested = new BPMNDirectDiagramMarshaller(xmlEncoder, stunnerAPI.getDefinitionManager(), stunnerAPI.getRuleManager(), widService, stunnerAPI.getFactoryManager(), stunnerAPI.commandFactory, stunnerAPI.commandManager, dataTypeCacheServer);
    diagram = Unmarshalling.unmarshall(tested, BPMN_CUSTOM_TASK);
}
Also used : WorkItemDefinitionLookupService(org.kie.workbench.common.stunner.bpmn.workitem.service.WorkItemDefinitionLookupService) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) BPMNDirectDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Collection(java.util.Collection) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) Before(org.junit.Before)

Aggregations

BPMNTestDefinitionFactory (org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory)5 Before (org.junit.Before)4 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)4 BPMNDefinitionSet (org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet)3 BPMNDirectDiagramMarshaller (org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller)3 WorkItemDefinitionLookupService (org.kie.workbench.common.stunner.bpmn.workitem.service.WorkItemDefinitionLookupService)3 XMLEncoderDiagramMetadataMarshaller (org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller)3 RootElement (org.eclipse.bpmn2.RootElement)2 BPMNDiagram (org.eclipse.bpmn2.di.BPMNDiagram)2 WorkItemDefinitionMockRegistry (org.kie.workbench.common.stunner.bpmn.WorkItemDefinitionMockRegistry)2 TypedFactoryManager (org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager)2 StunnerTestingGraphBackendAPI (org.kie.workbench.common.stunner.core.backend.StunnerTestingGraphBackendAPI)2 Collection (java.util.Collection)1 BaseConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory)1 BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)1 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory)1 DefinitionResolver (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver)1 BusinessRuleTask (org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask)1 NoneTask (org.kie.workbench.common.stunner.bpmn.definition.NoneTask)1 ScriptTask (org.kie.workbench.common.stunner.bpmn.definition.ScriptTask)1