Search in sources :

Example 16 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DecisionNavigatorBaseItemFactoryTest method testMakeOnClickCommandWhenNodeBelongsToCurrentDiagram.

@Test
public void testMakeOnClickCommandWhenNodeBelongsToCurrentDiagram() {
    final String nodeUUID = "nodeUUID";
    final String nodeDiagramUUID = "diagramUUID";
    final String diagramUUID = "diagramUUID";
    final View content = mock(View.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    when(node.getUUID()).thenReturn(nodeUUID);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(hasContentDefinitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(nodeDiagramUUID);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
    when(dmnDiagramElement.getId()).thenReturn(new Id(diagramUUID));
    factory.makeOnClickCommand(node).execute();
    verify(canvasFocusUtils).focus(nodeUUID);
    verify(lazyCanvasFocusUtils, never()).lazyFocus(Mockito.<String>any());
    verify(selectedEvent, never()).fire(any());
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 17 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DecisionNavigatorBaseItemFactoryTest method testMakeOnClickCommandWhenNodeDoesNotBelongToCurrentDiagram.

@Test
public void testMakeOnClickCommandWhenNodeDoesNotBelongToCurrentDiagram() {
    final String nodeUUID = "nodeUUID";
    final String nodeDiagramUUID = "otherDiagramUUID";
    final String diagramUUID = "diagramUUID";
    final View content = mock(View.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    final DMNDiagramElement otherDiagramElement = mock(DMNDiagramElement.class);
    when(node.getUUID()).thenReturn(nodeUUID);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(hasContentDefinitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(nodeDiagramUUID);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(dmnDiagramElement));
    when(dmnDiagramsSession.getDMNDiagramElement(nodeDiagramUUID)).thenReturn(otherDiagramElement);
    when(dmnDiagramElement.getId()).thenReturn(new Id(diagramUUID));
    factory.makeOnClickCommand(node).execute();
    verify(canvasFocusUtils, never()).focus(Mockito.<String>any());
    verify(lazyCanvasFocusUtils).lazyFocus(nodeUUID);
    verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
    assertEquals(otherDiagramElement, diagramSelectedArgumentCaptor.getValue().getDiagramElement());
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 18 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DeleteNodeConfirmationImplTest method createElementMockWithContentId.

private Element createElementMockWithContentId(final String contentId) {
    final Element element = mock(Element.class);
    final Definition definition = mock(Definition.class);
    final HasContentDefinitionId contentDefinitionId = mock(HasContentDefinitionId.class);
    when(element.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(contentDefinitionId);
    when(contentDefinitionId.getContentDefinitionId()).thenReturn(contentId);
    return element;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Aggregations

HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)18 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)9 Node (org.kie.workbench.common.stunner.core.graph.Node)8 Test (org.junit.Test)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 Element (org.kie.workbench.common.stunner.core.graph.Element)4 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1