Search in sources :

Example 76 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method assertConditionLanguage.

private void assertConditionLanguage(Diagram<Graph, Metadata> diagram, String id, String value) {
    List<Node> nodes = getNodes(diagram);
    Optional<SequenceFlow> sequenceFlow = Stream.concat(nodes.stream().flatMap(node -> {
        List<Edge> d = node.getInEdges();
        return d.stream();
    }), nodes.stream().flatMap(node -> {
        List<Edge> d = node.getOutEdges();
        return d.stream();
    })).filter(edge -> edge.getUUID().equals(id)).map(node -> (View) node.getContent()).filter(view -> view.getDefinition() instanceof SequenceFlow).map(view -> ((SequenceFlow) view.getDefinition())).findFirst();
    String conditionLanguage = (sequenceFlow.isPresent() ? sequenceFlow.get().getExecutionSet().getConditionExpression().getValue().getLanguage() : null);
    assertEquals(value, conditionLanguage);
}
Also used : Arrays(java.util.Arrays) BPMNGraphObjectBuilderFactory(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.builder.BPMNGraphObjectBuilderFactory) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) AssignmentsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssignmentsTypeSerializer) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) EndErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.EndErrorEvent) Edge(org.kie.workbench.common.stunner.core.graph.Edge) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BackendDefinitionSetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionSetAdapter) Bpmn2OryxPropertySerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertySerializer) EdgeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.EdgeFactoryImpl) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) BPMNDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDiagramMarshaller) Mockito.doAnswer(org.mockito.Mockito.doAnswer) GraphFactory(org.kie.workbench.common.stunner.core.factory.graph.GraphFactory) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) EndTerminateEvent(org.kie.workbench.common.stunner.bpmn.definition.EndTerminateEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) NodeFactory(org.kie.workbench.common.stunner.core.factory.graph.NodeFactory) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext) ColorTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ColorTypeSerializer) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) IntegerTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.IntegerTypeSerializer) StandardCharsets(java.nio.charset.StandardCharsets) Bpmn2OryxPropertyManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager) MorphDefinition(org.kie.workbench.common.stunner.core.definition.morph.MorphDefinition) Matchers.any(org.mockito.Matchers.any) Stream(java.util.stream.Stream) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) Assert.assertFalse(org.junit.Assert.assertFalse) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) InputOutputSpecification(org.eclipse.bpmn2.InputOutputSpecification) Mockito.mock(org.mockito.Mockito.mock) Bpmn2OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) ScriptTypeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Mock(org.mockito.Mock) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) GraphCommandManager(org.kie.workbench.common.stunner.core.graph.command.GraphCommandManager) RunWith(org.junit.runner.RunWith) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) GraphCommandManagerImpl(org.kie.workbench.common.stunner.core.graph.command.GraphCommandManagerImpl) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) CloneManager(org.kie.workbench.common.stunner.core.definition.clone.CloneManager) Matchers.anyString(org.mockito.Matchers.anyString) ArrayList(java.util.ArrayList) DataInput(org.eclipse.bpmn2.DataInput) Property(org.eclipse.bpmn2.Property) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) BackendDefinitionAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionAdapter) MapIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndexBuilder) InterruptingSignalEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.InterruptingSignalEventExecutionSet) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) AdapterManager(org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager) Before(org.junit.Before) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) NodeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.NodeFactoryImpl) MetaDataType(org.jboss.drools.MetaDataType) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) Assert.assertTrue(org.junit.Assert.assertTrue) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Test(org.junit.Test) AdapterRegistry(org.kie.workbench.common.stunner.core.registry.definition.AdapterRegistry) InterruptingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.InterruptingErrorEventExecutionSet) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) TimerSettingsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer) Graph(org.kie.workbench.common.stunner.core.graph.Graph) IntermediateMessageEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventThrowing) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Assert.assertNull(org.junit.Assert.assertNull) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) IsInterrupting(org.kie.workbench.common.stunner.bpmn.definition.property.event.IsInterrupting) BackendPropertyAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertyAdapter) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) BackendBindableMorphAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.bind.BackendBindableMorphAdapter) BeanManager(javax.enterprise.inject.spi.BeanManager) FlowElement(org.eclipse.bpmn2.FlowElement) Assert.assertEquals(org.junit.Assert.assertEquals) RootElement(org.eclipse.bpmn2.RootElement) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) UserTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.UserTaskExecutionSet) Activity(org.eclipse.bpmn2.Activity) GraphIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.GraphIndexBuilder) DefaultRuleViolations(org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations) BooleanTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.BooleanTypeSerializer) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) ByteArrayInputStream(java.io.ByteArrayInputStream) Matchers.eq(org.mockito.Matchers.eq) DataOutput(org.eclipse.bpmn2.DataOutput) EStructuralFeatureImpl(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) DoubleTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.DoubleTypeSerializer) Collection(java.util.Collection) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) ServiceTask(org.kie.workbench.common.stunner.bpmn.workitem.ServiceTask) ScriptTypeListTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) BackendPropertySetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertySetAdapter) TaskTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TaskTypeSerializer) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) EdgeFactory(org.kie.workbench.common.stunner.core.factory.graph.EdgeFactory) InterruptingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.InterruptingTimerEventExecutionSet) TaskTypes(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskTypes) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) List(java.util.List) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) Optional(java.util.Optional) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) StringTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.StringTypeSerializer) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) Element(org.kie.workbench.common.stunner.core.graph.Element) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) LinkedList(java.util.LinkedList) EnumTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.EnumTypeSerializer) GraphFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.GraphFactoryImpl) Definitions(org.eclipse.bpmn2.Definitions) Process(org.eclipse.bpmn2.Process) Iterator(java.util.Iterator) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) Assert.assertNotNull(org.junit.Assert.assertNotNull) InclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.InclusiveGateway) Mockito.when(org.mockito.Mockito.when) AdHocSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocSubprocessTaskExecutionSet) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) TestScopeModelFactory(org.kie.workbench.common.stunner.backend.definition.factory.TestScopeModelFactory) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) BackendFactoryManager(org.kie.workbench.common.stunner.core.backend.BackendFactoryManager) Bpmn2OryxManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager) WorkItemDefinitionBackendRegistry(org.kie.workbench.common.stunner.bpmn.backend.workitem.WorkItemDefinitionBackendRegistry) ElementFactory(org.kie.workbench.common.stunner.core.factory.graph.ElementFactory) ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) RuleManager(org.kie.workbench.common.stunner.core.rule.RuleManager) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) VariablesTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.VariablesTypeSerializer) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) InputStream(java.io.InputStream) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) InterruptingMessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.InterruptingMessageEventExecutionSet) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Node(org.kie.workbench.common.stunner.core.graph.Node) Matchers.anyString(org.mockito.Matchers.anyString) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 77 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMagnetDockers.

