Search in sources :

Example 1 with RectangleDimensionsSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet in project kie-wb-common by kiegroup.

the class BPMNDiagramTest method testBPMNDiagramEquals.

@Test
public void testBPMNDiagramEquals() {
    BPMNDiagramImpl BPMNDiagramImpl = createValidBpmnDiagram();
    BPMNDiagramImpl.setAdvancedData(new RootProcessAdvancedData(new GlobalVariables(GLOBAL_VARIABLES), new MetaDataAttributes(METADATA)));
    BPMNDiagramImpl BPMNDiagramImpl2 = createValidBpmnDiagram();
    BPMNDiagramImpl2.setAdvancedData(new RootProcessAdvancedData(new GlobalVariables(GLOBAL_VARIABLES), new MetaDataAttributes(METADATA)));
    assertEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
    BPMNDiagramImpl.setAdvancedData(new RootProcessAdvancedData(new GlobalVariables("id:"), new MetaDataAttributes("securityRoles3ß<![CDATA[employees,clients]]>")));
    assertNotEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
    BPMNDiagramImpl.setAdvancedData(new RootProcessAdvancedData(new GlobalVariables(GLOBAL_VARIABLES), new MetaDataAttributes("securityRoles3ß<![CDATA[employees,clients]]>")));
    assertNotEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
    BPMNDiagramImpl.setAdvancedData(new RootProcessAdvancedData(new GlobalVariables("id:"), new MetaDataAttributes(METADATA)));
    assertNotEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
    BPMNDiagramImpl.setAdvancedData(new RootProcessAdvancedData(new GlobalVariables(GLOBAL_VARIABLES), new MetaDataAttributes(METADATA)));
    assertEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
    BPMNDiagramImpl.setDimensionsSet(new RectangleDimensionsSet(10d, 10d));
    BPMNDiagramImpl2.setDimensionsSet(new RectangleDimensionsSet(20d, 20d));
    assertNotEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
    BPMNDiagramImpl2.setDimensionsSet(new RectangleDimensionsSet(10d, 10d));
    assertEquals(BPMNDiagramImpl, BPMNDiagramImpl2);
}
Also used : MetaDataAttributes(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.MetaDataAttributes) RootProcessAdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.RootProcessAdvancedData) GlobalVariables(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.GlobalVariables) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) Test(org.junit.Test)

Example 2 with RectangleDimensionsSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet in project kie-wb-common by kiegroup.

the class BaseArtifactsTest method setDimensionsSet.

@Test
public void setDimensionsSet() {
    RectangleDimensionsSet dimensionsSet = new RectangleDimensionsSet();
    tested.setDimensionsSet(dimensionsSet);
    assertEquals(dimensionsSet, tested.getDimensionsSet());
}
Also used : RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) Test(org.junit.Test)

Example 3 with RectangleDimensionsSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet in project kie-wb-common by kiegroup.

the class ProcessPostConverterTest method testPostConvert.

