Search in sources :

Example 6 with ShapeViewExtStub

use of org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub in project kie-wb-common by kiegroup.

the class LienzoSelectionControlTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(element.getContent()).thenReturn(new ViewImpl<>(definition, BoundsImpl.build(0, 0, 10, 10)));
    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(selectionControl.isEnabled()).thenReturn(true);
    when(selectionControl.getCanvasHandler()).thenReturn(canvasHandler);
    when(selectionControl.getCanvas()).thenReturn(canvas);
    when(shapeViewHandlers.supports(any(ViewEventType.class))).thenReturn(true);
    shapeView = new ShapeViewExtStub(shapeViewHandlers, null);
    when(shape.getShapeView()).thenReturn(shapeView);
    tested = new LienzoSelectionControl<>(selectionControl, canvasSelectionEvent, clearSelectionEvent);
}
Also used : ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) ViewEventType(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType) Before(org.junit.Before)

Example 7 with ShapeViewExtStub

use of org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub 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

ShapeViewExtStub (org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub)7 Before (org.junit.Before)6 ViewEventType (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType)3 DefaultCanvasCommandFactory (org.kie.workbench.common.stunner.core.client.canvas.command.DefaultCanvasCommandFactory)2 Collections (java.util.Collections)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 AbstractCanvas (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 Layer (org.kie.workbench.common.stunner.core.client.canvas.Layer)1 CanvasShapeRemovedEvent (org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent)1 CanvasClearSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent)1 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)1 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)1 ShapeState (org.kie.workbench.common.stunner.core.client.shape.ShapeState)1 HasControlPoints (org.kie.workbench.common.stunner.core.client.shape.view.HasControlPoints)1 HasEventHandlers (org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers)1