Nick Satinover il y a 6 ans
Parent
révision
82774e3030

+ 2
- 2
Checkbook/src/main/java/Transaction.java Voir le fichier

@@ -3,7 +3,7 @@ import java.util.concurrent.atomic.AtomicReference;
3 3
 
4 4
 public class Transaction implements AccountBook{
5 5
     private final AtomicReference<Integer> id = new AtomicReference<Integer>();
6
-    private final AtomicReference<LocalDate> date = new AtomicReference<LocalDate>();
6
+    private final AtomicReference<LocalDate> date = new AtomicReference<>(LocalDate.now());
7 7
     private String memo;
8 8
     private Payee payee;
9 9
     private TransactionType typee; // Credit (reduces the checkbook), Debit (increases the checkbook)
@@ -21,7 +21,7 @@ public class Transaction implements AccountBook{
21 21
     }
22 22
 
23 23
     public LocalDate getDate() {
24
-        return date.get();
24
+        return (LocalDate)date.get();
25 25
     }
26 26
 
27 27
     public TransactionType getType() {

+ 28
- 8
Checkbook/src/test/java/CheckbookTest.java Voir le fichier

@@ -21,6 +21,8 @@ public class CheckbookTest {
21 21
     public void setUp() throws Exception {
22 22
         this.owner = new Payee();
23 23
              owner.setGivenName("Nick Satinover");
24
+             owner.setFamilyName("Simpsons");
25
+             owner.setEmailAddress("nsatinover@gmail.com");
24 26
         this.payeeCredit = new Payee();
25 27
              payeeCredit.setGivenName("Credit Payee");
26 28
         this.payeeDebit = new Payee();
@@ -235,14 +237,32 @@ public class CheckbookTest {
235 237
         Assert.assertEquals(expected, actual);
236 238
     }
237 239
 
238
-//    @Test
239
-//    public void test1GetTransactionsForDate(){
240
-//        checkbook.add(credit);
241
-//        checkbook.add(debit);
242
-//        Transaction[] retarr = checkbook.getTransactionsForDate(LocalDate.now());
243
-//        Transaction expected = credit;
244
-//        Assert.assertEquals(expected, retarr[1]);
245
-//    }
240
+    @Test
241
+    public void test1GetTransactionsForDate(){
242
+        checkbook.add(credit);
243
+        checkbook.add(debit);
244
+        Transaction[] retarr = checkbook.getTransactionsForDate(LocalDate.now());
245
+        Transaction expected = credit;
246
+        Assert.assertEquals(expected, retarr[0]);
247
+    }
248
+
249
+    @Test
250
+    public void test2GetTransactionsForDate(){
251
+        checkbook.add(credit);
252
+        checkbook.add(debit);
253
+        Transaction[] retarr = checkbook.getTransactionsForDate(LocalDate.now());
254
+        Transaction expected = debit;
255
+        Assert.assertEquals(expected, retarr[1]);
256
+    }
257
+
258
+    @Test
259
+    public void test3GetTransactionsForDate(){
260
+        checkbook.add(debit);
261
+        Transaction[] retarr = checkbook.getTransactionsForDate(LocalDate.now());
262
+        LocalDate expected = debit.getDate();
263
+        LocalDate actual = retarr[0].getDate(); // LocalDate.of(2018, 12, 8);
264
+        Assert.assertEquals(expected, actual);
265
+    }
246 266
 
247 267
     @Test
248 268
     public void test1GetAllTransactionsForPayee(){