StockCardPresenter extends Presenter { public void loadStockCards(ArchiveStatus status) { loadStockCards(status, true); } StockCardPresenter(); List<InventoryViewModel> getInventoryViewModels(); Observable<List<StockCard>> correctDirtyObservable(ArchiveStatus status); void loadStockCards(ArchiveStatus status); void loadStockCards(ArchiveStatus status, Boolean showLoading); void loadKits(); void refreshStockCardsObservable(long stockCardId); @Override void attachView(BaseView v); void archiveBackStockCard(StockCard stockCard);  }
@Test public void shouldLoadStockCardsWithActiveProductsWithNoSOH() throws Exception { when(stockRepository.list()).thenReturn(newArrayList(stockCard(false, true, false, 0), stockCard(false, false, false, 0), stockCard(false, true, true, 0))); TestSubscriber<List<StockCard>> afterLoadHandler = new TestSubscriber<>(); presenter.afterLoadHandler = afterLoadHandler; presenter.loadStockCards(StockCardPresenter.ArchiveStatus.Active); afterLoadHandler.awaitTerminalEvent(); List<StockCard> loadedStockCards = afterLoadHandler.getOnNextEvents().get(0); assertEquals(1, loadedStockCards.size()); assertTrue(loadedStockCards.get(0).getProduct().isActive()); }
@Test public void shouldLoadStockCardsWithDeactivatedProductWithSOH() throws Exception { when(stockRepository.list()).thenReturn(newArrayList(stockCard(false, true, false, 10), stockCard(false, false, false, 10))); TestSubscriber<List<StockCard>> afterLoadHandler = new TestSubscriber<>(); presenter.afterLoadHandler = afterLoadHandler; presenter.loadStockCards(StockCardPresenter.ArchiveStatus.Active); afterLoadHandler.awaitTerminalEvent(); assertEquals(2, afterLoadHandler.getOnNextEvents().get(0).size()); }