Browse files

Added the Portfolio listeners for the query side to the code base

  • Loading branch information...
1 parent 63aac8b commit 28030178876ae8fd447efed2c5feae760cd2a3f6 @jettro jettro committed Nov 15, 2011
View
6 app/src/main/java/org/axonframework/samples/trader/app/query/orderbook/OrderBookEntry.java
@@ -43,23 +43,23 @@ public String getIdentifier() {
return identifier;
}
- void setIdentifier(String identifier) {
+ public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getCompanyIdentifier() {
return companyIdentifier;
}
- void setCompanyIdentifier(String companyIdentifier) {
+ public void setCompanyIdentifier(String companyIdentifier) {
this.companyIdentifier = companyIdentifier;
}
public String getCompanyName() {
return companyName;
}
- void setCompanyName(String companyName) {
+ public void setCompanyName(String companyName) {
this.companyName = companyName;
}
View
58 app/src/main/java/org/axonframework/samples/trader/app/query/portfolio/ItemEntry.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.query.portfolio;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class ItemEntry {
+ private String identifier;
+ private String companyIdentifier;
+ private String companyName;
+ private int amount;
+
+ public int getAmount() {
+ return amount;
+ }
+
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+
+ public String getCompanyIdentifier() {
+ return companyIdentifier;
+ }
+
+ public void setCompanyIdentifier(String companyIdentifier) {
+ this.companyIdentifier = companyIdentifier;
+ }
+
+ public String getCompanyName() {
+ return companyName;
+ }
+
+ public void setCompanyName(String companyName) {
+ this.companyName = companyName;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+}
View
74 app/src/main/java/org/axonframework/samples/trader/app/query/portfolio/PortfolioEntry.java
@@ -17,6 +17,9 @@
import org.springframework.data.annotation.Id;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Jettro Coenradie
*/
@@ -27,6 +30,39 @@
private long amountOfMoney;
private long reservedAmountOfMoney;
+ private Map<String, ItemEntry> itemsInPossession = new HashMap<String, ItemEntry>();
+ private Map<String, ItemEntry> itemsReserved = new HashMap<String, ItemEntry>();
+
+ /*-------------------------------------------------------------------------------------------*/
+ /* utility functions */
+ /*-------------------------------------------------------------------------------------------*/
+ public ItemEntry findReservedItemByIdentifier(String identifier) {
+ return itemsReserved.get(identifier);
+ }
+
+ public ItemEntry findItemInPossession(String identifier) {
+ return itemsInPossession.get(identifier);
+ }
+
+ public void addReservedItem(ItemEntry itemEntry) {
+ handleAdd(itemsReserved, itemEntry);
+ }
+
+ public void addItemInPossession(ItemEntry itemEntry) {
+ handleAdd(itemsInPossession, itemEntry);
+ }
+
+ public void removeReservedItem(String itemIdentifier, int amount) {
+ handleRemoveItem(itemsReserved, itemIdentifier, amount);
+ }
+
+ public void removeItemsInPossession(String itemIdentifier, int amount) {
+ handleRemoveItem(itemsInPossession, itemIdentifier, amount);
+ }
+
+ /*-------------------------------------------------------------------------------------------*/
+ /* Getters and setters */
+ /*-------------------------------------------------------------------------------------------*/
public String getUserIdentifier() {
return userIdentifier;
}
@@ -58,4 +94,42 @@ public long getReservedAmountOfMoney() {
public void setReservedAmountOfMoney(long reservedAmountOfMoney) {
this.reservedAmountOfMoney = reservedAmountOfMoney;
}
+
+ public Map<String, ItemEntry> getItemsInPossession() {
+ return itemsInPossession;
+ }
+
+ public void setItemsInPossession(Map<String, ItemEntry> itemsInPossession) {
+ this.itemsInPossession = itemsInPossession;
+ }
+
+ public Map<String, ItemEntry> getItemsReserved() {
+ return itemsReserved;
+ }
+
+ public void setItemsReserved(Map<String, ItemEntry> itemsReserved) {
+ this.itemsReserved = itemsReserved;
+ }
+
+ /*-------------------------------------------------------------------------------------------*/
+ /* Private helper methods */
+ /*-------------------------------------------------------------------------------------------*/
+ private void handleAdd(Map<String, ItemEntry> items, ItemEntry itemEntry) {
+ if (items.containsKey(itemEntry.getIdentifier())) {
+ ItemEntry foundEntry = items.get(itemEntry.getIdentifier());
+ foundEntry.setAmount(foundEntry.getAmount() + itemEntry.getAmount());
+ } else {
+ items.put(itemEntry.getIdentifier(), itemEntry);
+ }
+ }
+
+ private void handleRemoveItem(Map<String, ItemEntry> items, String itemIdentifier, int amount) {
+ if (items.containsKey(itemIdentifier)) {
+ ItemEntry foundEntry = items.get(itemIdentifier);
+ foundEntry.setAmount(foundEntry.getAmount() - amount);
+ if (foundEntry.getAmount() <= 0) {
+ items.remove(foundEntry.getIdentifier());
+ }
+ }
+ }
}
View
104 ...java/org/axonframework/samples/trader/app/query/portfolio/PortfolioItemEventListener.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.query.portfolio;
+
+import org.axonframework.eventhandling.annotation.EventHandler;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemReservationCancelledForPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemReservationConfirmedForPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemsAddedToPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemsReservedEvent;
+import org.axonframework.samples.trader.app.query.orderbook.OrderBookEntry;
+import org.axonframework.samples.trader.app.query.orderbook.repositories.OrderBookQueryRepository;
+import org.axonframework.samples.trader.app.query.portfolio.repositories.PortfolioQueryRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Jettro Coenradie
+ */
+@Component
+public class PortfolioItemEventListener {
+ private final static Logger logger = LoggerFactory.getLogger(PortfolioItemEventListener.class);
+ private PortfolioQueryRepository portfolioRepository;
+ private OrderBookQueryRepository orderBookQueryRepository;
+
+ @EventHandler
+ public void handleEvent(ItemsAddedToPortfolioEvent event) {
+ logger.debug("Handle ItemsAddedToPortfolioEvent for orderbook with identifier {}", event.getItemIdentifier());
+ ItemEntry itemEntry = createItemEntry(event.getItemIdentifier().asString(), event.getAmountOfItemsAdded());
+
+ PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
+ portfolioEntry.addItemInPossession(itemEntry);
+
+ portfolioRepository.save(portfolioEntry);
+ }
+
+ @EventHandler
+ public void handleEvent(ItemReservationCancelledForPortfolioEvent event) {
+ logger.debug("Handle ItemReservationCancelledForPortfolioEvent for orderbook with identifier {}", event.getItemIdentifier());
+ ItemEntry itemEntry = createItemEntry(event.getItemIdentifier().asString(), event.getAmountOfCancelledItems());
+
+ PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
+ portfolioEntry.removeReservedItem(event.getItemIdentifier().asString(), event.getAmountOfCancelledItems());
+ portfolioEntry.addItemInPossession(itemEntry);
+
+ portfolioRepository.save(portfolioEntry);
+ }
+
+ @EventHandler
+ public void handleEvent(ItemReservationConfirmedForPortfolioEvent event) {
+ logger.debug("Handle ItemReservationConfirmedForPortfolioEvent for orderbook with identifier {}", event.getItemIdentifier());
+ PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
+ portfolioEntry.removeReservedItem(event.getItemIdentifier().asString(), event.getAmountOfConfirmedItems());
+
+ portfolioRepository.save(portfolioEntry);
+ }
+
+ @EventHandler
+ public void handleEvent(ItemsReservedEvent event) {
+ logger.debug("Handle ItemsReservedEvent for orderbook with identifier {}", event.getItemIdentifier());
+ ItemEntry itemEntry = createItemEntry(event.getItemIdentifier().asString(), event.getAmountOfItemsReserved());
+
+ PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
+ portfolioEntry.addReservedItem(itemEntry);
+
+ portfolioRepository.save(portfolioEntry);
+ }
+
+ private ItemEntry createItemEntry(String identifier, int amount) {
+ OrderBookEntry orderBookEntry = orderBookQueryRepository.findOne(identifier);
+ ItemEntry itemEntry = new ItemEntry();
+ itemEntry.setIdentifier(identifier);
+ itemEntry.setCompanyIdentifier(orderBookEntry.getCompanyIdentifier());
+ itemEntry.setCompanyName(orderBookEntry.getCompanyName());
+ itemEntry.setAmount(amount);
+ return itemEntry;
+ }
+
+ @SuppressWarnings("SpringJavaAutowiringInspection")
+ @Autowired
+ public void setPortfolioRepository(PortfolioQueryRepository portfolioRepository) {
+ this.portfolioRepository = portfolioRepository;
+ }
+
+ @SuppressWarnings("SpringJavaAutowiringInspection")
+ @Autowired
+ public void setOrderBookQueryRepository(OrderBookQueryRepository orderBookQueryRepository) {
+ this.orderBookQueryRepository = orderBookQueryRepository;
+ }
+}
View
31 ...pp/query/portfolio/PortfolioListener.java → ...ortfolio/PortfolioMoneyEventListener.java
@@ -17,9 +17,7 @@
import org.axonframework.eventhandling.annotation.EventHandler;
import org.axonframework.samples.trader.app.api.portfolio.PortfolioCreatedEvent;
-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.MoneyWithdrawnFromPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.money.*;
import org.axonframework.samples.trader.app.query.portfolio.repositories.PortfolioQueryRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,8 +28,8 @@
* @author Jettro Coenradie
*/
@Component
-public class PortfolioListener {
- private final static Logger logger = LoggerFactory.getLogger(PortfolioListener.class);
+public class PortfolioMoneyEventListener {
+ private final static Logger logger = LoggerFactory.getLogger(PortfolioMoneyEventListener.class);
private PortfolioQueryRepository portfolioRepository;
@@ -67,11 +65,32 @@ public void handleEvent(MoneyWithdrawnFromPortfolioEvent event) {
public void handleEvent(MoneyReservedFromPortfolioEvent event) {
PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
portfolioEntry.setReservedAmountOfMoney(portfolioEntry.getReservedAmountOfMoney() + event.getAmountToReserve());
- portfolioEntry.setAmountOfMoney(portfolioEntry.getAmountOfMoney() - event.getAmountToReserve());
portfolioRepository.save(portfolioEntry);
}
+ @EventHandler
+ public void handleEvent(MoneyReservationCancelledFromPortfolioEvent event) {
+ PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
+ portfolioEntry.setReservedAmountOfMoney(portfolioEntry.getReservedAmountOfMoney() - event.getAmountOfMoneyToCancel());
+ portfolioRepository.save(portfolioEntry);
+ }
+
+ @EventHandler
+ public void handleEvent(MoneyReservationConfirmedFromPortfolioEvent event) {
+ PortfolioEntry portfolioEntry = portfolioRepository.findOne(event.getPortfolioIdentifier().asString());
+ long reservedAmountOfMoney = portfolioEntry.getReservedAmountOfMoney();
+ long amountOfMoneyConfirmed = event.getAmountOfMoneyConfirmedInCents();
+ if (amountOfMoneyConfirmed < reservedAmountOfMoney) {
+ portfolioEntry.setReservedAmountOfMoney(reservedAmountOfMoney - amountOfMoneyConfirmed);
+ } else {
+ portfolioEntry.setReservedAmountOfMoney(0);
+ }
+
+ portfolioEntry.setAmountOfMoney(portfolioEntry.getAmountOfMoney() - amountOfMoneyConfirmed);
+ portfolioRepository.save(portfolioEntry);
+ }
+ @SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
public void setPortfolioRepository(PortfolioQueryRepository portfolioRepository) {
this.portfolioRepository = portfolioRepository;
View
76 ...test/java/org/axonframework/samples/trader/app/query/portfolio/PortfolioEntryMatcher.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.query.portfolio;
+
+import org.hamcrest.Description;
+import org.mockito.ArgumentMatcher;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class PortfolioEntryMatcher extends ArgumentMatcher<PortfolioEntry> {
+ private String problem;
+ private final int itemsInPossession;
+ private String itemIdentifier;
+ private int amountOfItemInPossession;
+ private int itemsInReservation;
+ private int amountOfItemInReservation;
+
+ public PortfolioEntryMatcher(String itemIdentifier, int itemsInPossession, int amountOfItemInPossession, int itemsInReservation, int amountOfItemInReservation) {
+ this.itemsInPossession = itemsInPossession;
+ this.itemIdentifier = itemIdentifier;
+ this.amountOfItemInPossession = amountOfItemInPossession;
+ this.itemsInReservation = itemsInReservation;
+ this.amountOfItemInReservation = amountOfItemInReservation;
+ }
+
+ @Override
+ public boolean matches(Object argument) {
+ if (!(argument instanceof PortfolioEntry)) {
+ problem = String.format("Wrong argument type, required %s but received %s", PortfolioEntry.class.getName(), argument.getClass().getName());
+ return false;
+ }
+ PortfolioEntry portfolioEntry = (PortfolioEntry) argument;
+
+ if (portfolioEntry.getItemsInPossession().size() != itemsInPossession) {
+ problem = String.format("Amount of item entries in possession should be %d but was %d", itemsInPossession, portfolioEntry.getItemsInPossession().size());
+ return false;
+ }
+ int foundAmountOfItemsInPossession = portfolioEntry.findItemInPossession(itemIdentifier).getAmount();
+ if (foundAmountOfItemsInPossession != amountOfItemInPossession) {
+ problem = String.format("The amount of the item in possession should be %d but was %d", amountOfItemInPossession, foundAmountOfItemsInPossession);
+ return false;
+ }
+ if (portfolioEntry.getItemsReserved().size() != itemsInReservation) {
+ problem = String.format("The amount of reserved item entries should be %d but was %d", itemsInReservation, portfolioEntry.getItemsReserved().size());
+ return false;
+ }
+ if (itemsInReservation != 0) {
+ int foundAmountOfItemsInReservation = portfolioEntry.findReservedItemByIdentifier(itemIdentifier).getAmount();
+ if (foundAmountOfItemsInReservation != amountOfItemInReservation) {
+ problem = String.format("The amount of the reserved items should be %d but was %d", amountOfItemInReservation, foundAmountOfItemsInReservation);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(problem);
+ }
+}
View
151 .../org/axonframework/samples/trader/app/query/portfolio/PortfolioItemEventListenerTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2011. Gridshore
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.axonframework.samples.trader.app.query.portfolio;
+
+import org.axonframework.domain.AggregateIdentifier;
+import org.axonframework.domain.UUIDAggregateIdentifier;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemReservationCancelledForPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemReservationConfirmedForPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemsAddedToPortfolioEvent;
+import org.axonframework.samples.trader.app.api.portfolio.item.ItemsReservedEvent;
+import org.axonframework.samples.trader.app.query.orderbook.OrderBookEntry;
+import org.axonframework.samples.trader.app.query.orderbook.repositories.OrderBookQueryRepository;
+import org.axonframework.samples.trader.app.query.portfolio.repositories.PortfolioQueryRepository;
+import org.axonframework.test.utils.DomainEventUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.*;
+
+/**
+ * @author Jettro Coenradie
+ */
+public class PortfolioItemEventListenerTest {
+ public static final int DEFAULT_AMOUNT_ITEMS = 100;
+ private PortfolioQueryRepository portfolioQueryRepository;
+ private PortfolioItemEventListener listener;
+
+ final AggregateIdentifier userIdentifier = new UUIDAggregateIdentifier();
+ final AggregateIdentifier itemIdentifier = new UUIDAggregateIdentifier();
+ final AggregateIdentifier portfolioIdentifier = new UUIDAggregateIdentifier();
+ final AggregateIdentifier companyIdentifier = new UUIDAggregateIdentifier();
+
+ @Before
+ public void setUp() throws Exception {
+ portfolioQueryRepository = mock(PortfolioQueryRepository.class);
+
+ OrderBookQueryRepository orderBookQueryRepository = mock(OrderBookQueryRepository.class);
+
+ listener = new PortfolioItemEventListener();
+ listener.setPortfolioRepository(portfolioQueryRepository);
+ listener.setOrderBookQueryRepository(orderBookQueryRepository);
+
+ OrderBookEntry orderBookEntry = createOrderBookEntry();
+ when(orderBookQueryRepository.findOne(itemIdentifier.asString())).thenReturn(orderBookEntry);
+
+ PortfolioEntry portfolioEntry = createPortfolioEntry();
+ when(portfolioQueryRepository.findOne(portfolioIdentifier.asString())).thenReturn(portfolioEntry);
+
+ }
+
+ @Test
+ public void testHandleEventAddItems() throws Exception {
+ ItemsAddedToPortfolioEvent event = new ItemsAddedToPortfolioEvent(itemIdentifier, 100);
+ DomainEventUtils.setAggregateIdentifier(event, portfolioIdentifier);
+ listener.handleEvent(event);
+
+ verify(portfolioQueryRepository).save(argThat(new PortfolioEntryMatcher(
+ itemIdentifier.asString(),
+ 1,
+ 2 * DEFAULT_AMOUNT_ITEMS,
+ 1,
+ DEFAULT_AMOUNT_ITEMS)));
+ }
+
+ @Test
+ public void testHandleEventCancelItemReservation() throws Exception {
+ ItemReservationCancelledForPortfolioEvent event =
+ new ItemReservationCancelledForPortfolioEvent(itemIdentifier, DEFAULT_AMOUNT_ITEMS);
+ DomainEventUtils.setAggregateIdentifier(event, portfolioIdentifier);
+ listener.handleEvent(event);
+
+ verify(portfolioQueryRepository).save(argThat(new PortfolioEntryMatcher(
+ itemIdentifier.asString(),
+ 1,
+ 2 * DEFAULT_AMOUNT_ITEMS,
+ 0,
+ 0)));
+ }
+
+ @Test
+ public void testHandleEventConfirmItemReservation() {
+ ItemReservationConfirmedForPortfolioEvent event = new ItemReservationConfirmedForPortfolioEvent(itemIdentifier, 50);
+ DomainEventUtils.setAggregateIdentifier(event, portfolioIdentifier);
+
+ listener.handleEvent(event);
+
+ verify(portfolioQueryRepository).save(argThat(new PortfolioEntryMatcher(
+ itemIdentifier.asString(),
+ 1,
+ DEFAULT_AMOUNT_ITEMS,
+ 1,
+ DEFAULT_AMOUNT_ITEMS - 50)));
+ }
+
+ @Test
+ public void testHandleItemReservedEvent() {
+ ItemsReservedEvent event = new ItemsReservedEvent(itemIdentifier, DEFAULT_AMOUNT_ITEMS);
+ DomainEventUtils.setAggregateIdentifier(event, portfolioIdentifier);
+ listener.handleEvent(event);
+
+ verify(portfolioQueryRepository).save(argThat(new PortfolioEntryMatcher(
+ itemIdentifier.asString(),
+ 1,
+ DEFAULT_AMOUNT_ITEMS,
+ 1,
+ 2 * DEFAULT_AMOUNT_ITEMS)));
+ }
+
+ private PortfolioEntry createPortfolioEntry() {
+ PortfolioEntry portfolioEntry = new PortfolioEntry();
+ portfolioEntry.setIdentifier(portfolioIdentifier.asString());
+ portfolioEntry.setUserIdentifier(userIdentifier.asString());
+
+ portfolioEntry.addItemInPossession(createItemEntry(itemIdentifier, companyIdentifier));
+ portfolioEntry.addReservedItem(createItemEntry(itemIdentifier, companyIdentifier));
+ portfolioEntry.setReservedAmountOfMoney(1000);
+ portfolioEntry.setAmountOfMoney(10000);
+ return portfolioEntry;
+ }
+
+ private OrderBookEntry createOrderBookEntry() {
+ OrderBookEntry orderBookEntry = new OrderBookEntry();
+ orderBookEntry.setIdentifier(itemIdentifier.asString());
+ orderBookEntry.setCompanyIdentifier(companyIdentifier.asString());
+ orderBookEntry.setCompanyName("Test Company");
+ return orderBookEntry;
+ }
+
+ private ItemEntry createItemEntry(AggregateIdentifier itemIdentifier, AggregateIdentifier companyIdentifier) {
+ ItemEntry itemInPossession = new ItemEntry();
+ itemInPossession.setIdentifier(itemIdentifier.asString());
+ itemInPossession.setCompanyIdentifier(companyIdentifier.asString());
+ itemInPossession.setCompanyName("Test company");
+ itemInPossession.setAmount(DEFAULT_AMOUNT_ITEMS);
+ return itemInPossession;
+ }
+}
View
2 web-ui/src/main/java/org/axonframework/samples/trader/webui/init/DBInit.java
@@ -96,7 +96,7 @@ public void createItems() {
eventStore.ensureIndexes();
}
- public void addMoneyToPortfolio(String portfolioIdentifier, long amountOfMoney) {
+ public void depositMoneyToPortfolio(String portfolioIdentifier, long amountOfMoney) {
DepositMoneyToPortfolioCommand command =
new DepositMoneyToPortfolioCommand(new UUIDAggregateIdentifier(portfolioIdentifier), amountOfMoney);
commandBus.dispatch(command);
View
2 web-ui/src/main/java/org/axonframework/samples/trader/webui/init/MongoController.java
@@ -89,7 +89,7 @@ public String initializeMongo(Model model) {
public String addMoneyToPortfolio(@PathVariable("identifier") String portfolioIdentifier,
@PathVariable("amount") long amount,
Model model) {
- dbInit.addMoneyToPortfolio(portfolioIdentifier, amount);
+ dbInit.depositMoneyToPortfolio(portfolioIdentifier, amount);
model.addAttribute("info", "Added money to the portfolio.");
return "data/info";
}

0 comments on commit 2803017

Please sign in to comment.