Search in sources :

Example 1 with CanvasDomainObjectListener

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

the class DMNGridLayerControlImplTest method testDoDestroyWithBoundSession.

@Test
public void testDoDestroyWithBoundSession() {
    control.bind(session);
    control.doInit();
    verify(canvasHandler).addRegistrationListener(canvasElementListenerCaptor.capture());
    verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
    final CanvasElementListener canvasElementListener = canvasElementListenerCaptor.getValue();
    final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
    control.doDestroy();
    assertNull(control.getGridLayer());
    verify(canvasHandler).removeRegistrationListener(eq(canvasElementListener));
    verify(canvasHandler).removeDomainObjectListener(eq(domainObjectListener));
}
Also used : CanvasDomainObjectListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener) CanvasElementListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasElementListener) Test(org.junit.Test)

Example 2 with CanvasDomainObjectListener

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

the class DMNGridLayerControlImplTest method testDoInitWithBoundSession.

@Test
public void testDoInitWithBoundSession() {
    control.bind(session);
    control.doInit();
    assertEquals(gridLayer, control.getGridLayer());
    verify(canvasHandler).addRegistrationListener(canvasElementListenerCaptor.capture());
    final CanvasElementListener canvasElementListener = canvasElementListenerCaptor.getValue();
    canvasElementListener.update(element);
    verify(gridLayer).batch();
    reset(gridLayer);
    verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
    final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
    domainObjectListener.update(domainObject);
    verify(gridLayer).batch();
}
Also used : CanvasDomainObjectListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener) CanvasElementListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasElementListener) Test(org.junit.Test)

Example 3 with CanvasDomainObjectListener

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

the class ExpressionEditorControlImplTest method testBindDomainObjectListenerWithNoNodeMatch.

@Test
public void testBindDomainObjectListenerWithNoNodeMatch() {
    when(graph.nodes()).thenReturn(Collections.emptyList());
    control.bind(session);
    verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
    final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
    domainObjectListener.update(domainObject);
    verify(canvasElementUpdatedEvent, never()).fire(any(CanvasElementUpdatedEvent.class));
}
Also used : CanvasDomainObjectListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 4 with CanvasDomainObjectListener

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

the class ExpressionEditorControlImplTest method testBindDomainObjectListenerWithNodeMatch.

@Test
public void testBindDomainObjectListenerWithNodeMatch() {
    final Definition definition = mock(Definition.class);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(domainObject);
    when(domainObject.getDomainObjectUUID()).thenReturn("uuid");
    control.bind(session);
    verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
    final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
    domainObjectListener.update(domainObject);
    verify(canvasElementUpdatedEvent).fire(canvasElementUpdatedEventCaptor.capture());
    final CanvasElementUpdatedEvent canvasElementUpdatedEvent = canvasElementUpdatedEventCaptor.getValue();
    assertThat(canvasElementUpdatedEvent.getCanvasHandler()).isEqualTo(canvasHandler);
    assertThat(canvasElementUpdatedEvent.getElement()).isEqualTo(node);
}
Also used : CanvasDomainObjectListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 5 with CanvasDomainObjectListener

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

the class ExpressionEditorControlImplTest method testDoDestroy.

@Test
public void testDoDestroy() {
    control.bind(session);
    verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
    control.doDestroy();
    assertNull(control.getExpressionEditor());
    final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
    verify(canvasHandler).removeDomainObjectListener(domainObjectListener);
}
Also used : CanvasDomainObjectListener(org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 CanvasDomainObjectListener (org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener)5 CanvasElementUpdatedEvent (org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent)2 CanvasElementListener (org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasElementListener)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)1