IsBST { public boolean checkRecursive(BinaryNode<Integer> root) { validateInput(root); return checkRecursiveInner(root); }  boolean checkRecursive(BinaryNode<Integer> root); boolean checkIterative(BinaryNode<Integer> root);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullBinaryTreesRecursive() { isBST.checkRecursive(null); }
@Test public void shouldReturnTrueIfTheTreeContainsJustOneNodeRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); assertTrue(isBST.checkRecursive(root)); }
@Test public void shouldReturnFalseIfLeftNodesAreGraterThanRightNodesRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); BinaryNode<Integer> n1 = new BinaryNode<Integer>(1); BinaryNode<Integer> n2 = new BinaryNode<Integer>(2); root.setLeft(n2); root.setRight(n1); assertFalse(isBST.checkRecursive(root)); }
@Test public void shouldReturnTrueIfBinaryTreeIsBSTRecursive() { BinaryNode<Integer> root = new BinaryNode<Integer>(0); BinaryNode<Integer> n1 = new BinaryNode<Integer>(1); BinaryNode<Integer> n2 = new BinaryNode<Integer>(2); n1.setLeft(root); n1.setRight(n2); assertTrue(isBST.checkRecursive(n1)); }