@Test
public void testPostConvert() {
    DefinitionResolver definitionResolver = mock(DefinitionResolver.class);
    double laneX = 80;
    double laneY = 100;
    double laneWidth = 500;
    double laneHeight = 200;
    RectangleDimensionsSet laneRectangleDimensionsSet = new RectangleDimensionsSet(laneWidth, laneHeight);
    Lane laneDefinition = mock(Lane.class);
    when(laneDefinition.getDimensionsSet()).thenReturn(laneRectangleDimensionsSet);
    Node<? extends View<? extends BPMNViewDefinition>, ?> lane = mockNode(laneDefinition, laneX, laneY, laneWidth, laneHeight);
    BpmnNode laneNode = mockBpmnNode(lane);
    double startEventX = 180;
    double startEventY = 130;
    double eventWidth = 56;
    double eventHeight = 56;
    Node<? extends View<? extends BPMNViewDefinition>, ?> startEvent = mockNode(mock(StartNoneEvent.class), startEventX + laneX, startEventY + laneY, eventWidth, eventHeight);
    BpmnNode startEventNode = mockBpmnNode(startEvent);
    // subprocess is collapsed and has a boundaryEvent, and contains task1 and task2 (task2 has a boundaryEvent)
    double subprocessX = 270;
    double subprocessY = 180;
    double subprocessWidth = 100;
    double subprocessHeight = 60;
    RectangleDimensionsSet subprocessRectangleDimensionsSet = new RectangleDimensionsSet(subprocessWidth, subprocessHeight);
    EmbeddedSubprocess subprocessDefinition = mock(EmbeddedSubprocess.class);
    when(subprocessDefinition.getDimensionsSet()).thenReturn(subprocessRectangleDimensionsSet);
    Node<? extends View<? extends BPMNViewDefinition>, ?> subprocess = mockNode(subprocessDefinition, subprocessX + laneX, subprocessY + laneY, subprocessWidth, subprocessHeight);
    BpmnNode subprocessNode = mockBpmnNode(subprocess);
    BasePropertyReader subprocessPropertyReader = subprocessNode.getPropertyReader();
    when(subprocessPropertyReader.isExpanded()).thenReturn(false);
    double subprocessBoundaryEventX = subprocessWidth - 28;
    double subprocessBoundaryEventY = (subprocessHeight / 2) - 28;
    Node<? extends View<? extends BPMNViewDefinition>, ?> subprocessBoundaryEvent = mockNode(mock(IntermediateTimerEvent.class), subprocessBoundaryEventX, subprocessBoundaryEventY, eventWidth, eventHeight);
    BpmnNode subprocessBoundaryEventNode = mockBpmnNode(subprocessBoundaryEvent).docked();
    double task1X = 10;
    double task1Y = 10;
    double taskWidth = 200;
    double taskHeight = 100;
    Node<? extends View<? extends BPMNViewDefinition>, ?> task1 = mockNode(mock(UserTask.class), task1X, task1Y, taskWidth, taskHeight);
    BpmnNode task1Node = mockBpmnNode(task1);
    double task2X = 300;
    double task2Y = 200;
    Node<? extends View<? extends BPMNViewDefinition>, ?> task2 = mockNode(mock(UserTask.class), task2X, task2Y, taskWidth, taskHeight);
    BpmnNode task2Node = mockBpmnNode(task2);
    double task2BoundaryEventX = taskWidth - 28;
    double task2BoundaryEventY = taskHeight - 28;
    Node<? extends View<? extends BPMNViewDefinition>, ?> task2BoundaryEvent = mockNode(mock(IntermediateTimerEvent.class), task2BoundaryEventX, task2BoundaryEventY, eventWidth, eventHeight);
    BpmnNode task2BoundaryEventNode = mockBpmnNode(task2BoundaryEvent).docked();
    double endEventX = 450;
    double endEventY = 230;
    Node<? extends View<? extends BPMNViewDefinition>, ?> endEvent = mockNode(mock(EndNoneEvent.class), endEventX + laneX, endEventY + laneY, eventWidth, eventHeight);
    BpmnNode endEventNode = mockBpmnNode(endEvent);
    double task3X = 500;
    double task3Y = 600;
    Node<? extends View<? extends BPMNViewDefinition>, ?> task3 = mockNode(mock(UserTask.class), task3X + laneX, task3Y + laneY, taskWidth, taskHeight);
    BpmnNode task3Node = mockBpmnNode(task3);
    double task3BoundaryEventX = taskWidth - 28;
    double task3BoundaryEventY = taskHeight - 28;
    Node<? extends View<? extends BPMNViewDefinition>, ?> task3BoundaryEvent = mockNode(mock(IntermediateTimerEvent.class), task3BoundaryEventX, task3BoundaryEventY, eventWidth, eventHeight);
    BpmnNode task3BoundaryEventNode = mockBpmnNode(task3BoundaryEvent).docked();
    double task4X = 900;
    double task4Y = 1000;
    Node<? extends View<? extends BPMNViewDefinition>, ?> task4 = mockNode(mock(UserTask.class), task4X + laneX, task4Y + laneY, taskWidth, taskHeight);
    BpmnNode task4Node = mockBpmnNode(task4);
    List<Point2D> controlPoints = new ArrayList<>();
    controlPoints.add(Point2D.create(900 + 100 + laneX, 700 + laneY));
    Connection sourceConnection = MagnetConnection.Builder.at(56, 28).setAuto(false);
    Connection targetConnection = MagnetConnection.Builder.at(100, 0).setAuto(false);
    BPMNEdge bpmnEdge = mock(BPMNEdge.class);
    BaseElement baseElement = mock(BaseElement.class);
    SequenceFlowPropertyReader edgePropertyReader = mock(SequenceFlowPropertyReader.class);
    when(edgePropertyReader.getDefinitionResolver()).thenReturn(definitionResolver);
    when(edgePropertyReader.getElement()).thenReturn(baseElement);
    when(baseElement.getId()).thenReturn("elementId");
    when(definitionResolver.getEdge("elementId")).thenReturn(bpmnEdge);
    List<Point> wayPoints = new ArrayList<>();
    wayPoints.add(mockPoint((float) (700 + 28 + laneX), (float) (700 + laneY)));
    wayPoints.add(mockPoint((float) (1000 + laneX), (float) (700 + laneY)));
    wayPoints.add(mockPoint((float) (900 + 100 + laneX), (float) (1000 + laneY)));
    when(bpmnEdge.getWaypoint()).thenReturn(wayPoints);
    org.eclipse.dd.dc.Bounds sourceShapeBounds = mockBounds((float) (task3X + taskWidth - 28 + laneX), (float) (task3Y + taskHeight - 28 + laneY), (float) eventWidth, (float) eventHeight);
    BPMNShape sourceShape = mockShape(sourceShapeBounds);
    when(task3BoundaryEventNode.getPropertyReader().getShape()).thenReturn(sourceShape);
    org.eclipse.dd.dc.Bounds targetShapeBounds = mockBounds(task4.getContent().getBounds());
    BPMNShape targetShape = mockShape(targetShapeBounds);
    when(task4Node.getPropertyReader().getShape()).thenReturn(targetShape);
    BpmnEdge.Simple edgeTask3BoundaryEventToTask4 = BpmnEdge.of(null, task3BoundaryEventNode, sourceConnection, controlPoints, task4Node, targetConnection, edgePropertyReader);
    Node<? extends View<? extends BPMNViewDefinition>, ?> diagram = mockNode(mock(BPMNDiagramImpl.class), 0, 0, 10000, 10000);
    BpmnNode rootNode = mockBpmnNode(diagram);
    rootNode.addChild(laneNode);
    laneNode.addChild(startEventNode);
    laneNode.addChild(subprocessNode);
    laneNode.addChild(subprocessBoundaryEventNode);
    rootNode.addEdge(BpmnEdge.docked(subprocessNode, subprocessBoundaryEventNode));
    subprocessNode.addChild(task1Node);
    subprocessNode.addChild(task2Node);
    subprocessNode.addChild(task2BoundaryEventNode);
    subprocessNode.addEdge(BpmnEdge.docked(task2Node, task2BoundaryEventNode));
    laneNode.addChild(task3Node);
    laneNode.addChild(task3BoundaryEventNode);
    laneNode.addChild(task4Node);
    rootNode.addEdge(BpmnEdge.docked(task3Node, task3BoundaryEventNode));
    rootNode.addEdge(edgeTask3BoundaryEventToTask4);
    laneNode.addChild(endEventNode);
    ProcessPostConverter postConverter = new ProcessPostConverter();
    when(definitionResolver.getResolutionFactor()).thenReturn(2d);
    Result<BpmnNode> result = postConverter.postConvert(rootNode, definitionResolver);
    Bounds startEventBounds = startEventNode.value().getContent().getBounds();
    // preserves original position
    assertEquals(laneX + startEventX, startEventBounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + startEventY, startEventBounds.getUpperLeft().getY(), 0);
    assertEquals(eventWidth, startEventBounds.getWidth(), 0);
    assertEquals(eventHeight, startEventBounds.getHeight(), 0);
    Bounds subProcessBounds = subprocessNode.value().getContent().getBounds();
    // was properly resized and preserves original position
    assertEquals(laneX + subprocessX, subProcessBounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + subprocessY, subProcessBounds.getUpperLeft().getY(), 0);
    assertEquals(300 + 200 + 10, subProcessBounds.getWidth(), 0);
    assertEquals(200 + 100 + 10, subProcessBounds.getHeight(), 0);
    Bounds subProcessBoundaryEventBounds = subprocessBoundaryEventNode.value().getContent().getBounds();
    // boundary event was properly located
    assertEquals(subProcessBounds.getWidth() - 28, subProcessBoundaryEventBounds.getUpperLeft().getX(), 0);
    assertEquals(subProcessBounds.getHeight() / subprocessHeight * subprocessBoundaryEventY, subProcessBoundaryEventBounds.getUpperLeft().getY(), 0);
    Bounds task1Bounds = task1Node.value().getContent().getBounds();
    // was properly positioned and preserves size
    assertEquals(laneX + subprocessX + task1X, task1Bounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + subprocessY + task1Y, task1Bounds.getUpperLeft().getY(), 0);
    assertEquals(taskWidth, task1Bounds.getWidth(), 0);
    assertEquals(taskHeight, task1Bounds.getHeight(), 0);
    Bounds task2Bounds = task2Node.value().getContent().getBounds();
    // was properly positioned and preserves size
    assertEquals(laneX + subprocessX + task2X, task2Bounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + subprocessY + task2Y, task2Bounds.getUpperLeft().getY(), 0);
    assertEquals(taskWidth, task1Bounds.getWidth(), 0);
    assertEquals(taskHeight, task1Bounds.getHeight(), 0);
    Bounds task2BoundaryEventBounds = task2BoundaryEventNode.value().getContent().getBounds();
    // is relative to the task2 in the converted model and preserves size
    assertEquals(task2BoundaryEventX, task2BoundaryEventBounds.getUpperLeft().getX(), 0);
    assertEquals(task2BoundaryEventY, task2BoundaryEventBounds.getUpperLeft().getY(), 0);
    assertEquals(eventWidth, task2BoundaryEventBounds.getWidth(), 0);
    assertEquals(eventHeight, task2BoundaryEventBounds.getHeight(), 0);
    Bounds endEventBounds = endEventNode.value().getContent().getBounds();
    double subprocessDeltaX = subProcessBounds.getWidth() - subprocessWidth;
    double subprocessDeltaY = subProcessBounds.getHeight() - subprocessHeight;
    // was properly moved after the subprocess resize
    assertEquals(laneX + endEventX + subprocessDeltaX, endEventBounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + endEventY + subprocessDeltaY, endEventBounds.getUpperLeft().getY(), 0);
    Bounds task3Bounds = task3Node.value().getContent().getBounds();
    // was properly moved after the subprocess resize
    assertEquals(laneX + task3X + subprocessDeltaX, task3Bounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + task3Y + subprocessDeltaY, task3Bounds.getUpperLeft().getY(), 0);
    Bounds task3BoundaryEventBounds = task3BoundaryEventNode.value().getContent().getBounds();
    // is relative to the task3 in the converted model and preserves size
    assertEquals(task3BoundaryEventX, task3BoundaryEventBounds.getUpperLeft().getX(), 0);
    assertEquals(task3BoundaryEventY, task3BoundaryEventBounds.getUpperLeft().getY(), 0);
    assertEquals(eventWidth, task3BoundaryEventBounds.getWidth(), 0);
    assertEquals(eventHeight, task3BoundaryEventBounds.getHeight(), 0);
    Bounds task4Bounds = task4Node.value().getContent().getBounds();
    // was properly moved after the subprocess resize
    assertEquals(laneX + task4X + subprocessDeltaX, task4Bounds.getUpperLeft().getX(), 0);
    assertEquals(laneY + task4Y + subprocessDeltaY, task4Bounds.getUpperLeft().getY(), 0);
    // edgeTask3BoundaryEventToTask4 was properly translated and magnets are ok
    assertEquals(56, edgeTask3BoundaryEventToTask4.getSourceConnection().getLocation().getX(), 0);
    assertEquals(28, edgeTask3BoundaryEventToTask4.getSourceConnection().getLocation().getY(), 0);
    assertEquals(task4Node.value().getContent().getBounds().getUpperLeft().getX() + taskWidth / 2, controlPoints.get(0).getX(), 0);
    assertEquals(task3Node.value().getContent().getBounds().getLowerRight().getY(), controlPoints.get(0).getY(), 0);
    // assert the message result
    List<MarshallingMessage> messages = result.messages();
    assertEquals(1, messages.size());
    MarshallingMessage message = messages.get(0);
    assertEquals(Violation.Type.WARNING, message.getViolationType());
    assertEquals(MarshallingMessageKeys.collapsedElementExpanded, message.getMessageKey());
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) ArrayList(java.util.ArrayList) GraphBuilderTest.mockBpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.GraphBuilderTest.mockBpmnNode) BasePropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.BasePropertyReader) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) BPMNEdge(org.eclipse.bpmn2.di.BPMNEdge) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) Point(org.eclipse.dd.dc.Point) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) SequenceFlowPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SequenceFlowPropertyReader) BaseElement(org.eclipse.bpmn2.BaseElement) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) Factories.dc(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.dc) Test(org.junit.Test)

