PortofolioService { protected AssetInfo getAsset(AssetEntity ae) { SymbolEntity currency = ae.getCurrency(); AssetInfo asset = new AssetInfo(ae.getSymbol(), currency, ae.getQuantity().doubleValue()); Rate q = rateService.getLatest(ae.getSymbol().getCode(), currency.getCode()); if (!equalsByComparingTo(ae.getQuantity(), ZERO)) { BigDecimal currentValue = q.getValue().multiply(ae.getQuantity()); double percentChange = percentChange(ae.getCurrencyAmount(), currentValue); asset.setValue(ae.getCurrencyAmount().doubleValue()); asset.setCurrentValue(currentValue.doubleValue()); asset.setValueChange(currentValue.subtract(ae.getCurrencyAmount()).doubleValue()); asset.setPercentChange(percentChange); } asset.setCurrentRate(q.getValue().doubleValue()); return asset; }  Portofolio createPortofolio(String login, String baseCurrencyCode, int baseCurrencyAmount); AssetInfo getBaseCurrency(String login); Portofolio getPortofolio(String login); OrderInfo getOrderInfo(String login, String symbolCode, double quantity); List<Symbol> getAvailableSymbols(String login); Order buy(String login, String code, double quantity); Order sell(String login, String code, double quantity);  }
@Test public void testGetAsset() { String login = "toto"; String symbol = GBP; int amount = 5000; AssetEntity ae = portofolioRepo.findByUserUsername(login).getAsset(symbol); AssetInfo a = portofolioService.getAsset(ae); assertThat(a.getSymbol().getCode()).isEqualTo(symbol); assertThat(a.getQuantity()).isEqualTo(amount); assertThat(a.getValue()).isEqualTo(6000); assertThat(a.getCurrentValue()).isEqualTo(6332.419239); assertThat(a.getValueChange()).isEqualTo(332.419239); assertThat(a.getPercentChange()).isEqualTo(5.54032065); assertThat(a.getCurrentRate()).isEqualTo(1.2664838478); }