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);
}
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);
}
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);
}
Aggregations