Example 4 with RectangleDimensionsSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet in project kie-wb-common by kiegroup.

the class CallActivityConverterTest method setUp.

@Before
public void setUp() {
    final ReusableSubprocess definition = new ReusableSubprocess(new BPMNGeneralSet(), new ReusableSubprocessTaskExecutionSet(), new DataIOSet(), new BackgroundSet(), new FontSet(), new RectangleDimensionsSet(), new SimulationSet(), new AdvancedData());
    final View<ReusableSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    Node<View<ReusableSubprocess>, Edge> node = new NodeImpl<>(UUID);
    node.setContent(view);
    when(callActivity.getId()).thenReturn(UUID);
    when(callActivity.getCalledElement()).thenReturn(CALLED_ELEMENT);
    when(factoryManager.newNode(eq(UUID), eq(ReusableSubprocess.class))).thenReturn(node);
    when(propertyReaderFactory.of(callActivity)).thenReturn(propertyReader);
    when(propertyReader.getName()).thenReturn(NAME);
    when(propertyReader.getDocumentation()).thenReturn(DOCUMENTATION);
    when(propertyReader.getAssignmentsInfo()).thenReturn(ASSIGNMENTS_INFO);
    when(propertyReader.getBounds()).thenReturn(BOUNDS);
    when(propertyReader.getSimulationSet()).thenReturn(SIMULATION_SET);
    when(propertyReader.getRectangleDimensionsSet()).thenReturn(RECTANGLE_DIMENSIONS_SET);
    when(propertyReader.getFontSet()).thenReturn(FONT_SET);
    when(propertyReader.getBackgroundSet()).thenReturn(BACKGROUND_SET);
    when(propertyReader.isIndependent()).thenReturn(INDEPENDENT);
    when(propertyReader.isAbortParent()).thenReturn(ABORT_PARENT);
    when(propertyReader.isWaitForCompletion()).thenReturn(WAIT_FOR_COMPLETION);
    when(propertyReader.isAsync()).thenReturn(IS_ASYNC);
    when(propertyReader.isSequential()).thenReturn(SEQUENTIAL);
    when(propertyReader.getCollectionOutput()).thenReturn(COLLECTION_OUTPUT);
    when(propertyReader.getCollectionInput()).thenReturn(COLLECTION_INPUT);
    when(propertyReader.getDataInput()).thenReturn(DATA_INPUT);
    when(propertyReader.getDataOutput()).thenReturn(DATA_OUTPUT);
    when(propertyReader.getCompletionCondition()).thenReturn(COMPLETION_CONDITION);
    when(propertyReader.getOnEntryAction()).thenReturn(ON_ENTRY_ACTION);
    when(propertyReader.getOnExitAction()).thenReturn(ON_EXIT_ACTION);
    when(propertyReader.getSlaDueDate()).thenReturn(SLA_DUE_DATE);
    converter = new CallActivityConverter(factoryManager, propertyReaderFactory);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) FontSet(org.kie.workbench.common.stunner.bpmn.definition.property.font.FontSet) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) BackgroundSet(org.kie.workbench.common.stunner.bpmn.definition.property.background.BackgroundSet) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Before(org.junit.Before)

