PortofolioEntity extends AuditableEntity { public SymbolEntity getCurrencyFor(SymbolEntity symbol) { return (symbol.getCurrency() != null) ? symbol.getCurrency() : getBaseCurrency(); }  List<AssetEntity> getAssets(); AssetEntity getAsset(String symbolCode); SymbolEntity getCurrencyFor(SymbolEntity symbol); List<SymbolEntity> getCurrencies(); Order buy(SymbolEntity fromSymbol, double quantity, RateService rateService); Order sell(SymbolEntity fromSymbol, double quantity, RateService rateService);  }
@Test public void testGetCurrencyFor_Currency() { String login = "toto"; String assetCode = USD; PortofolioEntity portofolio = portofolioRepo.findByUserUsername(login); SymbolEntity se = symbolRepo.findById(assetCode).get(); SymbolEntity currency = portofolio.getCurrencyFor(se); assertThat(currency.getCode()).isEqualTo(EUR); }
@Test public void testGetCurrencyFor_Stock() { String login = "toto"; String assetCode = "RR"; PortofolioEntity portofolio = portofolioRepo.findByUserUsername(login); SymbolEntity se = symbolRepo.findById(assetCode).get(); SymbolEntity currency = portofolio.getCurrencyFor(se); assertThat(currency.getCode()).isEqualTo(GBP); }