Search in sources :

Example 1 with ShapeViewExtStub

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

the class AbstractControlTest method setUp.

public void setUp() {
    shapeView = new ShapeViewExtStub(shapeEventHandler, hasControlPoints);
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getAbstractCanvas()).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.MOUSE_CLICK))).thenReturn(true);
    when(shapeEventHandler.supports(eq(ViewEventType.MOUSE_ENTER))).thenReturn(true);
    when(shapeEventHandler.supports(eq(ViewEventType.MOUSE_EXIT))).thenReturn(true);
    when(shapeEventHandler.supports(eq(ViewEventType.DRAG))).thenReturn(true);
}
Also used : ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub)

Example 2 with ShapeViewExtStub

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

the class MapSelectionControlTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    ShapeViewExtStub shapeView = new ShapeViewExtStub(shapeEventHandler, hasControlPoints);
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(element.getContent()).thenReturn(new ViewImpl<>(definition, BoundsImpl.build(0, 0, 10, 10)));
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    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.MOUSE_CLICK))).thenReturn(true);
    this.tested = new MapSelectionControl(e -> elementSelectedEvent.fire((CanvasSelectionEvent) e), e -> clearSelectionEvent.fire((CanvasClearSelectionEvent) e));
    this.tested.setReadonly(false);
}
Also used : CanvasClearSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent) HasEventHandlers(org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers) ViewHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewHandler) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) HasControlPoints(org.kie.workbench.common.stunner.core.client.shape.view.HasControlPoints) AbstractCanvas(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) Layer(org.kie.workbench.common.stunner.core.client.canvas.Layer) CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.eq(org.mockito.Matchers.eq) CanvasShapeRemovedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasShapeRemovedEvent) ShapeState(org.kie.workbench.common.stunner.core.client.shape.ShapeState) Element(org.kie.workbench.common.stunner.core.graph.Element) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Before(org.junit.Before) ViewEventType(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) MouseClickHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) ShapeView(org.kie.workbench.common.stunner.core.client.shape.view.ShapeView) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Mockito.never(org.mockito.Mockito.never) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Assert.assertFalse(org.junit.Assert.assertFalse) ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) EventSourceMock(org.uberfire.mocks.EventSourceMock) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) Before(org.junit.Before)

Example 3 with ShapeViewExtStub

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

the class NodeShapeImplTest method setup.

@Before
public void setup() throws Exception {
    when(shapeStateHandler.shapeAttributesChanged()).thenReturn(shapeStateHandler);
    when(def.titleHandler()).thenReturn(Optional.of(titleHandler));
    when(def.fontHandler()).thenReturn(Optional.of(fontHandler));
    when(def.sizeHandler()).thenReturn(Optional.of(sizeHandler));
    when(def.viewHandler()).thenReturn(viewHandler);
    when(element.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(definition);
    when(content.getBounds()).thenReturn(bounds);
    when(bounds.getUpperLeft()).thenReturn(new BoundImpl(10d, 20d));
    when(bounds.getLowerRight()).thenReturn(new BoundImpl(50d, 60d));
    this.view = spy(new ShapeViewExtStub());
    this.tested = new NodeShapeImpl<>(def, new ShapeImpl<>(view, shapeStateHandler));
}
Also used : ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) Before(org.junit.Before)

Example 4 with ShapeViewExtStub

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

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

the class ToolboxControlImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    this.shapeView = new ShapeViewExtStub(shapeEventHandler, hasControlPoints);
    when(element.getUUID()).thenReturn(ELEMENT_UUID);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    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.MOUSE_CLICK))).thenReturn(true);
    when(toolboxFactory.build(eq(canvasHandler), eq(element))).thenReturn(Optional.of(toolbox));
    when(showToolboxPredicate.test(anyString())).thenReturn(true);
    this.tested = new ToolboxControlImpl(() -> Collections.singletonList(toolboxFactory), showToolboxPredicate);
}
Also used : ShapeViewExtStub(org.kie.workbench.common.stunner.core.client.shape.ShapeViewExtStub) 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