@Test public void yahooFinanceIntegrationTest() { final CalculateNAV calculateNav = new CalculateNAV( YahooFinance::getPrice ); BigDecimal oneGOOGShare = calculateNav.computeStockWorth( "GOOG", 1 ); assertNotNull( oneGOOGShare ); BigDecimal zero = new BigDecimal( 0 ); assertTrue( oneGOOGShare.compareTo( zero ) >= 0 ); BigDecimal expectedTenGOOGShares = oneGOOGShare.multiply( new BigDecimal( 10 ) ); BigDecimal actualTenGOOGShares = calculateNav.computeStockWorth( "GOOG", 10 ); assertEquals( expectedTenGOOGShares, actualTenGOOGShares ); }
public BigDecimal computeStockWorth( final String ticker, final int shares ) { return priceFinder.apply( ticker ).multiply( BigDecimal.valueOf( shares ) ); }
CalculateNAV { public BigDecimal computeStockWorth( final String ticker, final int shares ) { return priceFinder.apply( ticker ).multiply( BigDecimal.valueOf( shares ) ); } }
CalculateNAV { public BigDecimal computeStockWorth( final String ticker, final int shares ) { return priceFinder.apply( ticker ).multiply( BigDecimal.valueOf( shares ) ); } CalculateNAV( final Function<String, BigDecimal> aPriceFinder ); }
CalculateNAV { public BigDecimal computeStockWorth( final String ticker, final int shares ) { return priceFinder.apply( ticker ).multiply( BigDecimal.valueOf( shares ) ); } CalculateNAV( final Function<String, BigDecimal> aPriceFinder ); BigDecimal computeStockWorth( final String ticker, final int shares ); }
CalculateNAV { public BigDecimal computeStockWorth( final String ticker, final int shares ) { return priceFinder.apply( ticker ).multiply( BigDecimal.valueOf( shares ) ); } CalculateNAV( final Function<String, BigDecimal> aPriceFinder ); BigDecimal computeStockWorth( final String ticker, final int shares );  }