Getting this error when I run the test. The code works fine as I checked in debug mode though.
I tried using getStockQuote function from
- Using StockQuoteServiceFactory
- Using PortfolioManagerImpl
I also tried implementing the whole function in call() function in the implementation of Callable class.
Exception:
org.mockito.exceptions.misusing.UnnecessaryStubbingException:
Unnecessary stubbings detected.
Clean & maintainable test code requires zero unnecessary code.
Following stubbings are unnecessary (click to navigate to relevant line of code):
- -> at com.crio.warmup.stock.portfolio.PortfolioManagerPerformanceTest.getPortfolioManager(PortfolioManagerPerformanceTest.java:134)
- -> at com.crio.warmup.stock.portfolio.PortfolioManagerPerformanceTest.getPortfolioManager(PortfolioManagerPerformanceTest.java:136)
- -> at com.crio.warmup.stock.portfolio.PortfolioManagerPerformanceTest.getPortfolioManager(PortfolioManagerPerformanceTest.java:138)
Test File:
Mockito.doAnswer(invocation -> getCandles(aaplQuotes, false)) .when(stockQuotesService).getStockQuote(eq("AAPL"), any(), any()); Mockito.doAnswer(invocation -> getCandles(msftQuotes, withException)) .when(stockQuotesService).getStockQuote(eq("MSFT"), any(), any()); Mockito.doAnswer(invocation -> getCandles(googlQuotes, withException)) .when(stockQuotesService).getStockQuote(eq("GOOGL"), any(), any());