Example 5 with RectangleDimensionsSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet in project kie-wb-common by kiegroup.

the class CustomTaskShapeViewHandlerTest method init.

@Before
@SuppressWarnings("unchecked")
public void init() {
    task = new CustomTask();
    task.setName(WID_ID);
    task.setDimensionsSet(new RectangleDimensionsSet());
    width = spy(new Width(0d));
    height = spy(new Height(0d));
    task.getDimensionsSet().setWidth(width);
    task.getDimensionsSet().setHeight(height);
    when(registry.items()).thenReturn(Collections.singleton(DEF));
    when(registry.get(eq(WID_ID))).thenReturn(DEF);
    when(view.getChildren()).thenReturn(Collections.singletonList(iconSVGPrimiite));
    when(iconSVGPrimiite.getId()).thenReturn(CustomTaskShapeViewHandler.WID_ICON_ID);
    when(iconSVGPrimiite.get()).thenReturn(icon);
    when(iconSVGPrimiite.getPrimitiveId()).thenReturn(CustomTaskShapeViewHandler.WID_ICON_ID);
    when(icon.getID()).thenReturn(CustomTaskShapeViewHandler.WID_ICON_ID);
    when(icon.getImageProxy()).thenReturn(imageProxy);
    when(view.getPrimitive()).thenReturn(iconSVGPrimiite);
    when(icon.getAttributes()).thenReturn(svgAttr);
    when(svgAttr.getHeight()).thenReturn(HEIGHT);
    when(svgAttr.getWidth()).thenReturn(WIDTH);
    this.tested = new CustomTaskShapeViewHandler(() -> registry);
}
Also used : Height(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Height) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Width(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Width) Before(org.junit.Before)

Aggregations

RectangleDimensionsSet (org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet)14 Test (org.junit.Test)8 BackgroundSet (org.kie.workbench.common.stunner.bpmn.definition.property.background.BackgroundSet)5 FontSet (org.kie.workbench.common.stunner.bpmn.definition.property.font.FontSet)5 Before (org.junit.Before)4 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)4 AdvancedData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData)4 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)3 Height (org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Height)3 Width (org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Width)3 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)3 SimulationSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet)3 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)3 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)2 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)2 ReusableSubprocess (org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess)2 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)2 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)2 SLADueDate (org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate)2 TaskGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet)2