added new fields to TransferDetails
This commit is contained in:
@@ -7,20 +7,29 @@ case class TransferDetails(fromAccountId : EntityIdentifier, toAccountId : Entit
|
||||
import net.chrisrichardson.eventstore.EntityIdentifier;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class TransferDetails {
|
||||
|
||||
private EntityIdentifier fromAccountId;
|
||||
private EntityIdentifier toAccountId;
|
||||
private BigDecimal amount;
|
||||
private Date date;
|
||||
private String description;
|
||||
|
||||
private TransferDetails() {
|
||||
}
|
||||
|
||||
public TransferDetails(EntityIdentifier fromAccountId, EntityIdentifier toAccountId, BigDecimal amount) {
|
||||
this(fromAccountId, toAccountId, amount, new Date(), "");
|
||||
}
|
||||
|
||||
public TransferDetails(EntityIdentifier fromAccountId, EntityIdentifier toAccountId, BigDecimal amount, Date date, String description) {
|
||||
this.fromAccountId = fromAccountId;
|
||||
this.toAccountId = toAccountId;
|
||||
this.amount = amount;
|
||||
this.date = date;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public EntityIdentifier getFromAccountId() {
|
||||
@@ -34,4 +43,12 @@ public class TransferDetails {
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class EndToEndTest {
|
||||
transactionsCommandSideBaseUrl("/transfers"),
|
||||
HttpMethod.POST,
|
||||
CreateMoneyTransferResponse.class,
|
||||
new CreateMoneyTransferRequest(fromAccountId, toAccountId, amountToTransfer)
|
||||
new CreateMoneyTransferRequest(fromAccountId, toAccountId, amountToTransfer, "")
|
||||
);
|
||||
|
||||
assertAccountBalance(fromAccountId, finalFromAccountBalance);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class BankingWebIntegrationTest {
|
||||
baseUrl("/transfers"),
|
||||
HttpMethod.POST,
|
||||
CreateMoneyTransferResponse.class,
|
||||
new CreateMoneyTransferRequest(fromAccountId, toAccountId, amountToTransfer)
|
||||
new CreateMoneyTransferRequest(fromAccountId, toAccountId, amountToTransfer, "")
|
||||
);
|
||||
|
||||
assertAccountBalance(fromAccountId, finalFromAccountBalance);
|
||||
|
||||
@@ -15,13 +15,16 @@ public class CreateMoneyTransferRequest {
|
||||
@DecimalMin("0.01")
|
||||
private BigDecimal amount;
|
||||
|
||||
private String description;
|
||||
|
||||
public CreateMoneyTransferRequest() {
|
||||
}
|
||||
|
||||
public CreateMoneyTransferRequest(String fromAccountId, String toAccountId, BigDecimal amount) {
|
||||
public CreateMoneyTransferRequest(String fromAccountId, String toAccountId, BigDecimal amount, String description) {
|
||||
this.fromAccountId = fromAccountId;
|
||||
this.toAccountId = toAccountId;
|
||||
this.amount = amount;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setFromAccountId(String fromAccountId) {
|
||||
@@ -36,6 +39,10 @@ public class CreateMoneyTransferRequest {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFromAccountId() {
|
||||
return fromAccountId;
|
||||
}
|
||||
@@ -47,4 +54,8 @@ public class CreateMoneyTransferRequest {
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import rx.Observable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/transfers")
|
||||
public class MoneyTransferController {
|
||||
@@ -27,7 +29,9 @@ public class MoneyTransferController {
|
||||
TransferDetails transferDetails = new TransferDetails(
|
||||
new EntityIdentifier(request.getFromAccountId()),
|
||||
new EntityIdentifier(request.getToAccountId()),
|
||||
request.getAmount());
|
||||
request.getAmount(),
|
||||
new Date(),
|
||||
request.getDescription());
|
||||
return moneyTransferService.transferMoney(transferDetails)
|
||||
.map(entityAndEventInfo -> new CreateMoneyTransferResponse(entityAndEventInfo.getEntityIdentifier().getId()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user