|
|
|
|
83
|
1. Create a `PaymentPresenterTest`
|
83
|
1. Create a `PaymentPresenterTest`
|
84
|
2. Create a test case to test the `toString` method of the PaymentPresenter class
|
84
|
2. Create a test case to test the `toString` method of the PaymentPresenter class
|
85
|
- When there is no payment
|
85
|
- When there is no payment
|
|
|
86
|
+
|
86
|
```
|
87
|
```
|
87
|
Payment[] payments = new Payment[0];
|
88
|
Payment[] payments = new Payment[0];
|
88
|
PaymentPresenter presenter = new PaymentPresenter();
|
89
|
PaymentPresenter presenter = new PaymentPresenter();
|
|
|
|
|
92
|
|
93
|
|
93
|
assertEquals(expected, actual);
|
94
|
assertEquals(expected, actual);
|
94
|
```
|
95
|
```
|
|
|
96
|
+
|
95
|
- When there are multiple payments, you need to sort it first, then build the string using the short description
|
97
|
- When there are multiple payments, you need to sort it first, then build the string using the short description
|
|
|
98
|
+
|
96
|
```
|
99
|
```
|
97
|
Payment[] payments = new Payment[2];
|
100
|
Payment[] payments = new Payment[2];
|
98
|
Payment paypal = new PayPayl(4L, "Tia Mowry", "tia@mowry.com");
|
101
|
Payment paypal = new PayPayl(4L, "Tia Mowry", "tia@mowry.com");
|
|
|
|
|
106
|
String actual = presenter.toString(payments);
|
109
|
String actual = presenter.toString(payments);
|
107
|
assertEquals(expected, actual);
|
110
|
assertEquals(expected, actual);
|
108
|
```
|
111
|
```
|
|
|
112
|
+
|
109
|
3. Create a test case to test the `toStringByPayerName` method of the PaymentPresenter class
|
113
|
3. Create a test case to test the `toStringByPayerName` method of the PaymentPresenter class
|
110
|
- When there are multiple payments, you need to sort by calling the `PaymentSortByPayer` class to sort, then build the string using the short description
|
114
|
- When there are multiple payments, you need to sort by calling the `PaymentSortByPayer` class to sort, then build the string using the short description
|
|
|
115
|
+
|
111
|
```
|
116
|
```
|
112
|
Payment[] payments = new Payment[2];
|
117
|
Payment[] payments = new Payment[2];
|
113
|
Payment paypal = new PayPayl(4L, "Tamara Mowry", "tamara@mowry.com");
|
118
|
Payment paypal = new PayPayl(4L, "Tamara Mowry", "tamara@mowry.com");
|
|
|
|
|
121
|
String actual = presenter.toString(payments);
|
126
|
String actual = presenter.toString(payments);
|
122
|
assertEquals(expected, actual);
|
127
|
assertEquals(expected, actual);
|
123
|
```
|
128
|
```
|
|
|
129
|
+
|
124
|
4. Create a test case to test the `toStringById` method of the PaymentPresenter class
|
130
|
4. Create a test case to test the `toStringById` method of the PaymentPresenter class
|
125
|
- When there are multiple payments, you need to sort by creating a lambda to sort the payment by id, then build the string using the short description
|
131
|
- When there are multiple payments, you need to sort by creating a lambda to sort the payment by id, then build the string using the short description
|
|
|
132
|
+
|
126
|
```
|
133
|
```
|
127
|
Payment[] payments = new Payment[2];
|
134
|
Payment[] payments = new Payment[2];
|
128
|
Payment paypal = new PayPayl(120L, "Tamara Mowry", "tamara@mowry.com");
|
135
|
Payment paypal = new PayPayl(120L, "Tamara Mowry", "tamara@mowry.com");
|