Search in sources :

Example 1 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 testOnCanvasElementUpdatedDifferentNode.

@Test
@SuppressWarnings("unchecked")
public void testOnCanvasElementUpdatedDifferentNode() {
    final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
    final Decision differentNodeDefinition = mock(Decision.class);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(differentNodeDefinition);
    setupExpression(decision, decision, toolbarStateHandler, false);
    testedEditor.handleCanvasElementUpdated(event);
    verify(view, never()).setExpressionNameText(any(Optional.class));
}
Also used : Optional(java.util.Optional) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 2 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 testOnCanvasElementUpdated.

@Test
public void testOnCanvasElementUpdated() {
    control.bind(session);
    final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
    control.onCanvasElementUpdated(event);
    verify(editor).handleCanvasElementUpdated(event);
}
Also used : CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 3 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 testOnCanvasElementUpdatedDefinitions.

@Test
public void testOnCanvasElementUpdatedDefinitions() {
    final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
    final String NEW_DRG_NAME = "new-drg-name";
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(definitions);
    when(dmnDiagramsSession.isGlobalGraphSelected()).thenReturn(true);
    setupExpression(decision, decision, toolbarStateHandler, false);
    verify(view).setReturnToLinkText(eq(DRG_NAME));
    this.definitions.getName().setValue(NEW_DRG_NAME);
    testedEditor.handleCanvasElementUpdated(event);
    verify(view).setReturnToLinkText(eq(NEW_DRG_NAME));
}
Also used : CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) Test(org.junit.Test)

Example 4 with CanvasElementUpdatedEvent

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

the class TreeExplorerTest method testOnElementUpdated_childHighlighted.

@Test
public void testOnElementUpdated_childHighlighted() {
    final Node parent = mock(Node.class);
    when(parent.getUUID()).thenReturn("PARENT_UUID");
    when(parent.getContent()).thenReturn(mock(View.class));
    final Node child = mock(Node.class);
    when(child.getUUID()).thenReturn("CHILD_UUID");
    when(child.getContent()).thenReturn(mock(View.class));
    final Edge edge = mock(Edge.class);
    when(edge.getSourceNode()).thenReturn(parent);
    when(edge.getTargetNode()).thenReturn(child);
    when(edge.getContent()).thenReturn(mock(Child.class));
    final List<Edge> edges = Collections.singletonList(edge);
    when(parent.getOutEdges()).thenReturn(edges);
    when(child.getInEdges()).thenReturn(edges);
    when(view.isItemChanged(anyString(), anyString(), anyString(), anyInt(), any(OptionalInt.class))).thenReturn(true);
    testedTree.show(canvasHandler);
    final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, child);
    testedTree.onCanvasElementUpdatedEvent(event);
    verify(view, times(1)).setSelectedItem(eq("CHILD_UUID"));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) CanvasElementUpdatedEvent(org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent) OptionalInt(java.util.OptionalInt) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Test(org.junit.Test)

Example 5 with CanvasElementUpdatedEvent

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

the class DecisionNavigatorObserverTest method testOnCanvasElementUpdated.

@Test
public void testOnCanvasElementUpdated() {
    observer.init(presenter);
    observer.onCanvasElementUpdated(new CanvasElementUpdatedEvent(canvasHandler, element));
    verify(presenter).refresh();
}
Also used : 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