### Question:
InvestorService { public Stock updateAStockByInvestorIdAndStock(String investorId, Stock stockTobeUpdated) { Investor investor = fetchInvestorById(investorId); if (investor == null) { return null; } Stock currentStock = fetchSingleStockByInvestorIdAndStockSymbol(investorId, stockTobeUpdated.getSymbol()); if (currentStock == null) { return null; } currentStock.setNumberOfSharesHeld(stockTobeUpdated.getNumberOfSharesHeld()); currentStock.setTickerPrice(stockTobeUpdated.getTickerPrice()); return currentStock; }  List<Investor> fetchAllInvestors(); Investor fetchInvestorById(String investorId); List<Stock> fetchStocksByInvestorId(String investorId, int offset, int limit); Stock fetchSingleStockByInvestorIdAndStockSymbol(String investorId, String symbol); Stock addNewStockToTheInvestorPortfolio(String investorId, Stock newStock); boolean deleteStockFromTheInvestorPortfolio(String investorId, String stockTobeDeletedSymbol); Stock updateAStockByInvestorIdAndStock(String investorId, Stock stockTobeUpdated); Stock updateAStockByInvestorIdAndStock(String investorId, String symbol, Stock stockTobeUpdated);  }### Answer:
@Test public void testUpdateAStockByInvestorId() { Stock expectedStock = new Stock("EXA", 150, 18.5); InvestorService localInvestorService = getInvestorServiceForTest(); String investorId = "invr_1"; Stock actualStock = localInvestorService.updateAStockByInvestorIdAndStock(investorId, expectedStock); assertEquals(expectedStock.getNumberOfSharesHeld(), actualStock.getNumberOfSharesHeld()); assertEquals(expectedStock.getTickerPrice(), actualStock.getTickerPrice()); }
@Test public void testUpdateAStockByInvestorIdWhenInvestorIdNotFound() { Stock expectedStock = new Stock("EXA", 150, 18.5); InvestorService localInvestorService = getInvestorServiceForTest(); String investorId = "invr_not_found"; Stock actualStock = localInvestorService.updateAStockByInvestorIdAndStock(investorId, expectedStock); assertNull(actualStock); }
@Test public void testUpdateAStockByInvestorIdWhenStockSymbolNotFound() { Stock expectedStock = new Stock("not_found", 150, 18.5); InvestorService localInvestorService = getInvestorServiceForTest(); String investorId = "invr_1"; Stock actualStock = localInvestorService.updateAStockByInvestorIdAndStock(investorId, expectedStock); assertNull(actualStock); }