Search in sources :

Example 1 with DefaultCanvasCommandFactory

use of org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory in project kie-wb-common by kiegroup.

the class CreateNodeActionTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getShapeFactory(eq(SSID_UUID))).thenReturn(shapeFactory);
    when(canvas.getLayer()).thenReturn(layer);
    when(diagram.getGraph()).thenReturn(graph);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getShapeSetId()).thenReturn(SSID_UUID);
    when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
    when(graphIndex.get(eq(NODE_UUID))).thenReturn(element);
    when(graphIndex.getNode(eq(NODE_UUID))).thenReturn(element);
    when(graphIndex.get(eq(EDGE_UUID))).thenReturn(edge);
    when(graphIndex.getEdge(eq(EDGE_UUID))).thenReturn(edge);
    when(graphIndex.get(eq(TARGET_NODE_UUID))).thenReturn(targetNode);
    when(graphIndex.getNode(eq(TARGET_NODE_UUID))).thenReturn(targetNode);
    when(element.getUUID()).thenReturn(NODE_UUID);
    when(element.getContent()).thenReturn(elementContent);
    when(element.asNode()).thenReturn(element);
    when(edge.getUUID()).thenReturn(EDGE_UUID);
    when(edge.asEdge()).thenReturn(edge);
    when(targetNode.getUUID()).thenReturn(TARGET_NODE_UUID);
    when(targetNode.asNode()).thenReturn(targetNode);
    when(targetNode.getContent()).thenReturn(targetNodeContent);
    when(sessionCommandManager.execute(eq(canvasHandler), any(Command.class))).thenReturn(CanvasCommandResultBuilder.SUCCESS);
    when(elementContent.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 100d)));
    when(targetNodeContent.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 100d)));
    when(clientFactoryManager.newElement(anyString(), eq(EDGE_ID))).thenReturn((Element) edge);
    when(clientFactoryManager.newElement(anyString(), eq(TARGET_NODE_ID))).thenReturn((Element) targetNode);
    CanvasCommandFactory<AbstractCanvasHandler> canvasCommandFactory = new DefaultCanvasCommandFactory(null, null);
    this.tested = new CreateNodeAction(definitionUtils, clientFactoryManager, canvasLayoutUtils, canvasElementSelectedEvent, translationService, sessionCommandManager, canvasCommandFactory).setEdgeId(EDGE_ID).setNodeId(TARGET_NODE_ID);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) AddConnectorCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AddConnectorCommand) UpdateElementPositionCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand) SetConnectionTargetNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.SetConnectionTargetNodeCommand) Command(org.kie.workbench.common.stunner.core.command.Command) DeferredCompositeCommand(org.kie.workbench.common.stunner.core.command.impl.DeferredCompositeCommand) AddNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand) DeferredCommand(org.kie.workbench.common.stunner.core.command.impl.DeferredCommand) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) DefaultCanvasCommandFactory(org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Before(org.junit.Before)

Example 2 with DefaultCanvasCommandFactory

use of org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory in project kie-wb-common by kiegroup.

the class LocationControlImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    this.canvasCommandFactory = new DefaultCanvasCommandFactory(null, null);
    this.shapeView = spy(new ShapeViewExtStub(shapeEventHandler, hasControlPoints));
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(element.asNode()).thenReturn(element);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.get(eq(ELEMENT_UUID))).thenReturn(element);
    when(element.getContent()).thenReturn(elementContent);
    when(elementContent.getDefinition()).thenReturn(definition);
    when(elementContent.getBounds()).thenReturn(ELEMENT_BOUNDS);
    when(graph.getContent()).thenReturn(graphContent);
    when(graphContent.getBounds()).thenReturn(GRAPH_BOUNDS);
    when(diagram.getGraph()).thenReturn(graph);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvas.getLayer()).thenReturn(layer);
    when(canvas.getShape(eq(ELEMENT_UUID))).thenReturn(shape);
    when(canvas.getShapes()).thenReturn(Collections.singletonList(shape));
    when(canvas.getWiresManager()).thenReturn(wiresManager);
    when(shape.getUUID()).thenReturn(ELEMENT_UUID);
    when(shape.getShapeView()).thenReturn(shapeView);
    when(shapeEventHandler.supports(any(ViewEventType.class))).thenReturn(true);
    when(wiresManager.getSelectionManager()).thenReturn(selectionManager);
    when(selectionManager.getControl()).thenReturn(wiresCompositeControl);
    this.tested = new LocationControlImpl(canvasCommandFactory, shapeLocationsChangedEvent);
    tested.setCommandManagerProvider(() -> commandManager);
}
Also used : ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) DefaultCanvasCommandFactory(org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory) ViewEventType(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType) Before(org.junit.Before)

Example 3 with DefaultCanvasCommandFactory

use of org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory in project kie-wb-common by kiegroup.

the class ResizeControlImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    this.canvasCommandFactory = new DefaultCanvasCommandFactory(null, null);
    this.shapeView = new ShapeViewExtStub(shapeEventHandler, hasControlPoints);
    when(canvasHandler.getDefinitionManager()).thenReturn(definitionManager);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.registry()).thenReturn(adapterRegistry);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter);
    when(adapterRegistry.getPropertyAdapter(anyObject())).thenReturn(propertyAdapter);
    when(definitionAdapter.getId(eq(definition))).thenReturn(DEF_ID);
    when(propertyAdapter.getId(eq(wProperty))).thenReturn(W_PROPERTY_ID);
    when(propertyAdapter.getId(eq(hProperty))).thenReturn(H_PROPERTY_ID);
    when(propertyAdapter.getId(eq(rProperty))).thenReturn(R_PROPERTY_ID);
    when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.WIDTH), eq(definition))).thenReturn(wProperty);
    when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.HEIGHT), eq(definition))).thenReturn(hProperty);
    when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.RADIUS), eq(definition))).thenReturn(rProperty);
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(element.getContent()).thenReturn(elementContent);
    when(elementContent.getDefinition()).thenReturn(definition);
    when(elementContent.getBounds()).thenReturn(ELEMENT_BOUNDS);
    when(graph.getContent()).thenReturn(graphContent);
    when(graphContent.getBounds()).thenReturn(GRAPH_BOUNDS);
    when(diagram.getGraph()).thenReturn(graph);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvas.getLayer()).thenReturn(layer);
    when(canvas.getShape(eq(ELEMENT_UUID))).thenReturn(shape);
    when(canvas.getShapes()).thenReturn(Collections.singletonList(shape));
    when(shape.getUUID()).thenReturn(ELEMENT_UUID);
    when(shape.getShapeView()).thenReturn(shapeView);
    when(shapeEventHandler.supports(eq(ViewEventType.RESIZE))).thenReturn(true);
    this.tested = new ResizeControlImpl(canvasCommandFactory);
    tested.setCommandManagerProvider(() -> commandManager);
}
Also used : ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) DefaultCanvasCommandFactory(org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 DefaultCanvasCommandFactory (org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory)3 ShapeViewExtStub (org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 AddConnectorCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddConnectorCommand)1 AddNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddNodeCommand)1 SetConnectionTargetNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.SetConnectionTargetNodeCommand)1 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)1 ViewEventType (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType)1 Command (org.kie.workbench.common.stunner.core.command.Command)1 DeferredCommand (org.kie.workbench.common.stunner.core.command.impl.DeferredCommand)1 DeferredCompositeCommand (org.kie.workbench.common.stunner.core.command.impl.DeferredCompositeCommand)1 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)1 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)1