@Test public void loadActiveProductsNotInVIAForm() throws Exception { Product product1 = new ProductBuilder().setCode("P1").setPrimaryName("A1").build(); Product product2 = new ProductBuilder().setCode("P2").setPrimaryName("A2").build(); Product product3 = new ProductBuilder().setCode("P3").setPrimaryName("A3").build(); Product product4 = new ProductBuilder().setCode("P4").setPrimaryName("A4").build(); when(productRepository.queryActiveProductsInVIAProgramButNotInDraftVIAForm()).thenReturn(newArrayList(product1, product2, product3, product4)); TestSubscriber<Void> subscriber = new TestSubscriber<>(); presenter.loadActiveProductsNotInVIAForm(newArrayList("P3", "P4")).subscribe(subscriber); subscriber.awaitTerminalEvent(); subscriber.assertNoErrors(); assertThat(presenter.getInventoryViewModelList().size(), is(2)); assertThat(presenter.getInventoryViewModelList().get(0).getProductName(), is("A1")); assertThat(presenter.getInventoryViewModelList().get(1).getProductName(), is("A2")); }
public Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts) { return Observable.create((Observable.OnSubscribe<Void>) subscriber -> { try { inventoryViewModelList.addAll(FluentIterable .from(productRepository.queryActiveProductsInVIAProgramButNotInDraftVIAForm()) .filter(product -> !existingProducts.contains(product.getCode())) .transform((Function<Product, InventoryViewModel>) product -> new AddDrugsToViaInventoryViewModel(product)) .toList()); subscriber.onNext(null); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "AddDrugsToVIAPresenter,loadActiveProductsNotInVIAForm").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }
AddDrugsToVIAPresenter extends Presenter { public Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts) { return Observable.create((Observable.OnSubscribe<Void>) subscriber -> { try { inventoryViewModelList.addAll(FluentIterable .from(productRepository.queryActiveProductsInVIAProgramButNotInDraftVIAForm()) .filter(product -> !existingProducts.contains(product.getCode())) .transform((Function<Product, InventoryViewModel>) product -> new AddDrugsToViaInventoryViewModel(product)) .toList()); subscriber.onNext(null); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "AddDrugsToVIAPresenter,loadActiveProductsNotInVIAForm").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } }
AddDrugsToVIAPresenter extends Presenter { public Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts) { return Observable.create((Observable.OnSubscribe<Void>) subscriber -> { try { inventoryViewModelList.addAll(FluentIterable .from(productRepository.queryActiveProductsInVIAProgramButNotInDraftVIAForm()) .filter(product -> !existingProducts.contains(product.getCode())) .transform((Function<Product, InventoryViewModel>) product -> new AddDrugsToViaInventoryViewModel(product)) .toList()); subscriber.onNext(null); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "AddDrugsToVIAPresenter,loadActiveProductsNotInVIAForm").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } AddDrugsToVIAPresenter(); }
AddDrugsToVIAPresenter extends Presenter { public Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts) { return Observable.create((Observable.OnSubscribe<Void>) subscriber -> { try { inventoryViewModelList.addAll(FluentIterable .from(productRepository.queryActiveProductsInVIAProgramButNotInDraftVIAForm()) .filter(product -> !existingProducts.contains(product.getCode())) .transform((Function<Product, InventoryViewModel>) product -> new AddDrugsToViaInventoryViewModel(product)) .toList()); subscriber.onNext(null); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "AddDrugsToVIAPresenter,loadActiveProductsNotInVIAForm").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } AddDrugsToVIAPresenter(); @Override void attachView(BaseView v); Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts); Observable<ArrayList<RnrFormItem>> convertViewModelsToRnrFormItems(); }
AddDrugsToVIAPresenter extends Presenter { public Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts) { return Observable.create((Observable.OnSubscribe<Void>) subscriber -> { try { inventoryViewModelList.addAll(FluentIterable .from(productRepository.queryActiveProductsInVIAProgramButNotInDraftVIAForm()) .filter(product -> !existingProducts.contains(product.getCode())) .transform((Function<Product, InventoryViewModel>) product -> new AddDrugsToViaInventoryViewModel(product)) .toList()); subscriber.onNext(null); subscriber.onCompleted(); } catch (LMISException e) { new LMISException(e, "AddDrugsToVIAPresenter,loadActiveProductsNotInVIAForm").reportToFabric(); subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } AddDrugsToVIAPresenter(); @Override void attachView(BaseView v); Observable<Void> loadActiveProductsNotInVIAForm(final List<String> existingProducts); Observable<ArrayList<RnrFormItem>> convertViewModelsToRnrFormItems();  }