11import org .junit .jupiter .api .BeforeEach ;
22import org .junit .jupiter .api .Disabled ;
3+ import org .junit .jupiter .api .DisplayName ;
34import org .junit .jupiter .api .Test ;
45
56import java .util .Random ;
@@ -14,54 +15,55 @@ public void setUp() {
1415 bankAccount = new BankAccount ();
1516 }
1617
18+ @ DisplayName ("Newly opened account has empty balance" )
1719 @ Test
1820 public void newlyOpenedAccountHasEmptyBalance () throws BankAccountActionInvalidException {
1921 bankAccount .open ();
20-
2122 assertThat (bankAccount .getBalance ()).isEqualTo (0 );
2223 }
2324
2425 @ Disabled ("Remove to run test" )
26+ @ DisplayName ("Deposit into account" )
2527 @ Test
2628 public void singleDeposit () throws BankAccountActionInvalidException {
2729 bankAccount .open ();
2830 bankAccount .deposit (100 );
29-
3031 assertThat (bankAccount .getBalance ()).isEqualTo (100 );
3132 }
3233
3334 @ Disabled ("Remove to run test" )
35+ @ DisplayName ("Deposit into account several times" )
3436 @ Test
3537 public void multipleDeposits () throws BankAccountActionInvalidException {
3638 bankAccount .open ();
3739 bankAccount .deposit (100 );
3840 bankAccount .deposit (50 );
39-
4041 assertThat (bankAccount .getBalance ()).isEqualTo (150 );
4142 }
4243
4344 @ Disabled ("Remove to run test" )
45+ @ DisplayName ("Withdraw some money" )
4446 @ Test
4547 public void withdrawOnce () throws BankAccountActionInvalidException {
4648 bankAccount .open ();
4749 bankAccount .deposit (100 );
4850 bankAccount .withdraw (75 );
49-
5051 assertThat (bankAccount .getBalance ()).isEqualTo (25 );
5152 }
5253
5354 @ Disabled ("Remove to run test" )
55+ @ DisplayName ("Withdraw entire balance" )
5456 @ Test
5557 public void withdrawTwice () throws BankAccountActionInvalidException {
5658 bankAccount .open ();
5759 bankAccount .deposit (100 );
5860 bankAccount .withdraw (80 );
5961 bankAccount .withdraw (20 );
60-
6162 assertThat (bankAccount .getBalance ()).isEqualTo (0 );
6263 }
6364
6465 @ Disabled ("Remove to run test" )
66+ @ DisplayName ("Can do multiple operations sequentially" )
6567 @ Test
6668 public void canDoMultipleOperationsSequentially () throws BankAccountActionInvalidException {
6769 bankAccount .open ();
@@ -70,33 +72,33 @@ public void canDoMultipleOperationsSequentially() throws BankAccountActionInvali
7072 bankAccount .withdraw (200 );
7173 bankAccount .deposit (60 );
7274 bankAccount .withdraw (50 );
73-
7475 assertThat (bankAccount .getBalance ()).isEqualTo (20 );
7576 }
7677
7778 @ Disabled ("Remove to run test" )
79+ @ DisplayName ("Cannot get balance of closed account" )
7880 @ Test
7981 public void cannotCheckBalanceOfClosedAccount () throws BankAccountActionInvalidException {
8082 bankAccount .open ();
8183 bankAccount .close ();
82-
8384 assertThatExceptionOfType (BankAccountActionInvalidException .class )
8485 .isThrownBy (bankAccount ::getBalance )
8586 .withMessage ("Account closed" );
8687 }
8788
8889 @ Disabled ("Remove to run test" )
90+ @ DisplayName ("Cannot deposit money into closed account" )
8991 @ Test
9092 public void cannotDepositIntoClosedAccount () throws BankAccountActionInvalidException {
9193 bankAccount .open ();
9294 bankAccount .close ();
93-
9495 assertThatExceptionOfType (BankAccountActionInvalidException .class )
9596 .isThrownBy (() -> bankAccount .deposit (50 ))
9697 .withMessage ("Account closed" );
9798 }
9899
99100 @ Disabled ("Remove to run test" )
101+ @ DisplayName ("Cannot deposit money into unopened account" )
100102 @ Test
101103 public void cannotDepositIntoUnopenedAccount () {
102104 assertThatExceptionOfType (BankAccountActionInvalidException .class )
@@ -105,17 +107,18 @@ public void cannotDepositIntoUnopenedAccount() {
105107 }
106108
107109 @ Disabled ("Remove to run test" )
110+ @ DisplayName ("Cannot withdraw money from closed account" )
108111 @ Test
109112 public void cannotWithdrawFromClosedAccount () throws BankAccountActionInvalidException {
110113 bankAccount .open ();
111114 bankAccount .close ();
112-
113115 assertThatExceptionOfType (BankAccountActionInvalidException .class )
114116 .isThrownBy (() -> bankAccount .withdraw (50 ))
115117 .withMessage ("Account closed" );
116118 }
117119
118120 @ Disabled ("Remove to run test" )
121+ @ DisplayName ("Cannot close unopened account" )
119122 @ Test
120123 public void cannotCloseAnAccountThatWasNotOpened () {
121124 assertThatExceptionOfType (BankAccountActionInvalidException .class )
@@ -124,59 +127,60 @@ public void cannotCloseAnAccountThatWasNotOpened() {
124127 }
125128
126129 @ Disabled ("Remove to run test" )
130+ @ DisplayName ("Cannot open already opened account" )
127131 @ Test
128132 public void cannotOpenAnAlreadyOpenedAccount () throws BankAccountActionInvalidException {
129133 bankAccount .open ();
130-
131134 assertThatExceptionOfType (BankAccountActionInvalidException .class )
132135 .isThrownBy (bankAccount ::open )
133136 .withMessage ("Account already open" );
134137 }
135138
136139 @ Disabled ("Remove to run test" )
140+ @ DisplayName ("Reopened account does not retain balance" )
137141 @ Test
138142 public void reopenedAccountDoesNotRetainBalance () throws BankAccountActionInvalidException {
139143 bankAccount .open ();
140144 bankAccount .deposit (50 );
141145 bankAccount .close ();
142146 bankAccount .open ();
143-
144147 assertThat (bankAccount .getBalance ()).isEqualTo (0 );
145148 }
146149
147150 @ Disabled ("Remove to run test" )
151+ @ DisplayName ("Cannot withdraw more than was deposited" )
148152 @ Test
149153 public void cannotWithdrawMoreThanWasDeposited () throws BankAccountActionInvalidException {
150154 bankAccount .open ();
151155 bankAccount .deposit (25 );
152-
153156 assertThatExceptionOfType (BankAccountActionInvalidException .class )
154157 .isThrownBy (() -> bankAccount .withdraw (50 ))
155158 .withMessage ("Cannot withdraw more money than is currently in the account" );
156159 }
157160
158161 @ Disabled ("Remove to run test" )
162+ @ DisplayName ("Cannot withdraw negative amount" )
159163 @ Test
160164 public void cannotWithdrawNegativeAmount () throws BankAccountActionInvalidException {
161165 bankAccount .open ();
162166 bankAccount .deposit (100 );
163-
164167 assertThatExceptionOfType (BankAccountActionInvalidException .class )
165168 .isThrownBy (() -> bankAccount .withdraw (-50 ))
166169 .withMessage ("Cannot deposit or withdraw negative amount" );
167170 }
168171
169172 @ Disabled ("Remove to run test" )
173+ @ DisplayName ("Cannot deposit negative amount" )
170174 @ Test
171175 public void cannotDepositNegativeAmount () throws BankAccountActionInvalidException {
172176 bankAccount .open ();
173-
174177 assertThatExceptionOfType (BankAccountActionInvalidException .class )
175178 .isThrownBy (() -> bankAccount .deposit (-50 ))
176179 .withMessage ("Cannot deposit or withdraw negative amount" );
177180 }
178181
179182 @ Disabled ("Remove to run test" )
183+ @ DisplayName ("Can handle concurrent transactions" )
180184 @ Test
181185 public void canHandleConcurrentTransactions () throws BankAccountActionInvalidException , InterruptedException {
182186 bankAccount .open ();
0 commit comments