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