Search in sources :

Example 6 with CanvasElementUpdatedEvent

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

the class ExpressionEditorTest method testOnCanvasElementUpdated.

@Test
public void testOnCanvasElementUpdated() {
    final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(decision);
    setupExpression(decision, decision, toolbarStateHandler, false);
    testedEditor.handleCanvasElementUpdated(event);
    verify(view).setExpressionNameText(optionalHasNameCaptor.capture());
    verify(view).refresh();
    final Optional<HasName> optionalHasName = optionalHasNameCaptor.getValue();
    assertTrue(optionalHasName.isPresent());
    assertEquals(decision, optionalHasName.get());
}
Also used : HasName(org.kie.workbench.common.dmn.api.definition.HasName) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 7 with CanvasElementUpdatedEvent

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

the class ExpressionEditorTest method testOnCanvasElementUpdatedBusinessKnowledgeModel.

@Test
public void testOnCanvasElementUpdatedBusinessKnowledgeModel() {
    final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel();
    final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(bkm);
    setupExpression(bkm.asHasExpression(), bkm, toolbarStateHandler, false);
    testedEditor.handleCanvasElementUpdated(event);
    verify(view).setExpressionNameText(optionalHasNameCaptor.capture());
    verify(view).refresh();
    final Optional<HasName> optionalHasName = optionalHasNameCaptor.getValue();
    assertTrue(optionalHasName.isPresent());
    assertEquals(bkm, optionalHasName.get());
}
Also used : HasName(org.kie.workbench.common.dmn.api.definition.HasName) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 8 with CanvasElementUpdatedEvent

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

the class NodeTextSetterTest method testFireCanvasElementUpdated.

@Test
public void testFireCanvasElementUpdated() {
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final Node node = mock(Node.class);
    nodeTextSetter.fireCanvasElementUpdated(canvasHandler, node);
    verify(canvasElementUpdatedEvent).fire(canvasElementUpdatedEventArgumentCaptor.capture());
    final CanvasElementUpdatedEvent arg = canvasElementUpdatedEventArgumentCaptor.getValue();
    assertEquals(canvasHandler, arg.getCanvasHandler());
    assertEquals(node, arg.getElement());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Node(org.kie.workbench.common.stunner.core.graph.Node) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 9 with CanvasElementUpdatedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent 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 10 with CanvasElementUpdatedEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent 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)

Aggregations

Test (org.junit.Test)10 CanvasElementUpdatedEvent (org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent)10 HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 CanvasDomainObjectListener (org.kie.workbench.common.stunner.core.client.canvas.listener.CanvasDomainObjectListener)2 Node (org.kie.workbench.common.stunner.core.graph.Node)2 Optional (java.util.Optional)1 OptionalInt (java.util.OptionalInt)1 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)1 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1