### Question:
AddNewItemViewModel extends ViewModel { public void addNewStock(String symbolName, BigDecimal shareCount) { Date date = new Date(); StockPortfolioItem item = new StockPortfolioItem( symbolName, shareCount, date ); portfolioRepository.save(item); getActivity().finish(); } @Inject  AddNewItemViewModel(); void addNewStock(String symbolName, BigDecimal shareCount); @VisibleForTesting void setPortfolioRepository(PortfolioRepository portfolioRepository);  }### Answer:
@Test public void verifyPersistenceCalls() { viewModel.addNewStock("GOOG", BigDecimal.ONE); verify(portfolioRepository, atLeast(1)) .save(any(StockPortfolioItem.class)); }
@Test public void verifyActivityBeingClosed() { viewModel.addNewStock("GOOG", BigDecimal.ONE); verify(activity, only()).finish(); }