Last active
June 30, 2024 13:42
-
-
Save trikitrok/8f7b7386baee3a92a979f0a3e503ad88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package bank.tests.integration; | |
| // some ommited imports... | |
| public class InMemoryTransactionsRepositoryTest { | |
| private TransactionsRepository repository; | |
| private List<Transaction> initialTransactions; | |
| @Before | |
| public void setup() throws ParseException { | |
| repository = new InMemoryTransactionsRepository(); | |
| initialTransactions = Arrays.asList( | |
| aTransaction().withDeposit(100).on("10/10/2021").build(), | |
| aTransaction().withWithdrawal(50).on("15/10/2021").build()); | |
| prepareData(initialTransactions); | |
| } | |
| @Test | |
| public void a_transaction_can_be_saved() throws ParseException { | |
| Transaction transaction = aTransaction().withDeposit(500).on("25/10/2021").build(); | |
| repository.save(transaction); | |
| assertThat(repository.retrieveAll(), is(addTo(initialTransactions, transaction))); | |
| } | |
| @Test | |
| public void transactions_can_be_retrieved() { | |
| assertThat(repository.retrieveAll(), is(initialTransactions)); | |
| } | |
| private void prepareData(List<Transaction> transactions) { | |
| for (Transaction transaction : transactions) { | |
| repository.save(transaction); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment