use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl 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());
}
use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl 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());
}
use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl 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());
}
use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl 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);
}
use of org.kie.workbench.common.stunner.core.graph.impl.GraphImpl in project kie-wb-common by kiegroup.
the class HashCodeAndEqualityTest method testGraphHashCode.
@Test
public void testGraphHashCode() {
GraphImpl<String> a = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
GraphImpl<String> b = new GraphImpl<String>("Graph", new GraphNodeStoreImpl());
assertEquals(a.hashCode(), b.hashCode());
NodeImpl<String> node = new NodeImpl<>("Node");
a.addNode(node);
assertNotEquals(a.hashCode(), b.hashCode());
b.addNode(node);
assertEquals(a.hashCode(), b.hashCode());
assertEquals(a.hashCode(), a.hashCode());
}
Aggregations