It is only left a test for addWithdrawal
authorGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 17:31:12 +0000 (18:31 +0100)
committerGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 4 Dec 2016 17:31:12 +0000 (18:31 +0100)
TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/Transaction.java
TDD/sandromancuso/bank/src/main/java/org/craftedsw/feature/TransactionRepository.java

index 2786699..8ae726c 100644 (file)
@@ -2,8 +2,39 @@ package org.craftedsw.feature;
 
 public class Transaction {
 
+       private final String date;
+       private final int amount;
+
        public Transaction(String date, int amount) {
-               throw new UnsupportedOperationException();
+               this.date = date;
+               this.amount = amount;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + amount;
+               result = prime * result + ((date == null) ? 0 : date.hashCode());
+               return result;
        }
 
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               Transaction other = (Transaction) obj;
+               if (amount != other.amount)
+                       return false;
+               if (date == null) {
+                       if (other.date != null)
+                               return false;
+               } else if (!date.equals(other.date))
+                       return false;
+               return true;
+       }
 }
index 4c5d20a..d1d07bc 100644 (file)
@@ -1,6 +1,7 @@
 package org.craftedsw.feature;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 public class TransactionRepository {
@@ -22,7 +23,7 @@ public class TransactionRepository {
        }
 
        public List<Transaction> allTransactions() {
-               throw new UnsupportedOperationException();
+               return Collections.unmodifiableList(transactions);
        }
 
 }