@Test public void shouldLoadPhysicalStockCardListWithoutDeactivatedOrKitProducts() throws LMISException { StockCard stockCardVIA = StockCardBuilder.buildStockCard(); stockCardVIA.setProduct(new ProductBuilder().setPrimaryName("VIA Product").setIsArchived(false).setIsActive(true).build()); StockCard stockCardMMIA = StockCardBuilder.buildStockCard(); stockCardMMIA.setProduct(new ProductBuilder().setPrimaryName("MMIA Product").setIsArchived(false).setIsActive(false).build()); StockCard kitStockCard = StockCardBuilder.buildStockCard(); kitStockCard.setProduct(new ProductBuilder().setPrimaryName("VIA Kit Product").setIsArchived(false).setIsActive(true).setIsKit(true).build()); List<StockCard> stockCards = Arrays.asList(stockCardMMIA, stockCardVIA, kitStockCard); when(stockRepositoryMock.list()).thenReturn(stockCards); TestSubscriber<List<InventoryViewModel>> subscriber = new TestSubscriber<>(); Observable<List<InventoryViewModel>> observable = presenter.loadInventory(); observable.subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); List<InventoryViewModel> receivedInventoryViewModels = subscriber.getOnNextEvents().get(0); assertEquals(1, receivedInventoryViewModels.size()); assertEquals("VIA Product", receivedInventoryViewModels.get(0).getProductName()); }
@Override public Observable<List<InventoryViewModel>> loadInventory() { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { List<StockCard> validStockCardsForPhysicalInventory = getValidStockCardsForPhysicalInventory(); inventoryViewModelList.addAll(convertStockCardsToStockCardViewModels(validStockCardsForPhysicalInventory)); restoreDraftInventory(); subscriber.onNext(inventoryViewModelList); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }
PhysicalInventoryPresenter extends InventoryPresenter { @Override public Observable<List<InventoryViewModel>> loadInventory() { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { List<StockCard> validStockCardsForPhysicalInventory = getValidStockCardsForPhysicalInventory(); inventoryViewModelList.addAll(convertStockCardsToStockCardViewModels(validStockCardsForPhysicalInventory)); restoreDraftInventory(); subscriber.onNext(inventoryViewModelList); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } }
PhysicalInventoryPresenter extends InventoryPresenter { @Override public Observable<List<InventoryViewModel>> loadInventory() { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { List<StockCard> validStockCardsForPhysicalInventory = getValidStockCardsForPhysicalInventory(); inventoryViewModelList.addAll(convertStockCardsToStockCardViewModels(validStockCardsForPhysicalInventory)); restoreDraftInventory(); subscriber.onNext(inventoryViewModelList); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }  }
PhysicalInventoryPresenter extends InventoryPresenter { @Override public Observable<List<InventoryViewModel>> loadInventory() { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { List<StockCard> validStockCardsForPhysicalInventory = getValidStockCardsForPhysicalInventory(); inventoryViewModelList.addAll(convertStockCardsToStockCardViewModels(validStockCardsForPhysicalInventory)); restoreDraftInventory(); subscriber.onNext(inventoryViewModelList); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }  @Override Observable<List<InventoryViewModel>> loadInventory(); Observable<Object> saveDraftInventoryObservable(); Observable<Object> doInventory(final String sign); void updateAvgMonthlyConsumption(); int getCompleteCount(); }
PhysicalInventoryPresenter extends InventoryPresenter { @Override public Observable<List<InventoryViewModel>> loadInventory() { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { List<StockCard> validStockCardsForPhysicalInventory = getValidStockCardsForPhysicalInventory(); inventoryViewModelList.addAll(convertStockCardsToStockCardViewModels(validStockCardsForPhysicalInventory)); restoreDraftInventory(); subscriber.onNext(inventoryViewModelList); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }  @Override Observable<List<InventoryViewModel>> loadInventory(); Observable<Object> saveDraftInventoryObservable(); Observable<Object> doInventory(final String sign); void updateAvgMonthlyConsumption(); int getCompleteCount();  }