@Test public void whenThen() { assertThat(tree.searchByValue(3), is("Element is found")); }
public String searchByValue(E value) { TreeNodeBinary<E> current = this; String result = "Element is not found"; while (current != null) { if (current.value == value) { result = "Element is found"; break; } else if (current.value.compareTo(value) > 0) { current = current.left; } else { current = current.right; } } return result; }
TreeNodeBinary { public String searchByValue(E value) { TreeNodeBinary<E> current = this; String result = "Element is not found"; while (current != null) { if (current.value == value) { result = "Element is found"; break; } else if (current.value.compareTo(value) > 0) { current = current.left; } else { current = current.right; } } return result; } }
TreeNodeBinary { public String searchByValue(E value) { TreeNodeBinary<E> current = this; String result = "Element is not found"; while (current != null) { if (current.value == value) { result = "Element is found"; break; } else if (current.value.compareTo(value) > 0) { current = current.left; } else { current = current.right; } } return result; } TreeNodeBinary(E value); }
TreeNodeBinary { public String searchByValue(E value) { TreeNodeBinary<E> current = this; String result = "Element is not found"; while (current != null) { if (current.value == value) { result = "Element is found"; break; } else if (current.value.compareTo(value) > 0) { current = current.left; } else { current = current.right; } } return result; } TreeNodeBinary(E value); void insert(E value); String searchByValue(E value); }
TreeNodeBinary { public String searchByValue(E value) { TreeNodeBinary<E> current = this; String result = "Element is not found"; while (current != null) { if (current.value == value) { result = "Element is found"; break; } else if (current.value.compareTo(value) > 0) { current = current.left; } else { current = current.right; } } return result; } TreeNodeBinary(E value); void insert(E value); String searchByValue(E value);  }