Traversal { public List<Integer> inOrderTraverse(BinaryTreeNode root) { List<Integer> result = new ArrayList<>(); if (root != null) { Stack<BinaryTreeNode> stack = new Stack<>(); BinaryTreeNode cur = root; while (!stack.isEmpty() || cur != null){ if (cur != null) { stack.push(cur); cur = cur.left; } else { cur = stack.pop(); result.add(cur.val); cur = cur.right; } } } return result; }  List<Integer> preOrderTraverse(BinaryTreeNode root); List<Integer> inOrderTraverse(BinaryTreeNode root); List<Integer> postOrderTraverse(BinaryTreeNode root);  }
@Test(dataProvider = "inOrderTree") public void testInOrder(BinaryTreeNode head, List<Integer> expectedResult){ Traversal traversal = new Traversal(); assertEquals(traversal.inOrderTraverse(head), expectedResult); }