Commit e95fe430 authored by Berk Yavuz's avatar Berk Yavuz
Browse files

setup solution readme fix

parent f52c052d
No related merge requests found
Showing with 746 additions and 91 deletions
+746 -91
.gitignore 0 → 100644
.settings
.project
.history
.classpath
target
.DS_Store
.flattened-pom.xml
.gradle
bin
build
/target
\ No newline at end of file
......@@ -25,18 +25,6 @@ The main idea of mock is splitting test method into three parts: setting, execut
2. To use Mockito framework, open `pom.xml` file and add following code inside the dependicies.
```xml
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.10.0</version>
<scope>test</scope>
</dependency>
```
3. Open `pom.xml` file and change the version of mockito to 2.23.4
```xml
<dependency>
<groupId>org.mockito</groupId>
......@@ -46,109 +34,154 @@ The main idea of mock is splitting test method into three parts: setting, execut
</dependency>
```
4. After theese you will have a project structre like that
3. After theese you will have a project structre like that
```
├───.settings
├───src
│ ├───main
│ │ ├───java
│ │ │ └───com
│ │ │ └───eteration
│ │ │ └───banking
│ │ │ ├───exception
│ │ │ ├───model
│ │ │ └───util
│ │ ├───resources
│ │ └───webapp
│ │ └───WEB-INF
│ └───test
│ ├───java
│ │ └───com
│ │ └───eteration
│ │ └───banking
│ │ └───tests
│ └───resources
└───target
├───classes
│ └───com
│ └───eteration
│ └───banking
│ ├───exception
│ ├───model
│ └───util
├───m2e-wtp
│ └───web-resources
│ └───META-INF
│ └───maven
│ └───banking.app
│ └───banking
└───test-classes
└───com
└───eteration
└───banking
└───tests
.
├── _classpath.xml
├── pom.xml
├── _project.xml
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │   └── eteration
│   │   │   └── banking
│   │   │   ├── exception
│   │   │   │   └── InsufficientBalanceException.java
│   │   │   ├── model
│   │   │   │   ├── Account.java
│   │   │   │   ├── DepositTransaction.java
│   │   │   │   ├── Transaction.java
│   │   │   │   └── WithdrawalTransaction.java
│   │   │   └── util
│   │   │   └── DateUtil.java
│   │   └── webapp
│   │   └── WEB-INF
│   │   └── web.xml
│   └── test
│   └── java
│   └── com
│   └── eteration
│   └── banking
│   └── tests
│   └── TestBankAccount.java
└── target
├── classes
│   └── com
│   └── eteration
│   └── banking
│   ├── exception
│   │   └── InsufficientBalanceException.class
│   ├── model
│   │   ├── Account.class
│   │   ├── DepositTransaction.class
│   │   ├── Transaction.class
│   │   └── WithdrawalTransaction.class
│   └── util
│   └── DateUtil.class
├── m2e-wtp
│   └── web-resources
│   └── META-INF
│   ├── MANIFEST.MF
│   └── maven
│   └── banking.app
│   └── banking
│   ├── pom.properties
│   └── pom.xml
└── test-classes
└── com
└── eteration
└── banking
└── tests
└── TestBankAccount.class
```
5. According to Test Driven Development approach, we will write a test first. We create an account with a 1000 balance in type of TL and then convert this balance to `USD` and `EURO`. Here is the required method:
4. The balance should be changed to other curreny units. Because of that, we will need class of DAO. Lets create `CurrencyDAO` interface inside `com.eteration.banking.dao` package.
```java
public interface CurrencyDAO {
public double getTLRate(String currencyCode);
}
```
@Test
public void testCurrencyConverter() {
Account account = new Account("Canan","1234");
CurrencyDAO mockedCurrencyDAO = mock(CurrencyDAO.class);
account.post(new DepositTransaction(1000));
when(mockedCurrencyDAO.getTLRate("USD")).thenReturn(5.34);
when(mockedCurrencyDAO.getTLRate("EUR")).thenReturn(6.06);
account.setCurrencyDAO(mockedCurrencyDAO);
assertEquals(187.26,account.convertBalance("USD"),0);;
assertEquals(165.01,account.convertBalance("EUR"),0);
verify(mockedCurrencyDAO).getTLRate("EUR");
verify(mockedCurrencyDAO).getTLRate("USD");
5. Add the "CurrencyDAO" dependency to the "Account" class.
```java
private CurrencyDAO currencyDAO;
public CurrencyDAO getCurrencyDAO() {
return currencyDAO;
}
public void setCurrencyDAO(CurrencyDAO currencyDAO) {
this.currencyDAO = currencyDAO;
}
```
6. Add the method to convert the balance amount to other currencies in the "Account" class.
```java
public double convertBalance(String currencyCode){
double rate=getCurrencyDAO().getTLRate(currencyCode);
return (int)(getBalance()/rate*100)/100.0;
}
```
If we want to test this method, test will fail. Because we do not create an interface and its necessaries methods yet. So now we will create an interface and implement it onto Account.java under `src\main\java\com\eteration\banking\model`
7. Add static import to `TestBankAccount.java`.
6. Add a new CurrencyDAO folder under the `src/main/java/com/eteration/banking` and create CurrencyDAO interface into it.Here is the CurrencyDAO:
``` java
import static org.mockito.Mockito.*;
```
```java
package com.eteration.banking.dao;
8. Create an account with has a balance equals of 1000.
public interface CurrencyDAO {
public double getTLRate(String currencyCode);
}
```java
Account account = new Account("Canan","1234");
CurrencyDAO mockedCurrencyDAO = mock(CurrencyDAO.class);
account.post(new DepositTransaction(1000));
```
>After adding interface we have to do some changes on the Account.java under `src/main/java/com/eteration/banking/model`.
9. Let's record Mock Object.
>Firstly declare `currencyDAO` and to use it add getter and setter methods.
```java
private CurrencyDAO currencyDAO;
```java
when(mockedCurrencyDAO.getTLRate("USD")).thenReturn(5.34);
when(mockedCurrencyDAO.getTLRate("EUR")).thenReturn(6.06);
account.setCurrencyDAO(mockedCurrencyDAO);
```
10. Add the assertions and be sure about the `CurrenyDAO` is called twice.
public CurrencyDAO getCurrencyDAO() {
return currencyDAO;
}
public void setCurrencyDAO(CurrencyDAO currencyDAO) {
this.currencyDAO = currencyDAO;
}
```java
assertEquals(187.26,account.convertBalance("USD"));;
assertEquals(165.01,account.convertBalance("EUR"));
verify(mockedCurrencyDAO).getTLRate("EUR");
verify(mockedCurrencyDAO).getTLRate("USD");
```
>Before testing step we have to add one more methods to convert its balance to the intended currency.
11. After theese steps, the method should like below
```java
public double convertBalance(String currencyCode){
double rate=getCurrencyDAO().getTLRate(currencyCode);
return (int)(getBalance()/rate*100)/100.0;
@Test
public void testCurrencyConverter() {
Account account = new Account("Canan","1234");
CurrencyDAO mockedCurrencyDAO = mock(CurrencyDAO.class);
account.post(new DepositTransaction(1000));
when(mockedCurrencyDAO.getTLRate("USD")).thenReturn(5.34);
when(mockedCurrencyDAO.getTLRate("EUR")).thenReturn(6.06);
account.setCurrencyDAO(mockedCurrencyDAO);
assertEquals(187.26,account.convertBalance("USD"),0);;
assertEquals(165.01,account.convertBalance("EUR"),0);
verify(mockedCurrencyDAO).getTLRate("EUR");
verify(mockedCurrencyDAO).getTLRate("USD");
}
```
7. If we run the test now, test will pass successfully
12. If we run the test now, test will pass successfully
![Test-result](img/TestResult.png)
![Test-result](img/TestResult.jpg)
8. In the `solution` folder, there is complete project includes several unit tests similar to test we created. To exercise you can check if all the tests work. If some of these tests fails, write the required functions as stated by Test Driven Development method.
\ No newline at end of file
---
\ No newline at end of file
img/testResult.jpg

28.6 KB

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>banking</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>banking.app</groupId>
<artifactId>banking</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.eteration.banking.exception;
public class InsufficientBalanceException extends Exception{
public InsufficientBalanceException() {
super();
}
public InsufficientBalanceException(String message) {
super(message);
}
}
package com.eteration.banking.model;
import java.util.ArrayList;
import java.util.List;
import com.eteration.banking.exception.InsufficientBalanceException;
import com.eteration.banking.util.DateUtil;
public class Account {
private String accountNumber;
private String owner;
private double balance;
private String createDate;
private List<Transaction> transactions = new ArrayList<>();
public Account(String owner, String accountNumber) {
this.owner=owner;
this.accountNumber=accountNumber;
this.createDate=DateUtil.getSysdateAsStr();
}
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public void deposit(double amount) {
setBalance(getBalance()+amount);
}
public void withdraw(double amount) throws InsufficientBalanceException {
if(amount>getBalance())
throw new InsufficientBalanceException("Your balance is not enough");
setBalance(getBalance()-amount);
}
public List<Transaction> getTransactions() {
return transactions;
}
public void setTransactions(List<Transaction> transactions) {
this.transactions = transactions;
}
public void post(Transaction trx) throws InsufficientBalanceException {
trx.update(this);
this.getTransactions().add(trx);
}
public void post(DepositTransaction depositTrx) {
this.deposit(depositTrx.getAmount());
this.getTransactions().add(depositTrx);
}
public void post(WithdrawalTransaction withdrawalTrx) throws InsufficientBalanceException {
this.withdraw(withdrawalTrx.getAmount());
this.getTransactions().add(withdrawalTrx);
}
}
package com.eteration.banking.model;
public class DepositTransaction extends Transaction {
public DepositTransaction(double amount) {
super(amount);
}
public void update(Account account) {
account.deposit(this.getAmount());
}
}
package com.eteration.banking.model;
import java.util.Date;
import com.eteration.banking.exception.InsufficientBalanceException;
public abstract class Transaction {
private Date date;
private double amount;
public abstract void update(Account account) throws InsufficientBalanceException;
public Transaction(double amount) {
this.date=new Date();
this.setAmount(amount);
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
}
package com.eteration.banking.model;
import com.eteration.banking.exception.InsufficientBalanceException;
public class WithdrawalTransaction extends Transaction {
public WithdrawalTransaction(double amount) {
super(amount);
}
public void update(Account account) throws InsufficientBalanceException {
account.withdraw(this.getAmount());
}
}
package com.eteration.banking.util;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil {
public static String getSysdateAsStr() {
SimpleDateFormat df=new SimpleDateFormat("dd.MM.yyyy");
return df.format(new Date());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>banking</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
\ No newline at end of file
package com.eteration.banking.tests;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.eteration.banking.exception.InsufficientBalanceException;
import com.eteration.banking.model.Account;
import com.eteration.banking.model.DepositTransaction;
import com.eteration.banking.model.WithdrawalTransaction;
import com.eteration.banking.util.DateUtil;
public class TestBankAccount {
@Test
public void testCreateAccountAndSetBalance0() {
Account account = new Account("Kerem Karaca", "17892");
assertTrue(account.getOwner().equals("Kerem Karaca"));
assertTrue(account.getAccountNumber().equals("17892"));
assertTrue(account.getBalance() == 0);
}
@Test
public void testSettingCreateDateWhenAccountCreated() {
Account account = new Account("Demet Demircan", "9834");
String sysdateAsStr = DateUtil.getSysdateAsStr();
assertTrue(account.getCreateDate().equals(sysdateAsStr));
}
@Test
public void testDepositIntoBankAccount() {
Account account = new Account("Demet Demircan", "9834");
account.deposit(100);
assertTrue(account.getBalance() == 100);
}
@Test
public void testWithdrawFromBankAccount() throws InsufficientBalanceException {
Account account = new Account("Demet Demircan", "9834");
account.deposit(100);
assertTrue(account.getBalance() == 100);
account.withdraw(50);
assertTrue(account.getBalance() == 50);
}
@Test
public void testWithdrawException() throws InsufficientBalanceException {
Assertions.assertThrows(InsufficientBalanceException.class, () -> {
Account account = new Account("Demet Demircan", "9834");
account.deposit(100);
account.withdraw(500);
});
}
@Test
public void testTransactions() throws InsufficientBalanceException {
// Create account
Account account = new Account("Canan Kaya", "1234");
assertTrue(account.getTransactions().size() == 0);
// Deposit Transaction
DepositTransaction depositTrx = new DepositTransaction(100);
assertTrue(depositTrx.getDate() != null);
account.post(depositTrx);
assertTrue(account.getBalance() == 100);
assertTrue(account.getTransactions().size() == 1);
// Withdrawal Transaction
WithdrawalTransaction withdrawalTrx = new WithdrawalTransaction(60);
assertTrue(withdrawalTrx.getDate() != null);
account.post(withdrawalTrx);
assertTrue(account.getBalance() == 40);
assertTrue(account.getTransactions().size() == 2);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>banking</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>banking.app</groupId>
<artifactId>banking</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.eteration.banking.dao;
public interface CurrencyDAO {
public double getTLRate(String currencyCode);
}
package com.eteration.banking.exception;
public class InsufficientBalanceException extends Exception{
public InsufficientBalanceException() {
super();
}
public InsufficientBalanceException(String message) {
super(message);
}
}
package com.eteration.banking.model;
import java.util.ArrayList;
import java.util.List;
import com.eteration.banking.dao.CurrencyDAO;
import com.eteration.banking.exception.InsufficientBalanceException;
import com.eteration.banking.util.DateUtil;
public class Account {
private String accountNumber;
private String owner;
private double balance;
private String createDate;
private List<Transaction> transactions = new ArrayList<>();
private CurrencyDAO currencyDAO;
public Account(String owner, String accountNumber) {
this.owner = owner;
this.accountNumber = accountNumber;
this.createDate = DateUtil.getSysdateAsStr();
}
public double convertBalance(String currencyCode) {
double rate = getCurrencyDAO().getTLRate(currencyCode);
return (int) (getBalance() / rate * 100) / 100.0;
}
public CurrencyDAO getCurrencyDAO() {
return currencyDAO;
}
public void setCurrencyDAO(CurrencyDAO currencyDAO) {
this.currencyDAO = currencyDAO;
}
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public void deposit(double amount) {
setBalance(getBalance() + amount);
}
public void withdraw(double amount) throws InsufficientBalanceException {
if (amount > getBalance())
throw new InsufficientBalanceException("Your balance is not enough");
setBalance(getBalance() - amount);
}
public List<Transaction> getTransactions() {
return transactions;
}
public void setTransactions(List<Transaction> transactions) {
this.transactions = transactions;
}
public void post(Transaction trx) throws InsufficientBalanceException {
trx.update(this);
this.getTransactions().add(trx);
}
public void post(DepositTransaction depositTrx) {
this.deposit(depositTrx.getAmount());
this.getTransactions().add(depositTrx);
}
public void post(WithdrawalTransaction withdrawalTrx) throws InsufficientBalanceException {
this.withdraw(withdrawalTrx.getAmount());
this.getTransactions().add(withdrawalTrx);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment