PortfolioView { public long obtainAmountOfAvailableItemsFor(String orderBookId) { long possession = obtainAmountOfItemsInPossessionFor(orderBookId); long reserved = obtainAmountOfReservedItemsFor(orderBookId); return possession - reserved; }  long obtainAmountOfAvailableItemsFor(String orderBookId); long obtainAmountOfReservedItemsFor(String orderBookId); long obtainAmountOfItemsInPossessionFor(String orderBookId); long obtainMoneyToSpend(); ItemEntry findReservedItemByIdentifier(String orderBookId); ItemEntry findItemInPossession(String orderBookId); void addReservedItem(ItemEntry itemEntry); void addItemInPossession(ItemEntry itemEntry); void removeReservedItem(String itemIdentifier, long amount); void removeItemsInPossession(String itemIdentifier, long amount); String getUserIdentifier(); void setUserIdentifier(String userIdentifier); long getAmountOfMoney(); void setAmountOfMoney(long amountOfMoney); String getIdentifier(); void setIdentifier(String identifier); long getReservedAmountOfMoney(); void setReservedAmountOfMoney(long reservedAmountOfMoney); Map<String, ItemEntry> getItemsInPossession(); void setItemsInPossession(Map<String, ItemEntry> itemsInPossession); Map<String, ItemEntry> getItemsReserved(); void setItemsReserved(Map<String, ItemEntry> itemsReserved); String getUserName(); void setUserName(String userName); @Override String toString();  }
@Test public void testObtainAvailableItems() { PortfolioView portfolio = createDefaultPortfolio(); assertEquals(AMOUNT_ITEMS - AMOUNT_RESERVED, portfolio.obtainAmountOfAvailableItemsFor(ORDER_BOOK_ID)); }