Search in sources :

Example 6 with GraphNodeStoreImpl

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

the class AbstractCommandTest method setup.

@SuppressWarnings("unchecked")
public void setup() {
    MockitoAnnotations.initMocks(this);
    this.graph = new GraphImpl<>("graph", new GraphNodeStoreImpl());
    this.index = new MapIndex(graph, new HashMap<>(), new HashMap<>());
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getGraphExecutionContext()).thenReturn(context);
    when(context.getGraphIndex()).thenReturn(index);
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(diagram.getGraph()).thenReturn(graph);
    when(metadata.getDefinitionSetId()).thenReturn(DEF_SET_ID);
    when(metadata.getShapeSetId()).thenReturn(SHAPE_SET_ID);
    when(metadata.getCanvasRootUUID()).thenReturn(CANVAS_ROOT_UUID);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) HashMap(java.util.HashMap) MapIndex(org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndex)

Example 7 with GraphNodeStoreImpl

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

the class CaseManagementUtilsTest method checkGetFirstDiagramNodeWithNonEmptyGraph.

@Test
@SuppressWarnings("unchecked")
public void checkGetFirstDiagramNodeWithNonEmptyGraph() {
    final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl());
    final Node node = new NodeImpl<Definition>("node-uuid");
    final CaseManagementDiagram content = new CaseManagementDiagram.CaseManagementDiagramBuilder().build();
    node.setContent(new DefinitionImpl<>(content));
    graph.addNode(node);
    final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementUtils.getFirstDiagramNode(graph);
    assertNotNull(fNode);
    assertEquals("node-uuid", fNode.getUUID());
    assertEquals(content, fNode.getContent().getDefinition());
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) Graph(org.kie.workbench.common.stunner.core.graph.Graph) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) CaseManagementDiagram(org.kie.workbench.common.stunner.cm.definition.CaseManagementDiagram) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 8 with GraphNodeStoreImpl

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

the class ProjectDiagramImplTest method testProjectDiagramHashCode.

@Test
public void testProjectDiagramHashCode() {
    ProjectDiagramImpl a = new ProjectDiagramImpl("Diagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    ProjectDiagramImpl b = new ProjectDiagramImpl("AnotherDiagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    assertNotEquals(a.hashCode(), b.hashCode());
    b = new ProjectDiagramImpl("Diagram", new GraphImpl("Graph", new GraphNodeStoreImpl()), new ProjectMetadataImpl());
    assertEquals(a.hashCode(), b.hashCode());
    a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertEquals(a.hashCode(), b.hashCode());
    a.getGraph().addNode(new NodeImpl("Node1"));
    b.getGraph().addNode(new NodeImpl("Node2"));
    assertNotEquals(a.hashCode(), b.hashCode());
    b.getGraph().removeNode("Node2");
    b.getGraph().addNode(new NodeImpl("Node1"));
    assertEquals(a.hashCode(), b.hashCode());
    assertEquals(a.hashCode(), a.hashCode());
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Test(org.junit.Test)

Example 9 with GraphNodeStoreImpl

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

the class DiagramImplTest method testDiagramHashCode.

@Test
public void testDiagramHashCode() {
    DiagramImpl a = new DiagramImpl("Diagram", new MetadataImpl());
    DiagramImpl b = new DiagramImpl("AnotherDiagram", new MetadataImpl());
    assertNotEquals(a.hashCode(), b.hashCode());
    b = new DiagramImpl("Diagram", new MetadataImpl());
    assertEquals(a.hashCode(), b.hashCode());
    a.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    b.setGraph(new GraphImpl("Graph", new GraphNodeStoreImpl()));
    assertEquals(a.hashCode(), b.hashCode());
    a.getGraph().addNode(new NodeImpl("Node1"));
    b.getGraph().addNode(new NodeImpl("Node2"));
    assertNotEquals(a.hashCode(), b.hashCode());
    b.getGraph().removeNode("Node2");
    b.getGraph().addNode(new NodeImpl("Node1"));
    assertEquals(a.hashCode(), b.hashCode());
    assertEquals(a.hashCode(), a.hashCode());
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Test(org.junit.Test)

Example 10 with GraphNodeStoreImpl

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

the class HashCodeAndEqualityTest method testGraphEquals.

@Test
public void testGraphEquals() {
    GraphImpl<String> a = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
    GraphImpl<String> b = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
    assertEquals(a, b);
    NodeImpl<String> node = new NodeImpl<>("Node");
    a.addNode(node);
    assertNotEquals(a, b);
    b.addNode(node);
    assertEquals(a, b);
    assertEquals(a, a);
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) Test(org.junit.Test)

Aggregations

GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)11 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)10 Test (org.junit.Test)8 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)7 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)2 DefinitionSetImpl (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSetImpl)2 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)2 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)2 Annotation (java.lang.annotation.Annotation)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 CaseManagementDiagram (org.kie.workbench.common.stunner.cm.definition.CaseManagementDiagram)1 ZoomControl (org.kie.workbench.common.stunner.core.client.canvas.controls.zoom.ZoomControl)1 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 DiagramImpl (org.kie.workbench.common.stunner.core.diagram.DiagramImpl)1 MetadataImpl (org.kie.workbench.common.stunner.core.diagram.MetadataImpl)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)1 MapIndex (org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndex)1