Search in sources :

Example 1 with CanvasClearSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent 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 2 with CanvasClearSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.

the class MapSelectionControlTest method testOnClearSelectionEvent.

@Test
public void testOnClearSelectionEvent() {
    tested.enable(canvasHandler);
    tested.register(element);
    tested.select(element);
    CanvasClearSelectionEvent event = new CanvasClearSelectionEvent(canvasHandler);
    tested.onCanvasClearSelection(event);
    assertTrue(tested.getSelectedItems().isEmpty());
    verify(canvas, atLeastOnce()).draw();
    verify(shape, times(1)).applyState(eq(ShapeState.SELECTED));
    verify(shape, times(1)).applyState(eq(ShapeState.NONE));
    verify(shape, never()).applyState(eq(ShapeState.INVALID));
    verify(shape, never()).applyState(eq(ShapeState.HIGHLIGHT));
    verify(clearSelectionEvent, never()).fire(any(CanvasClearSelectionEvent.class));
}
Also used : CanvasClearSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent) Test(org.junit.Test)

Example 3 with CanvasClearSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.

the class ToolboxControlTest method testClearSelectionEvent.

@Test
public void testClearSelectionEvent() {
    final CanvasClearSelectionEvent event = new CanvasClearSelectionEvent(canvasHandler);
    tested.onCanvasClearSelectionEvent(event);
    verify(delegated, times(1)).destroy();
    verify(delegated, never()).show(any(Element.class));
    verify(delegated, never()).show(anyString());
}
Also used : CanvasClearSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent) Element(org.kie.workbench.common.stunner.core.graph.Element) Test(org.junit.Test)

Example 4 with CanvasClearSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.

the class AbstractSelectionAwareSessionCommandTest method testOnCanvasClearSelection.

@Test
public void testOnCanvasClearSelection() {
    CanvasClearSelectionEvent event = new CanvasClearSelectionEvent(canvasHandler);
    command.onCanvasClearSelectionEvent(event);
    verify(command, times(1)).handleCanvasClearSelectionEvent(event);
    event = new CanvasClearSelectionEvent(anotherCanvasHandler);
    command.onCanvasClearSelectionEvent(event);
    verify(command, never()).handleCanvasClearSelectionEvent(event);
}
Also used : CanvasClearSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent) Test(org.junit.Test)

Example 5 with CanvasClearSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.

the class BaseSessionCommandKeyboardSelectionAwareTest method testHandleCanvasClearSelectionEvent.

@Test
public void testHandleCanvasClearSelectionEvent() {
    command.bind(session);
    ((AbstractSelectionAwareSessionCommand) command).handleCanvasClearSelectionEvent(new CanvasClearSelectionEvent(canvasHandler));
    assertFalse(command.isEnabled());
    verify(statusCallback, times(1)).execute();
}
Also used : CanvasClearSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent) Test(org.junit.Test)

Aggregations

CanvasClearSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent)6 Test (org.junit.Test)5 Element (org.kie.workbench.common.stunner.core.graph.Element)3 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 Dependent (javax.enterprise.context.Dependent)1 Event (javax.enterprise.event.Event)1 Inject (javax.inject.Inject)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 RunWith (org.junit.runner.RunWith)1 PortablePreconditions.checkNotNull (org.kie.soup.commons.validation.PortablePreconditions.checkNotNull)1 AbstractCanvas (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas)1