Permalink
Browse files

Renaming some of the portfolio related classes

  • Loading branch information...
1 parent 883f119 commit 63aac8bc7e18ae75eac98140bc7f5db5157de37c @jettro jettro committed Nov 11, 2011
@@ -18,13 +18,15 @@
import org.axonframework.domain.AggregateIdentifier;
/**
+ * Adding money to your Portfolio through a deposit
+ *
* @author Jettro Coenradie
*/
-public class AddMoneyToPortfolioCommand {
+public class DepositMoneyToPortfolioCommand {
private AggregateIdentifier portfolioIdentifier;
private long moneyToAddInCents;
- public AddMoneyToPortfolioCommand(AggregateIdentifier portfolioIdentifier, long moneyToAddInCents) {
+ public DepositMoneyToPortfolioCommand(AggregateIdentifier portfolioIdentifier, long moneyToAddInCents) {
this.portfolioIdentifier = portfolioIdentifier;
this.moneyToAddInCents = moneyToAddInCents;
}
@@ -21,10 +21,10 @@
/**
* @author Jettro Coenradie
*/
-public class MoneyAddedToPortfolioEvent extends DomainEvent {
+public class MoneyDepositedToPortfolioEvent extends DomainEvent {
private long moneyAddedInCents;
- public MoneyAddedToPortfolioEvent(long moneyAddedInCents) {
+ public MoneyDepositedToPortfolioEvent(long moneyAddedInCents) {
this.moneyAddedInCents = moneyAddedInCents;
}
@@ -21,10 +21,10 @@
/**
* @author Jettro Coenradie
*/
-public class PaymentMadeFromPortfolioEvent extends DomainEvent {
+public class MoneyWithdrawnFromPortfolioEvent extends DomainEvent {
private long amountPaidInCents;
- public PaymentMadeFromPortfolioEvent(long amountPaidInCents) {
+ public MoneyWithdrawnFromPortfolioEvent(long amountPaidInCents) {
this.amountPaidInCents = amountPaidInCents;
}
@@ -20,11 +20,11 @@
/**
* @author Jettro Coenradie
*/
-public class MakePaymentFromPortfolioCommand {
+public class WithdrawMoneyFromPortfolioCommand {
private AggregateIdentifier portfolioIdentifier;
private long amountToPayInCents;
- public MakePaymentFromPortfolioCommand(AggregateIdentifier portfolioIdentifier, long amountToPayInCents) {
+ public WithdrawMoneyFromPortfolioCommand(AggregateIdentifier portfolioIdentifier, long amountToPayInCents) {
this.portfolioIdentifier = portfolioIdentifier;
this.amountToPayInCents = amountToPayInCents;
@@ -77,11 +77,11 @@ public void cancelReservation(AggregateIdentifier itemIdentifier, int amountOfIt
}
public void addMoney(long moneyToAddInCents) {
- apply(new MoneyAddedToPortfolioEvent(moneyToAddInCents));
+ apply(new MoneyDepositedToPortfolioEvent(moneyToAddInCents));
}
public void makePayment(long amountToPayInCents) {
- apply(new PaymentMadeFromPortfolioEvent(amountToPayInCents));
+ apply(new MoneyWithdrawnFromPortfolioEvent(amountToPayInCents));
}
public void reserveMoney(long amountToReserve) {
@@ -147,12 +147,12 @@ public void onReservationCancelled(ItemReservationCancelledForPortfolioEvent eve
}
@EventHandler
- public void onMoneyAddedToPortfolio(MoneyAddedToPortfolioEvent event) {
+ public void onMoneyAddedToPortfolio(MoneyDepositedToPortfolioEvent event) {
amountOfMoney += event.getMoneyAddedInCents();
}
@EventHandler
- public void onPaymentMadeFromPortfolio(PaymentMadeFromPortfolioEvent event) {
+ public void onPaymentMadeFromPortfolio(MoneyWithdrawnFromPortfolioEvent event) {
amountOfMoney -= event.getAmountPaidInCents();
}
@@ -67,13 +67,13 @@ public void handleCancelReservationCommand(CancelItemReservationForPortfolioComm
}
@CommandHandler
- public void handleAddMoneyToPortfolioCommand(AddMoneyToPortfolioCommand command) {
+ public void handleAddMoneyToPortfolioCommand(DepositMoneyToPortfolioCommand command) {
Portfolio portfolio = portfolioRepository.load(command.getPortfolioIdentifier());
portfolio.addMoney(command.getMoneyToAddInCents());
}
@CommandHandler
- public void handleMakePaymentFromPortfolioCommand(MakePaymentFromPortfolioCommand command) {
+ public void handleMakePaymentFromPortfolioCommand(WithdrawMoneyFromPortfolioCommand command) {
Portfolio portfolio = portfolioRepository.load(command.getPortfolioIdentifier());
portfolio.makePayment(command.getAmountToPayInCents());
}
@@ -17,9 +17,9 @@
import org.axonframework.eventhandling.annotation.EventHandler;
import org.axonframework.samples.trader.app.api.portfolio.PortfolioCreatedEvent;
-import org.axonframework.samples.trader.app.api.portfolio.money.MoneyAddedToPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.money.MoneyDepositedToPortfolioEvent;
import org.axonframework.samples.trader.app.api.portfolio.money.MoneyReservedFromPortfolioEvent;
-import org.axonframework.samples.trader.app.api.portfolio.money.PaymentMadeFromPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.money.MoneyWithdrawnFromPortfolioEvent;
import org.axonframework.samples.trader.app.query.portfolio.repositories.PortfolioQueryRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,14 +50,14 @@ public void handleEvent(PortfolioCreatedEvent event) {
}
@EventHandler
- public void handleEvent(MoneyAddedToPortfolioEvent event) {
+ public void handleEvent(MoneyDepositedToPortfolioEvent event) {
PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
portfolioEntry.setAmountOfMoney(portfolioEntry.getAmountOfMoney() + event.getMoneyAddedInCents());
portfolioRepository.save(portfolioEntry);
}
@EventHandler
- public void handleEvent(PaymentMadeFromPortfolioEvent event) {
+ public void handleEvent(MoneyWithdrawnFromPortfolioEvent event) {
PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
portfolioEntry.setAmountOfMoney(portfolioEntry.getAmountOfMoney() - event.getAmountPaidInCents());
portfolioRepository.save(portfolioEntry);
@@ -126,38 +126,38 @@ public void testCancellationOfReservation() {
/* Money related test methods */
@Test
- public void testAddingMoneyToThePortfolio() {
+ public void testDepositingMoneyToThePortfolio() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
- AddMoneyToPortfolioCommand command = new AddMoneyToPortfolioCommand(portfolioIdentifier, 2000l);
+ DepositMoneyToPortfolioCommand command = new DepositMoneyToPortfolioCommand(portfolioIdentifier, 2000l);
fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()))
.when(command)
- .expectEvents(new MoneyAddedToPortfolioEvent(2000l));
+ .expectEvents(new MoneyDepositedToPortfolioEvent(2000l));
}
@Test
- public void testMakingPaymentFromPortfolio() {
+ public void testWithdrawingMoneyFromPortfolio() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
- MakePaymentFromPortfolioCommand command = new MakePaymentFromPortfolioCommand(portfolioIdentifier, 300l);
- fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyAddedToPortfolioEvent(400))
+ WithdrawMoneyFromPortfolioCommand command = new WithdrawMoneyFromPortfolioCommand(portfolioIdentifier, 300l);
+ fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyDepositedToPortfolioEvent(400))
.when(command)
- .expectEvents(new PaymentMadeFromPortfolioEvent(300l));
+ .expectEvents(new MoneyWithdrawnFromPortfolioEvent(300l));
}
@Test
- public void testMakingPaymentFromPortfolio_withoutEnoughMoney() {
+ public void testWithdrawingMoneyFromPortfolio_withoutEnoughMoney() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
- MakePaymentFromPortfolioCommand command = new MakePaymentFromPortfolioCommand(portfolioIdentifier, 300l);
- fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyAddedToPortfolioEvent(200))
+ WithdrawMoneyFromPortfolioCommand command = new WithdrawMoneyFromPortfolioCommand(portfolioIdentifier, 300l);
+ fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyDepositedToPortfolioEvent(200))
.when(command)
- .expectEvents(new PaymentMadeFromPortfolioEvent(300l));
+ .expectEvents(new MoneyWithdrawnFromPortfolioEvent(300l));
}
@Test
public void testMakingMoneyReservation() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
ReserveMoneyFromPortfolioCommand command = new ReserveMoneyFromPortfolioCommand(portfolioIdentifier, 300l);
- fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyAddedToPortfolioEvent(400))
+ fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyDepositedToPortfolioEvent(400))
.when(command)
.expectEvents(new MoneyReservedFromPortfolioEvent(300l));
}
@@ -166,7 +166,7 @@ public void testMakingMoneyReservation() {
public void testMakingMoneyReservation_withoutEnoughMoney() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
ReserveMoneyFromPortfolioCommand command = new ReserveMoneyFromPortfolioCommand(portfolioIdentifier, 600l);
- fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyAddedToPortfolioEvent(400))
+ fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyDepositedToPortfolioEvent(400))
.when(command)
.expectEvents(new NotEnoughMoneyInPortfolioToMakeReservationEvent(600));
}
@@ -175,7 +175,7 @@ public void testMakingMoneyReservation_withoutEnoughMoney() {
public void testCancelMoneyReservation() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
CancelMoneyReservationFromPortfolioCommand command = new CancelMoneyReservationFromPortfolioCommand(portfolioIdentifier, 200l);
- fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyAddedToPortfolioEvent(400))
+ fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyDepositedToPortfolioEvent(400))
.when(command)
.expectEvents(new MoneyReservationCancelledFromPortfolioEvent(200l));
}
@@ -184,7 +184,7 @@ public void testCancelMoneyReservation() {
public void testConfirmMoneyReservation() {
AggregateIdentifier portfolioIdentifier = fixture.getAggregateIdentifier();
ConfirmMoneyReservationFromPortfolionCommand command = new ConfirmMoneyReservationFromPortfolionCommand(portfolioIdentifier, 200l);
- fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyAddedToPortfolioEvent(400))
+ fixture.given(new PortfolioCreatedEvent(new UUIDAggregateIdentifier()), new MoneyDepositedToPortfolioEvent(400))
.when(command)
.expectEvents(new MoneyReservationConfirmedFromPortfolioEvent(200l));
}
@@ -24,7 +24,7 @@
import org.axonframework.eventstore.mongo.MongoEventStore;
import org.axonframework.samples.trader.app.api.company.CreateCompanyCommand;
import org.axonframework.samples.trader.app.api.order.CreateOrderBookCommand;
-import org.axonframework.samples.trader.app.api.portfolio.money.AddMoneyToPortfolioCommand;
+import org.axonframework.samples.trader.app.api.portfolio.money.DepositMoneyToPortfolioCommand;
import org.axonframework.samples.trader.app.api.user.CreateUserCommand;
import org.axonframework.samples.trader.app.query.company.CompanyEntry;
import org.axonframework.samples.trader.app.query.company.repositories.CompanyQueryRepository;
@@ -97,8 +97,8 @@ public void createItems() {
}
public void addMoneyToPortfolio(String portfolioIdentifier, long amountOfMoney) {
- AddMoneyToPortfolioCommand command =
- new AddMoneyToPortfolioCommand(new UUIDAggregateIdentifier(portfolioIdentifier), amountOfMoney);
+ DepositMoneyToPortfolioCommand command =
+ new DepositMoneyToPortfolioCommand(new UUIDAggregateIdentifier(portfolioIdentifier), amountOfMoney);
commandBus.dispatch(command);
}

0 comments on commit 63aac8b

Please sign in to comment.