01: /*
02: * DependencyNodeTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.db;
13:
14: import junit.framework.TestCase;
15:
16: /**
17: *
18: * @author support@sql-workbench.net
19: */
20: public class DependencyNodeTest extends TestCase {
21: public DependencyNodeTest(String testName) {
22: super (testName);
23: }
24:
25: public void testGetLevel() {
26: TableIdentifier root = new TableIdentifier("root");
27: DependencyNode rootNode = new DependencyNode(root);
28: assertEquals("Wrong level for root", 0, rootNode.getLevel());
29:
30: TableIdentifier child1 = new TableIdentifier("child1");
31: DependencyNode cnode = rootNode.addChild(child1, "test");
32: assertEquals("Wrong level for first child", 1, cnode.getLevel());
33:
34: TableIdentifier child2 = new TableIdentifier("child2");
35: DependencyNode cnode2 = rootNode.addChild(child2, "test_2");
36: assertEquals("Wrong level for second child", 1, cnode2
37: .getLevel());
38:
39: TableIdentifier child3 = new TableIdentifier("child3");
40: DependencyNode cnode3 = cnode2.addChild(child3, "test_3");
41: assertEquals("Wrong level for third child", 2, cnode3
42: .getLevel());
43:
44: DependencyNode f = rootNode.findNode(cnode3);
45: assertNotNull(f);
46: assertEquals(f, cnode3);
47: }
48:
49: }
|