Permalink
Browse files

Inner loop - Blue: Improve repository test readability

  • Loading branch information...
CarlosMChica committed May 2, 2016
1 parent 6b0bf42 commit f999927fe0ca18b16baeae874925e7df20b9782d
@@ -1,6 +1,8 @@
package me.panavtec.androidbankkata.account.transaction;
import java.util.Date;
+import java.util.List;
+import org.hamcrest.Matcher;
import org.junit.Test;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
@@ -9,12 +11,19 @@
public class TransactionRepositoryShouldShould {
@Test public void store_transactions() {
- TransactionRepository repository = new TransactionRepository();
- Deposit deposit = new Deposit(anAmount(), aDate());
+ TransactionRepository repository = givenTransactionRepository();
- repository.store(deposit);
+ repository.store(aTransaction());
- assertThat(repository.transactions(), hasItem(deposit));
+ assertThat(transactionsOf(repository), has(aTransaction()));
+ }
+
+ private List<Transaction> transactionsOf(TransactionRepository repository) {
+ return repository.transactions();
+ }
+
+ private Transaction aTransaction() {
+ return new Deposit(anAmount(), aDate());
}
private Date aDate() {
@@ -24,4 +33,12 @@ private Date aDate() {
private int anAmount() {
return 0;
}
+
+ private Matcher<Iterable<? super Transaction>> has(Transaction transaction) {
+ return hasItem(transaction);
+ }
+
+ private TransactionRepository givenTransactionRepository() {
+ return new TransactionRepository();
+ }
}

0 comments on commit f999927

Please sign in to comment.