private void testMagnetDockers(Diagram<Graph, Metadata> diagram) throws Exception {
    Node userTaskNode = (Node) findElementByContentType(diagram, UserTask.class);
    Node businessRuleTaskNode = (Node) findElementByContentType(diagram, BusinessRuleTask.class);
    Node scriptTaskNode = (Node) findElementByContentType(diagram, ScriptTask.class);
    assertNotNull(userTaskNode);
    assertNotNull(businessRuleTaskNode);
    assertNotNull(scriptTaskNode);
    ViewConnector userTaskInEdgeConnector = getInEdgeViewConnector(userTaskNode);
    ViewConnector businessRuleTaskInEdgeConnector = getInEdgeViewConnector(businessRuleTaskNode);
    ViewConnector scriptTaskInEdgeConnector = getInEdgeViewConnector(scriptTaskNode);
    assertNotNull(userTaskInEdgeConnector);
    assertNotNull(businessRuleTaskInEdgeConnector);
    assertNotNull(scriptTaskInEdgeConnector);
    ViewConnector userTaskOutEdgeConnector = getOutEdgeViewConnector(userTaskNode);
    ViewConnector businessRuleTaskOutEdgeConnector = getOutEdgeViewConnector(businessRuleTaskNode);
    ViewConnector scriptTaskOutEdgeConnector = getOutEdgeViewConnector(scriptTaskNode);
    assertNotNull(userTaskOutEdgeConnector);
    assertNotNull(businessRuleTaskOutEdgeConnector);
    assertNotNull(scriptTaskOutEdgeConnector);
    // userTaskInEdgeConnector is from magnet top-middle to left-middle
    assertTrue(userTaskInEdgeConnector.getSourceConnection().isPresent());
    assertTrue(userTaskInEdgeConnector.getTargetConnection().isPresent());
    DiscreteConnection sourceConnection = (DiscreteConnection) userTaskInEdgeConnector.getSourceConnection().get();
    DiscreteConnection targetConnection = (DiscreteConnection) userTaskInEdgeConnector.getTargetConnection().get();
    assertEquals(20d, sourceConnection.getLocation().getX(), 0.1d);
    assertEquals(0d, sourceConnection.getLocation().getY(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
    assertEquals(24d, targetConnection.getLocation().getY(), 0.1d);
    // Assert both connections for userTaskInEdgeConnector are set to auto.
    assertTrue(sourceConnection.isAuto());
    assertTrue(targetConnection.isAuto());
    // businessRuleTaskInEdgeConnector is from magnet right-middle to top-left
    assertTrue(businessRuleTaskInEdgeConnector.getSourceConnection().isPresent());
    assertTrue(businessRuleTaskInEdgeConnector.getTargetConnection().isPresent());
    sourceConnection = (DiscreteConnection) businessRuleTaskInEdgeConnector.getSourceConnection().get();
    targetConnection = (DiscreteConnection) businessRuleTaskInEdgeConnector.getTargetConnection().get();
    assertEquals(40d, sourceConnection.getLocation().getX(), 0.1d);
    assertEquals(20d, sourceConnection.getLocation().getY(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
    // Assert both connections for businessRuleTaskInEdgeConnector are NOT set to auto.
    assertFalse(sourceConnection.isAuto());
    assertFalse(targetConnection.isAuto());
    // scriptTaskInEdgeConnector is from magnet left-bottom to left-bottom
    assertTrue(scriptTaskInEdgeConnector.getSourceConnection().isPresent());
    assertTrue(scriptTaskInEdgeConnector.getTargetConnection().isPresent());
    sourceConnection = (DiscreteConnection) scriptTaskInEdgeConnector.getSourceConnection().get();
    targetConnection = (DiscreteConnection) scriptTaskInEdgeConnector.getTargetConnection().get();
    assertEquals(0d, sourceConnection.getLocation().getX(), 0.1d);
    assertEquals(40d, sourceConnection.getLocation().getY(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
    assertEquals(48d, targetConnection.getLocation().getY(), 0.1d);
    // userTaskOutEdgeConnector is from magnet right-middle to left-middle
    assertTrue(userTaskOutEdgeConnector.getSourceConnection().isPresent());
    assertTrue(userTaskOutEdgeConnector.getTargetConnection().isPresent());
    sourceConnection = (DiscreteConnection) userTaskOutEdgeConnector.getSourceConnection().get();
    targetConnection = (DiscreteConnection) userTaskOutEdgeConnector.getTargetConnection().get();
    assertEquals(136d, sourceConnection.getLocation().getX(), 0.1d);
    assertEquals(24d, sourceConnection.getLocation().getY(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
    assertEquals(14d, targetConnection.getLocation().getY(), 0.1d);
    // businessRuleTaskOutEdgeConnector is from magnet middle-bottom to middle-bottom
    assertTrue(businessRuleTaskOutEdgeConnector.getSourceConnection().isPresent());
    assertTrue(businessRuleTaskOutEdgeConnector.getTargetConnection().isPresent());
    sourceConnection = (DiscreteConnection) businessRuleTaskOutEdgeConnector.getSourceConnection().get();
    targetConnection = (DiscreteConnection) businessRuleTaskOutEdgeConnector.getTargetConnection().get();
    assertEquals(68d, sourceConnection.getLocation().getX(), 0.1d);
    assertEquals(48d, sourceConnection.getLocation().getY(), 0.1d);
    assertEquals(14d, targetConnection.getLocation().getX(), 0.1d);
    assertEquals(28d, targetConnection.getLocation().getY(), 0.1d);
    // scriptTaskOutEdgeConnector is from magnet left-top to left-top
    assertTrue(scriptTaskOutEdgeConnector.getSourceConnection().isPresent());
    assertTrue(scriptTaskOutEdgeConnector.getTargetConnection().isPresent());
    sourceConnection = (DiscreteConnection) scriptTaskOutEdgeConnector.getSourceConnection().get();
    targetConnection = (DiscreteConnection) scriptTaskOutEdgeConnector.getTargetConnection().get();
    assertEquals(0d, sourceConnection.getLocation().getX(), 0.1d);
    assertEquals(0d, sourceConnection.getLocation().getY(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
    assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
}
Also used : ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) Node(org.kie.workbench.common.stunner.core.graph.Node) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask)

Example 78 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method assertDocumentation.

private void assertDocumentation(Diagram<Graph, Metadata> diagram, String id, String value) {
    Optional<BPMNDefinition> documentation = getNodes(diagram).stream().filter(node -> node.getContent() instanceof View && node.getUUID().equals(id)).map(node -> (View) node.getContent()).filter(view -> view.getDefinition() instanceof BPMNDefinition).map(view -> (BPMNDefinition) view.getDefinition()).findFirst();
    String documentationValue = (documentation.isPresent() ? documentation.get().getGeneral().getDocumentation().getValue() : null);
    assertEquals(value, documentationValue);
}
Also used : Arrays(java.util.Arrays) BPMNGraphObjectBuilderFactory(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.builder.BPMNGraphObjectBuilderFactory) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) AssignmentsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssignmentsTypeSerializer) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) EndErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.EndErrorEvent) Edge(org.kie.workbench.common.stunner.core.graph.Edge) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BackendDefinitionSetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionSetAdapter) Bpmn2OryxPropertySerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertySerializer) EdgeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.EdgeFactoryImpl) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) BPMNDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDiagramMarshaller) Mockito.doAnswer(org.mockito.Mockito.doAnswer) GraphFactory(org.kie.workbench.common.stunner.core.factory.graph.GraphFactory) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) EndTerminateEvent(org.kie.workbench.common.stunner.bpmn.definition.EndTerminateEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) NodeFactory(org.kie.workbench.common.stunner.core.factory.graph.NodeFactory) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext) ColorTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ColorTypeSerializer) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) IntegerTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.IntegerTypeSerializer) StandardCharsets(java.nio.charset.StandardCharsets) Bpmn2OryxPropertyManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager) MorphDefinition(org.kie.workbench.common.stunner.core.definition.morph.MorphDefinition) Matchers.any(org.mockito.Matchers.any) Stream(java.util.stream.Stream) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) Assert.assertFalse(org.junit.Assert.assertFalse) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) InputOutputSpecification(org.eclipse.bpmn2.InputOutputSpecification) Mockito.mock(org.mockito.Mockito.mock) Bpmn2OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) ScriptTypeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Mock(org.mockito.Mock) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) GraphCommandManager(org.kie.workbench.common.stunner.core.graph.command.GraphCommandManager) RunWith(org.junit.runner.RunWith) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) GraphCommandManagerImpl(org.kie.workbench.common.stunner.core.graph.command.GraphCommandManagerImpl) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) CloneManager(org.kie.workbench.common.stunner.core.definition.clone.CloneManager) Matchers.anyString(org.mockito.Matchers.anyString) ArrayList(java.util.ArrayList) DataInput(org.eclipse.bpmn2.DataInput) Property(org.eclipse.bpmn2.Property) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) BackendDefinitionAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionAdapter) MapIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndexBuilder) InterruptingSignalEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.InterruptingSignalEventExecutionSet) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) AdapterManager(org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager) Before(org.junit.Before) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) NodeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.NodeFactoryImpl) MetaDataType(org.jboss.drools.MetaDataType) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) Assert.assertTrue(org.junit.Assert.assertTrue) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Test(org.junit.Test) AdapterRegistry(org.kie.workbench.common.stunner.core.registry.definition.AdapterRegistry) InterruptingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.InterruptingErrorEventExecutionSet) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) TimerSettingsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer) Graph(org.kie.workbench.common.stunner.core.graph.Graph) IntermediateMessageEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventThrowing) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Assert.assertNull(org.junit.Assert.assertNull) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) IsInterrupting(org.kie.workbench.common.stunner.bpmn.definition.property.event.IsInterrupting) BackendPropertyAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertyAdapter) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) BackendBindableMorphAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.bind.BackendBindableMorphAdapter) BeanManager(javax.enterprise.inject.spi.BeanManager) FlowElement(org.eclipse.bpmn2.FlowElement) Assert.assertEquals(org.junit.Assert.assertEquals) RootElement(org.eclipse.bpmn2.RootElement) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) UserTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.UserTaskExecutionSet) Activity(org.eclipse.bpmn2.Activity) GraphIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.GraphIndexBuilder) DefaultRuleViolations(org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations) BooleanTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.BooleanTypeSerializer) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) ByteArrayInputStream(java.io.ByteArrayInputStream) Matchers.eq(org.mockito.Matchers.eq) DataOutput(org.eclipse.bpmn2.DataOutput) EStructuralFeatureImpl(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) DoubleTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.DoubleTypeSerializer) Collection(java.util.Collection) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) ServiceTask(org.kie.workbench.common.stunner.bpmn.workitem.ServiceTask) ScriptTypeListTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) BackendPropertySetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertySetAdapter) TaskTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TaskTypeSerializer) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) EdgeFactory(org.kie.workbench.common.stunner.core.factory.graph.EdgeFactory) InterruptingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.InterruptingTimerEventExecutionSet) TaskTypes(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskTypes) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) List(java.util.List) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) Optional(java.util.Optional) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) StringTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.StringTypeSerializer) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) Element(org.kie.workbench.common.stunner.core.graph.Element) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) LinkedList(java.util.LinkedList) EnumTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.EnumTypeSerializer) GraphFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.GraphFactoryImpl) Definitions(org.eclipse.bpmn2.Definitions) Process(org.eclipse.bpmn2.Process) Iterator(java.util.Iterator) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) Assert.assertNotNull(org.junit.Assert.assertNotNull) InclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.InclusiveGateway) Mockito.when(org.mockito.Mockito.when) AdHocSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocSubprocessTaskExecutionSet) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) TestScopeModelFactory(org.kie.workbench.common.stunner.backend.definition.factory.TestScopeModelFactory) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) BackendFactoryManager(org.kie.workbench.common.stunner.core.backend.BackendFactoryManager) Bpmn2OryxManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager) WorkItemDefinitionBackendRegistry(org.kie.workbench.common.stunner.bpmn.backend.workitem.WorkItemDefinitionBackendRegistry) ElementFactory(org.kie.workbench.common.stunner.core.factory.graph.ElementFactory) ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) RuleManager(org.kie.workbench.common.stunner.core.rule.RuleManager) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) VariablesTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.VariablesTypeSerializer) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) InputStream(java.io.InputStream) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) InterruptingMessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.InterruptingMessageEventExecutionSet) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) Matchers.anyString(org.mockito.Matchers.anyString) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 79 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    // Work Items.
    workItemDefinitionMockRegistry = new WorkItemDefinitionMockRegistry();
    // Graph utils.
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.registry()).thenReturn(adapterRegistry);
    definitionUtils = new DefinitionUtils(definitionManager, applicationFactoryManager);
    testScopeModelFactory = new BPMNTestScopeModelFactory(new BPMNDefinitionSet.BPMNDefinitionSetBuilder().build(), workItemDefinitionMockRegistry);
    // Definition manager.
    final BackendDefinitionAdapter definitionAdapter = new BackendDefinitionAdapter(definitionUtils);
    final BackendDefinitionSetAdapter definitionSetAdapter = new BackendDefinitionSetAdapter(definitionAdapter);
    final BackendPropertySetAdapter propertySetAdapter = new BackendPropertySetAdapter();
    final BackendPropertyAdapter propertyAdapter = new BackendPropertyAdapter();
    when(adapterManager.forDefinitionSet()).thenReturn(definitionSetAdapter);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(adapterManager.forPropertySet()).thenReturn(propertySetAdapter);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(adapterRegistry.getDefinitionSetAdapter(any(Class.class))).thenReturn(definitionSetAdapter);
    when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter);
    when(adapterRegistry.getPropertySetAdapter(any(Class.class))).thenReturn(propertySetAdapter);
    when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter);
    commandManager = new GraphCommandManagerImpl(null, null, null);
    commandFactory = new GraphCommandFactory();
    connectionEdgeFactory = new EdgeFactoryImpl(definitionManager);
    viewNodeFactory = new NodeFactoryImpl(definitionUtils);
    bpmnGraphFactory = new GraphFactoryImpl(definitionManager);
    doAnswer(invocationOnMock -> {
        String id = (String) invocationOnMock.getArguments()[0];
        return testScopeModelFactory.build(id);
    }).when(applicationFactoryManager).newDefinition(anyString());
    doAnswer(invocationOnMock -> {
        String uuid = (String) invocationOnMock.getArguments()[0];
        String id = (String) invocationOnMock.getArguments()[1];
        if (BPMNDefinitionSet.class.getName().equals(id)) {
            Graph graph = (Graph) bpmnGraphFactory.build(uuid, BPMN_DEF_SET_ID);
            return graph;
        }
        Object model = testScopeModelFactory.accepts(id) ? testScopeModelFactory.build(id) : null;
        if (null != model) {
            Class<? extends ElementFactory> element = BackendDefinitionAdapter.getGraphFactory(model.getClass());
            if (element.isAssignableFrom(NodeFactory.class)) {
                Node node = viewNodeFactory.build(uuid, model);
                return node;
            } else if (element.isAssignableFrom(EdgeFactory.class)) {
                Edge edge = connectionEdgeFactory.build(uuid, model);
                return edge;
            }
        }
        return null;
    }).when(applicationFactoryManager).newElement(anyString(), anyString());
    doAnswer(invocationOnMock -> {
        String uuid = (String) invocationOnMock.getArguments()[0];
        Class type = (Class) invocationOnMock.getArguments()[1];
        String id = BindableAdapterUtils.getGenericClassName(type);
        if (BPMNDefinitionSet.class.equals(type)) {
            Graph graph = (Graph) bpmnGraphFactory.build(uuid, BPMN_DEF_SET_ID);
            return graph;
        }
        Object model = testScopeModelFactory.accepts(id) ? testScopeModelFactory.build(id) : null;
        if (null != model) {
            Class<? extends ElementFactory> element = BackendDefinitionAdapter.getGraphFactory(model.getClass());
            if (element.isAssignableFrom(NodeFactory.class)) {
                Node node = viewNodeFactory.build(uuid, model);
                return node;
            } else if (element.isAssignableFrom(EdgeFactory.class)) {
                Edge edge = connectionEdgeFactory.build(uuid, model);
                return edge;
            }
        }
        return null;
    }).when(applicationFactoryManager).newElement(anyString(), any(Class.class));
    doAnswer(invocationOnMock -> {
        String uuid = (String) invocationOnMock.getArguments()[0];
        String defSetId = (String) invocationOnMock.getArguments()[1];
        final Graph graph = (Graph) applicationFactoryManager.newElement(uuid, defSetId);
        final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build());
        result.setGraph(graph);
        return result;
    }).when(applicationFactoryManager).newDiagram(anyString(), anyString(), any(Metadata.class));
    // Bpmn 2 oryx stuff.
    oryxIdMappings = new Bpmn2OryxIdMappings(definitionManager, () -> workItemDefinitionMockRegistry);
    StringTypeSerializer stringTypeSerializer = new StringTypeSerializer();
    BooleanTypeSerializer booleanTypeSerializer = new BooleanTypeSerializer();
    ColorTypeSerializer colorTypeSerializer = new ColorTypeSerializer();
    DoubleTypeSerializer doubleTypeSerializer = new DoubleTypeSerializer();
    IntegerTypeSerializer integerTypeSerializer = new IntegerTypeSerializer();
    EnumTypeSerializer enumTypeSerializer = new EnumTypeSerializer(definitionUtils);
    AssignmentsTypeSerializer assignmentsTypeSerializer = new AssignmentsTypeSerializer();
    VariablesTypeSerializer variablesTypeSerializer = new VariablesTypeSerializer();
    TimerSettingsTypeSerializer timerSettingsTypeSerializer = new TimerSettingsTypeSerializer();
    ScriptTypeTypeSerializer scriptTypeTypeSerializer = new ScriptTypeTypeSerializer();
    ScriptTypeListTypeSerializer scriptTypeListTypeSerializer = new ScriptTypeListTypeSerializer();
    TaskTypeSerializer taskTypeSerializer = new TaskTypeSerializer(definitionUtils, enumTypeSerializer);
    List<Bpmn2OryxPropertySerializer<?>> propertySerializers = new LinkedList<>();
    propertySerializers.add(stringTypeSerializer);
    propertySerializers.add(booleanTypeSerializer);
    propertySerializers.add(colorTypeSerializer);
    propertySerializers.add(doubleTypeSerializer);
    propertySerializers.add(integerTypeSerializer);
    propertySerializers.add(enumTypeSerializer);
    propertySerializers.add(assignmentsTypeSerializer);
    propertySerializers.add(variablesTypeSerializer);
    propertySerializers.add(timerSettingsTypeSerializer);
    propertySerializers.add(scriptTypeTypeSerializer);
    propertySerializers.add(scriptTypeListTypeSerializer);
    propertySerializers.add(taskTypeSerializer);
    oryxPropertyManager = new Bpmn2OryxPropertyManager(propertySerializers);
    oryxManager = new Bpmn2OryxManager(oryxIdMappings, oryxPropertyManager);
    oryxManager.init();
    // Marshalling factories.
    objectBuilderFactory = new BPMNGraphObjectBuilderFactory(definitionManager, oryxManager, () -> workItemDefinitionMockRegistry);
    taskMorphDefinition = new TaskTypeMorphDefinition();
    Collection<MorphDefinition> morphDefinitions = new ArrayList<MorphDefinition>() {

        {
            add(taskMorphDefinition);
        }
    };
    BackendBindableMorphAdapter<Object> morphAdapter = new BackendBindableMorphAdapter(definitionUtils, applicationFactoryManager, cloneManager, morphDefinitions);
    when(adapterRegistry.getMorphAdapter(eq(UserTask.class))).thenReturn(morphAdapter);
    when(adapterRegistry.getMorphAdapter(eq(NoneTask.class))).thenReturn(morphAdapter);
    when(adapterRegistry.getMorphAdapter(eq(ScriptTask.class))).thenReturn(morphAdapter);
    when(adapterRegistry.getMorphAdapter(eq(BusinessRuleTask.class))).thenReturn(morphAdapter);
    GraphIndexBuilder<?> indexBuilder = new MapIndexBuilder();
    when(rulesManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(new DefaultRuleViolations());
    // The work item definition registry.
    WorkItemDefinitionBackendRegistry widRegistry = mock(WorkItemDefinitionBackendRegistry.class);
    when(widRegistry.getRegistry()).thenReturn(workItemDefinitionMockRegistry);
    when(widRegistry.items()).thenReturn(workItemDefinitionMockRegistry.items());
    when(widRegistry.load(any(Metadata.class))).thenReturn(widRegistry);
    doAnswer(invocationOnMock -> workItemDefinitionMockRegistry.get((String) invocationOnMock.getArguments()[0])).when(widRegistry).get(anyString());
    // The tested BPMN marshaller.
    tested = new BPMNDiagramMarshaller(new XMLEncoderDiagramMetadataMarshaller(), objectBuilderFactory, definitionManager, indexBuilder, oryxManager, applicationFactoryManager, rulesManager, commandManager, commandFactory, widRegistry);
}
Also used : BackendPropertyAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertyAdapter) NodeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.NodeFactoryImpl) BackendDefinitionAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionAdapter) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) GraphFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.GraphFactoryImpl) Matchers.anyString(org.mockito.Matchers.anyString) BackendBindableMorphAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.bind.BackendBindableMorphAdapter) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) ScriptTypeListTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer) BackendPropertySetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertySetAdapter) Bpmn2OryxPropertyManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager) RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) MorphDefinition(org.kie.workbench.common.stunner.core.definition.morph.MorphDefinition) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) LinkedList(java.util.LinkedList) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) Bpmn2OryxPropertySerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertySerializer) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) BPMNGraphObjectBuilderFactory(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.builder.BPMNGraphObjectBuilderFactory) EdgeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.EdgeFactoryImpl) EdgeFactory(org.kie.workbench.common.stunner.core.factory.graph.EdgeFactory) TaskTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TaskTypeSerializer) Bpmn2OryxManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager) DoubleTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.DoubleTypeSerializer) ColorTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ColorTypeSerializer) MapIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndexBuilder) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) WorkItemDefinitionBackendRegistry(org.kie.workbench.common.stunner.bpmn.backend.workitem.WorkItemDefinitionBackendRegistry) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) Bpmn2OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings) ScriptTypeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer) TimerSettingsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer) EnumTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.EnumTypeSerializer) BackendDefinitionSetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionSetAdapter) StringTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.StringTypeSerializer) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) GraphCommandManagerImpl(org.kie.workbench.common.stunner.core.graph.command.GraphCommandManagerImpl) IntegerTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.IntegerTypeSerializer) AssignmentsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssignmentsTypeSerializer) VariablesTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.VariablesTypeSerializer) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) BPMNDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDiagramMarshaller) BooleanTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.BooleanTypeSerializer) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext) DefaultRuleViolations(org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Before(org.junit.Before)

Example 80 with Node

use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallNotBoundaryEvents.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNotBoundaryEvents() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NOT_BOUNDARY_EVENTS);
    assertEquals("Not Boundary Event", diagram.getMetadata().getTitle());
    assertDiagram(diagram, 6);
    // Assert than the intermediate event is connected using a view connector,
    // so not boundary to the task ( not docked ).
    Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
    List<Edge> inEdges = event.getInEdges();
    boolean foundViewConnector = false;
    for (Edge e : inEdges) {
        if (e.getContent() instanceof ViewConnector) {
            foundViewConnector = true;
        }
    }
    assertTrue(foundViewConnector);
    // Assert absolute position as the node is not docked.
    Bounds bounds = ((View) event.getContent()).getBounds();
    Bounds.Bound ul = bounds.getUpperLeft();
    Bounds.Bound lr = bounds.getLowerRight();
    assertEquals(305, ul.getX(), 0);
    assertEquals(300, ul.getY(), 0);
    assertEquals(335, lr.getX(), 0);
    assertEquals(330, lr.getY(), 0);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Aggregations

Node (org.kie.workbench.common.stunner.core.graph.Node)153 Edge (org.kie.workbench.common.stunner.core.graph.Edge)85 View (org.kie.workbench.common.stunner.core.graph.content.view.View)59 Test (org.junit.Test)38 Graph (org.kie.workbench.common.stunner.core.graph.Graph)32 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)24 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)21 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)17 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)15 Element (org.kie.workbench.common.stunner.core.graph.Element)14 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)13 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)13 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)13 Matchers.anyString (org.mockito.Matchers.anyString)13 List (java.util.List)12 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 Before (org.junit.Before)11 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)11 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)11