condense a little bit the code of test data

This commit is contained in:
Yavuz Tas 2019-11-30 08:33:51 +01:00
parent cd4e521a3b
commit 6dde04eed2
1 changed files with 15 additions and 24 deletions

View File

@ -32,34 +32,29 @@ public class PrintingBinaryTreeModelUnitTest {
public void tearDown() {
System.setOut(System.out);
}
private BinaryTreeModel createBalancedTree() {
BinaryTreeModel root = new BinaryTreeModel("root");
BinaryTreeModel node1 = new BinaryTreeModel("node1");
BinaryTreeModel node2 = new BinaryTreeModel("node2");
root.setLeft(node1);
root.setRight(node2);
BinaryTreeModel node3 = new BinaryTreeModel("node3");
BinaryTreeModel node4 = new BinaryTreeModel("node4");
node1.setLeft(node3);
node1.setRight(node4);
BinaryTreeModel node5 = new BinaryTreeModel("node5");
BinaryTreeModel node6 = new BinaryTreeModel("node6");
node2.setLeft(node5);
node2.setRight(node6);
node2.setLeft(new BinaryTreeModel("node5"));
node2.setRight(new BinaryTreeModel("node6"));
BinaryTreeModel node7 = new BinaryTreeModel("node7");
node3.setLeft(node7);
BinaryTreeModel node8 = new BinaryTreeModel("node8");
BinaryTreeModel node9 = new BinaryTreeModel("node9");
node7.setLeft(node8);
node7.setRight(node9);
node7.setLeft(new BinaryTreeModel("node8"));
node7.setRight(new BinaryTreeModel("node9"));
return root;
}
@ -68,9 +63,8 @@ public class PrintingBinaryTreeModelUnitTest {
BinaryTreeModel root = new BinaryTreeModel("root");
BinaryTreeModel node1 = new BinaryTreeModel("node1");
BinaryTreeModel node2 = new BinaryTreeModel("node2");
root.setLeft(node1);
root.setRight(node2);
root.setRight(new BinaryTreeModel("node2"));
BinaryTreeModel node3 = new BinaryTreeModel("node3");
node1.setLeft(node3);
@ -87,8 +81,7 @@ public class PrintingBinaryTreeModelUnitTest {
BinaryTreeModel node7 = new BinaryTreeModel("node7");
node6.setLeft(node7);
BinaryTreeModel node8 = new BinaryTreeModel("node8");
node7.setLeft(node8);
node7.setLeft(new BinaryTreeModel("node8"));
return root;
}
@ -97,9 +90,8 @@ public class PrintingBinaryTreeModelUnitTest {
BinaryTreeModel root = new BinaryTreeModel("root");
BinaryTreeModel node1 = new BinaryTreeModel("node1");
BinaryTreeModel node2 = new BinaryTreeModel("node2");
root.setLeft(node1);
root.setLeft(new BinaryTreeModel("node1"));
root.setRight(node2);
BinaryTreeModel node3 = new BinaryTreeModel("node3");
@ -117,8 +109,7 @@ public class PrintingBinaryTreeModelUnitTest {
BinaryTreeModel node7 = new BinaryTreeModel("node7");
node6.setRight(node7);
BinaryTreeModel node8 = new BinaryTreeModel("node8");
node7.setRight(node8);
node7.setRight(new BinaryTreeModel("node8"));
return root;
}