Skip to content
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Random;
Expand All @@ -15,6 +16,7 @@ public void setUp() {
}

@Test
@DisplayName("Newly opened account has zero balance")
public void newlyOpenedAccountHasEmptyBalance() throws BankAccountActionInvalidException {
bankAccount.open();

Expand All @@ -23,6 +25,7 @@ public void newlyOpenedAccountHasEmptyBalance() throws BankAccountActionInvalidE

@Disabled("Remove to run test")
@Test
@DisplayName("Single deposit")
public void singleDeposit() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(100);
Expand All @@ -32,6 +35,7 @@ public void singleDeposit() throws BankAccountActionInvalidException {

@Disabled("Remove to run test")
@Test
@DisplayName("Multiple deposits")
public void multipleDeposits() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(100);
Expand All @@ -42,6 +46,7 @@ public void multipleDeposits() throws BankAccountActionInvalidException {

@Disabled("Remove to run test")
@Test
@DisplayName("Withdraw once")
public void withdrawOnce() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(100);
Expand All @@ -52,6 +57,7 @@ public void withdrawOnce() throws BankAccountActionInvalidException {

@Disabled("Remove to run test")
@Test
@DisplayName("Withdraw twice")
public void withdrawTwice() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(100);
Expand All @@ -63,6 +69,7 @@ public void withdrawTwice() throws BankAccountActionInvalidException {

@Disabled("Remove to run test")
@Test
@DisplayName("Can do multiple operations sequentially")
public void canDoMultipleOperationsSequentially() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(100);
Expand All @@ -76,6 +83,7 @@ public void canDoMultipleOperationsSequentially() throws BankAccountActionInvali

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot check balance of closed account")
public void cannotCheckBalanceOfClosedAccount() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.close();
Expand All @@ -87,6 +95,7 @@ public void cannotCheckBalanceOfClosedAccount() throws BankAccountActionInvalidE

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot deposit into closed account")
public void cannotDepositIntoClosedAccount() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.close();
Expand All @@ -98,6 +107,7 @@ public void cannotDepositIntoClosedAccount() throws BankAccountActionInvalidExce

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot deposit into unopened account")
public void cannotDepositIntoUnopenedAccount() {
assertThatExceptionOfType(BankAccountActionInvalidException.class)
.isThrownBy(() -> bankAccount.deposit(50))
Expand All @@ -106,6 +116,7 @@ public void cannotDepositIntoUnopenedAccount() {

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot withdraw from closed account")
public void cannotWithdrawFromClosedAccount() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.close();
Expand All @@ -117,6 +128,7 @@ public void cannotWithdrawFromClosedAccount() throws BankAccountActionInvalidExc

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot close an account that was not opened")
public void cannotCloseAnAccountThatWasNotOpened() {
assertThatExceptionOfType(BankAccountActionInvalidException.class)
.isThrownBy(bankAccount::close)
Expand All @@ -125,6 +137,7 @@ public void cannotCloseAnAccountThatWasNotOpened() {

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot open an already opened account")
public void cannotOpenAnAlreadyOpenedAccount() throws BankAccountActionInvalidException {
bankAccount.open();

Expand All @@ -135,6 +148,7 @@ public void cannotOpenAnAlreadyOpenedAccount() throws BankAccountActionInvalidEx

@Disabled("Remove to run test")
@Test
@DisplayName("Reopened account does not retain balance")
public void reopenedAccountDoesNotRetainBalance() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(50);
Expand All @@ -146,7 +160,8 @@ public void reopenedAccountDoesNotRetainBalance() throws BankAccountActionInvali

@Disabled("Remove to run test")
@Test
public void cannotWithdrawMoreThanWasDeposited() throws BankAccountActionInvalidException {
@DisplayName("Cannot withdraw more than deposited")
public void cannotWithdrawMoreThanDeposited() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(25);

Expand All @@ -157,6 +172,7 @@ public void cannotWithdrawMoreThanWasDeposited() throws BankAccountActionInvalid

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot withdraw negative")
public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidException {
bankAccount.open();
bankAccount.deposit(100);
Expand All @@ -168,6 +184,7 @@ public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidExcept

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot deposit negative")
public void cannotDepositNegativeAmount() throws BankAccountActionInvalidException {
bankAccount.open();

Expand All @@ -178,6 +195,7 @@ public void cannotDepositNegativeAmount() throws BankAccountActionInvalidExcepti

@Disabled("Remove to run test")
@Test
@DisplayName("Can handle concurrent transactions")
public void canHandleConcurrentTransactions() throws BankAccountActionInvalidException, InterruptedException {
bankAccount.open();
bankAccount.deposit(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

public class BinarySearchTreeTest {

@Test
@DisplayName("data is retained")
public void dataIsRetained() {
BinarySearchTree<Integer> binarySearchTree = new BinarySearchTree<>();

Expand All @@ -24,6 +26,7 @@ public void dataIsRetained() {

@Disabled("Remove to run test")
@Test
@DisplayName("insert data at proper node")
public void insertsLess() {
BinarySearchTree<Character> binarySearchTree = new BinarySearchTree<>();

Expand All @@ -45,6 +48,7 @@ public void insertsLess() {

@Disabled("Remove to run test")
@Test
@DisplayName("same number at left node")
public void insertsSame() {
BinarySearchTree<String> binarySearchTree = new BinarySearchTree<>();
String expectedRoot = "4";
Expand All @@ -65,6 +69,7 @@ public void insertsSame() {

@Disabled("Remove to run test")
@Test
@DisplayName("greater number at right node")
public void insertsRight() {
BinarySearchTree<Integer> binarySearchTree = new BinarySearchTree<>();
int expectedRoot = 4;
Expand All @@ -85,6 +90,7 @@ public void insertsRight() {

@Disabled("Remove to run test")
@Test
@DisplayName("can create complex tree")
public void createsComplexTree() {
BinarySearchTree<Character> binarySearchTree = new BinarySearchTree<>();
List<Character> expected = List.of('4', '2', '6', '1', '3', '5', '7');
Expand All @@ -97,6 +103,7 @@ public void createsComplexTree() {

@Disabled("Remove to run test")
@Test
@DisplayName("can sort single number")
public void sortsSingleElement() {
BinarySearchTree<String> binarySearchTree = new BinarySearchTree<>();
List<String> expected = Collections.singletonList("2");
Expand All @@ -108,6 +115,7 @@ public void sortsSingleElement() {

@Disabled("Remove to run test")
@Test
@DisplayName("can sort if second number is smaller than first")
public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {
BinarySearchTree<Integer> binarySearchTree = new BinarySearchTree<>();
List<Integer> expected = List.of(1, 2);
Expand All @@ -120,6 +128,7 @@ public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {

@Disabled("Remove to run test")
@Test
@DisplayName("can sort if second number is same as first")
public void sortsCollectionOfTwoIfSecondNumberisSameAsFirst() {
BinarySearchTree<Character> binarySearchTree = new BinarySearchTree<>();
List<Character> expected = List.of('2', '2');
Expand All @@ -132,6 +141,7 @@ public void sortsCollectionOfTwoIfSecondNumberisSameAsFirst() {

@Disabled("Remove to run test")
@Test
@DisplayName("can sort if second number is greater than first")
public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {
BinarySearchTree<Character> binarySearchTree = new BinarySearchTree<>();
List<Character> expected = List.of('2', '3');
Expand All @@ -144,6 +154,7 @@ public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {

@Disabled("Remove to run test")
@Test
@DisplayName("can sort complex tree")
public void iteratesOverComplexTree() {
BinarySearchTree<String> binarySearchTree = new BinarySearchTree<>();
List<String> expected = List.of("1", "2", "3", "5", "6", "7");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Collections;
Expand All @@ -10,6 +11,7 @@
public class BinarySearchTest {

@Test
@DisplayName("finds a value in an array with one element")
public void findsAValueInAnArrayWithOneElement() throws ValueNotFoundException {
List<Integer> listOfUnitLength = Collections.singletonList(6);

Expand All @@ -20,6 +22,7 @@ public void findsAValueInAnArrayWithOneElement() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("finds a value in the middle of an array")
public void findsAValueInTheMiddleOfAnArray() throws ValueNotFoundException {
List<Integer> sortedList = List.of(1, 3, 4, 6, 8, 9, 11);

Expand All @@ -30,6 +33,7 @@ public void findsAValueInTheMiddleOfAnArray() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("finds a value at the beginning of an array")
public void findsAValueAtTheBeginningOfAnArray() throws ValueNotFoundException {
List<Integer> sortedList = List.of(1, 3, 4, 6, 8, 9, 11);

Expand All @@ -40,6 +44,7 @@ public void findsAValueAtTheBeginningOfAnArray() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("finds a value at the end of an array")
public void findsAValueAtTheEndOfAnArray() throws ValueNotFoundException {
List<Integer> sortedList = List.of(1, 3, 4, 6, 8, 9, 11);

Expand All @@ -50,6 +55,7 @@ public void findsAValueAtTheEndOfAnArray() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("finds a value in an array of odd length")
public void findsAValueInAnArrayOfOddLength() throws ValueNotFoundException {
List<Integer> sortedListOfOddLength = List.of(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634);

Expand All @@ -60,6 +66,7 @@ public void findsAValueInAnArrayOfOddLength() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("finds a value in an array of even length")
public void findsAValueInAnArrayOfEvenLength() throws ValueNotFoundException {
List<Integer> sortedListOfEvenLength = List.of(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377);

Expand All @@ -70,6 +77,7 @@ public void findsAValueInAnArrayOfEvenLength() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("identifies that a value is not included in the array")
public void identifiesThatAValueIsNotFoundInTheArray() {
List<Integer> sortedList = List.of(1, 3, 4, 6, 8, 9, 11);

Expand All @@ -82,6 +90,7 @@ public void identifiesThatAValueIsNotFoundInTheArray() {

@Disabled("Remove to run test")
@Test
@DisplayName("a value smaller than the array's smallest value is not found")
public void aValueSmallerThanTheArraysSmallestValueIsNotFound() {
List<Integer> sortedList = List.of(1, 3, 4, 6, 8, 9, 11);

Expand All @@ -94,6 +103,7 @@ public void aValueSmallerThanTheArraysSmallestValueIsNotFound() {

@Disabled("Remove to run test")
@Test
@DisplayName("a value larger than the array's largest value is not found")
public void aValueLargerThanTheArraysLargestValueIsNotFound() throws ValueNotFoundException {
List<Integer> sortedList = List.of(1, 3, 4, 6, 8, 9, 11);

Expand All @@ -106,6 +116,7 @@ public void aValueLargerThanTheArraysLargestValueIsNotFound() throws ValueNotFou

@Disabled("Remove to run test")
@Test
@DisplayName("nothing is found in an empty array")
public void nothingIsFoundInAnEmptyArray() throws ValueNotFoundException {
List<Integer> emptyList = Collections.emptyList();

Expand All @@ -118,6 +129,7 @@ public void nothingIsFoundInAnEmptyArray() throws ValueNotFoundException {

@Disabled("Remove to run test")
@Test
@DisplayName("nothing is found when the left and right bounds cross")
public void nothingIsFoundWhenTheLeftAndRightBoundCross() throws ValueNotFoundException {
List<Integer> sortedList = List.of(1, 2);

Expand Down
Loading