Skip to content

Commit b821416

Browse files
Completed with adding @DisplayName to bank-account, binary-search-tree, binary-search, bob, book-store (#2991)
* alphametics, anagram, armstrong-numbers, atbash-cipher * alphametics, armstrong-numbers * bank-account, binary-search-tree, binary-search, bob, book-store * Update exercises/practice/book-store/src/test/java/BookStoreTest.java Co-authored-by: Jagdish Prajapati <[email protected]> * Update exercises/practice/book-store/src/test/java/BookStoreTest.java Co-authored-by: Jagdish Prajapati <[email protected]> * binary-search * Update exercises/practice/book-store/src/test/java/BookStoreTest.java Co-authored-by: Jagdish Prajapati <[email protected]> [no important files changed] --------- Co-authored-by: Jagdish Prajapati <[email protected]>
1 parent 51896fc commit b821416

File tree

5 files changed

+91
-3
lines changed

5 files changed

+91
-3
lines changed

exercises/practice/bank-account/src/test/java/BankAccountTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.junit.jupiter.api.BeforeEach;
22
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
34
import org.junit.jupiter.api.Test;
45

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

1718
@Test
19+
@DisplayName("Newly opened account has zero balance")
1820
public void newlyOpenedAccountHasEmptyBalance() throws BankAccountActionInvalidException {
1921
bankAccount.open();
2022

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

2426
@Disabled("Remove to run test")
2527
@Test
28+
@DisplayName("Single deposit")
2629
public void singleDeposit() throws BankAccountActionInvalidException {
2730
bankAccount.open();
2831
bankAccount.deposit(100);
@@ -32,6 +35,7 @@ public void singleDeposit() throws BankAccountActionInvalidException {
3235

3336
@Disabled("Remove to run test")
3437
@Test
38+
@DisplayName("Multiple deposits")
3539
public void multipleDeposits() throws BankAccountActionInvalidException {
3640
bankAccount.open();
3741
bankAccount.deposit(100);
@@ -42,6 +46,7 @@ public void multipleDeposits() throws BankAccountActionInvalidException {
4246

4347
@Disabled("Remove to run test")
4448
@Test
49+
@DisplayName("Withdraw once")
4550
public void withdrawOnce() throws BankAccountActionInvalidException {
4651
bankAccount.open();
4752
bankAccount.deposit(100);
@@ -52,6 +57,7 @@ public void withdrawOnce() throws BankAccountActionInvalidException {
5257

5358
@Disabled("Remove to run test")
5459
@Test
60+
@DisplayName("Withdraw twice")
5561
public void withdrawTwice() throws BankAccountActionInvalidException {
5662
bankAccount.open();
5763
bankAccount.deposit(100);
@@ -63,6 +69,7 @@ public void withdrawTwice() throws BankAccountActionInvalidException {
6369

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

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

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

99108
@Disabled("Remove to run test")
100109
@Test
110+
@DisplayName("Cannot deposit into unopened account")
101111
public void cannotDepositIntoUnopenedAccount() {
102112
assertThatExceptionOfType(BankAccountActionInvalidException.class)
103113
.isThrownBy(() -> bankAccount.deposit(50))
@@ -106,6 +116,7 @@ public void cannotDepositIntoUnopenedAccount() {
106116

107117
@Disabled("Remove to run test")
108118
@Test
119+
@DisplayName("Cannot withdraw from closed account")
109120
public void cannotWithdrawFromClosedAccount() throws BankAccountActionInvalidException {
110121
bankAccount.open();
111122
bankAccount.close();
@@ -117,6 +128,7 @@ public void cannotWithdrawFromClosedAccount() throws BankAccountActionInvalidExc
117128

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

126138
@Disabled("Remove to run test")
127139
@Test
140+
@DisplayName("Cannot open an already opened account")
128141
public void cannotOpenAnAlreadyOpenedAccount() throws BankAccountActionInvalidException {
129142
bankAccount.open();
130143

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

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

147161
@Disabled("Remove to run test")
148162
@Test
149-
public void cannotWithdrawMoreThanWasDeposited() throws BankAccountActionInvalidException {
163+
@DisplayName("Cannot withdraw more than deposited")
164+
public void cannotWithdrawMoreThanDeposited() throws BankAccountActionInvalidException {
150165
bankAccount.open();
151166
bankAccount.deposit(25);
152167

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

158173
@Disabled("Remove to run test")
159174
@Test
175+
@DisplayName("Cannot withdraw negative")
160176
public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidException {
161177
bankAccount.open();
162178
bankAccount.deposit(100);
@@ -168,6 +184,7 @@ public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidExcept
168184

169185
@Disabled("Remove to run test")
170186
@Test
187+
@DisplayName("Cannot deposit negative")
171188
public void cannotDepositNegativeAmount() throws BankAccountActionInvalidException {
172189
bankAccount.open();
173190

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

179196
@Disabled("Remove to run test")
180197
@Test
198+
@DisplayName("Can handle concurrent transactions")
181199
public void canHandleConcurrentTransactions() throws BankAccountActionInvalidException, InterruptedException {
182200
bankAccount.open();
183201
bankAccount.deposit(1000);

exercises/practice/binary-search-tree/src/test/java/BinarySearchTreeTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
import static org.assertj.core.api.Assertions.assertThat;
66
import org.junit.jupiter.api.Disabled;
7+
import org.junit.jupiter.api.DisplayName;
78
import org.junit.jupiter.api.Test;
89

910
public class BinarySearchTreeTest {
1011

1112
@Test
13+
@DisplayName("data is retained")
1214
public void dataIsRetained() {
1315
BinarySearchTree<Integer> binarySearchTree = new BinarySearchTree<>();
1416

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

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

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

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

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

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

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

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

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

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

145155
@Disabled("Remove to run test")
146156
@Test
157+
@DisplayName("can sort complex tree")
147158
public void iteratesOverComplexTree() {
148159
BinarySearchTree<String> binarySearchTree = new BinarySearchTree<>();
149160
List<String> expected = List.of("1", "2", "3", "5", "6", "7");

exercises/practice/binary-search/src/test/java/BinarySearchTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
33

44
import org.junit.jupiter.api.Disabled;
5+
import org.junit.jupiter.api.DisplayName;
56
import org.junit.jupiter.api.Test;
67

78
import java.util.Collections;
@@ -10,6 +11,7 @@
1011
public class BinarySearchTest {
1112

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)