Search in sources :

Example 1 with GraphsProvider

use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.

the class ContentDefinitionIdUtilsTest method testNodeBelongsToCurrentGraph.

@Test
public void testNodeBelongsToCurrentGraph() {
    final String currentDiagramId = "currentDiagramId";
    final Node node = createNode(currentDiagramId);
    final GraphsProvider graphsProvider = createGraphsProvider(currentDiagramId);
    assertTrue(belongsToCurrentGraph(node, graphsProvider));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Test(org.junit.Test)

Example 2 with GraphsProvider

use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.

the class ContentDefinitionIdUtilsTest method testEdgeBelongsToCurrentGraphWhenDoesNot.

@Test
public void testEdgeBelongsToCurrentGraphWhenDoesNot() {
    final String nodeDiagramId = "nodeDiagramId";
    final String currentDiagramId = "currentDiagramId";
    final Node node = createNode(nodeDiagramId);
    final Edge edge = createEdge(node, null);
    final GraphsProvider graphsProvider = createGraphsProvider(currentDiagramId);
    assertFalse(belongsToCurrentGraph(edge, graphsProvider));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Edge(org.kie.workbench.common.stunner.core.graph.Edge) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Test(org.junit.Test)

Example 3 with GraphsProvider

use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.

the class ContentDefinitionIdUtilsTest method testNodeBelongsToCurrentGraphWhenDoesNot.

@Test
public void testNodeBelongsToCurrentGraphWhenDoesNot() {
    final String nodeDiagramId = "nodeDiagramId";
    final String currentDiagramId = "currentDiagramId";
    final Node node = createNode(nodeDiagramId);
    final GraphsProvider graphsProvider = createGraphsProvider(currentDiagramId);
    assertFalse(belongsToCurrentGraph(node, graphsProvider));
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Test(org.junit.Test)

Example 4 with GraphsProvider

use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.

the class ContentDefinitionIdUtilsTest method createGraphsProvider.

private GraphsProvider createGraphsProvider(final String currentDiagramId) {
    final GraphsProvider graphsProvider = mock(GraphsProvider.class);
    when(graphsProvider.getCurrentDiagramId()).thenReturn(currentDiagramId);
    return graphsProvider;
}
Also used : GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider)

Example 5 with GraphsProvider

use of org.kie.workbench.common.stunner.core.diagram.GraphsProvider in project kie-wb-common by kiegroup.

the class DeleteNodeConfirmationImplTest method testInit.

@Test
public void testInit() {
    final ClientSession session = mock(ClientSession.class);
    final CanvasHandler canvasHandler = mock(CanvasHandler.class);
    final Diagram diagram = mock(Diagram.class);
    final Metadata metadata = mock(Metadata.class);
    final String definitionId = "definitionId";
    final Annotation qualifier = mock(Annotation.class);
    final ManagedInstance<GraphsProvider> foundInstances = mock(ManagedInstance.class);
    final GraphsProvider foundInstance = mock(GraphsProvider.class);
    when(foundInstances.isUnsatisfied()).thenReturn(false);
    when(foundInstances.get()).thenReturn(foundInstance);
    when(graphsProviderInstances.select(GraphsProvider.class, qualifier)).thenReturn(foundInstances);
    when(definitionUtils.getQualifier(definitionId)).thenReturn(qualifier);
    when(metadata.getDefinitionSetId()).thenReturn(definitionId);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    confirmation.init();
    final GraphsProvider actualProvider = confirmation.getGraphsProvider();
    assertEquals(actualProvider, foundInstance);
}
Also used : ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Annotation(java.lang.annotation.Annotation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Aggregations

GraphsProvider (org.kie.workbench.common.stunner.core.diagram.GraphsProvider)11 Test (org.junit.Test)8 Node (org.kie.workbench.common.stunner.core.graph.Node)7 ArrayDeque (java.util.ArrayDeque)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 ChildrenTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl)3 TreeWalkTraverseProcessorImpl (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl)3 Annotation (java.lang.annotation.Annotation)2 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Deque (java.util.Deque)1 PostConstruct (javax.annotation.PostConstruct)1 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 Element (org.kie.workbench.common.stunner.core.graph.Element)1 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)1 AbstractTreeTraverseCallback (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.AbstractTreeTraverseCallback)1 TreeWalkTraverseProcessor (org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessor)1