@Test public void shouldLoadKitProductList() throws Exception { Product kit = prepareKit(); TestSubscriber<List<InventoryViewModel>> subscriber = new TestSubscriber<>(); presenter.subscriptions.add(presenter.getKitProductsObservable("KIT_Code", 3).subscribe(subscriber)); subscriber.awaitTerminalEvent(); verify(productRepository).queryKitProductByKitCode(kit.getCode()); List<InventoryViewModel> resultProducts = presenter.getInventoryViewModels(); assertThat(resultProducts.size(), is(2)); InventoryViewModel viewModel1 = resultProducts.get(0); InventoryViewModel viewModel2 = resultProducts.get(1); assertThat(viewModel1.getProduct().getCode(), is("P1_Code")); assertThat(viewModel2.getProduct().getCode(), is("P2_Code")); assertThat(viewModel1.getKitExpectQuantity(), is(300L)); assertThat(viewModel2.getKitExpectQuantity(), is(600L)); assertTrue(viewModel1.isChecked()); assertTrue(viewModel2.isChecked()); }
public Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum) { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { UnpackKitPresenter.this.kitCode = kitCode; inventoryViewModels.clear(); List<KitProduct> kitProducts = productRepository.queryKitProductByKitCode(kitCode); for (KitProduct kitProduct : kitProducts) { final Product product = productRepository.getByCode(kitProduct.getProductCode()); InventoryViewModel inventoryViewModel = new UnpackKitInventoryViewModel(product); setExistingLotViewModels(inventoryViewModel); inventoryViewModel.setKitExpectQuantity(kitProduct.getQuantity() * kitNum); inventoryViewModel.setChecked(true); inventoryViewModels.add(inventoryViewModel); } subscriber.onNext(inventoryViewModels); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); }
UnpackKitPresenter extends Presenter { public Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum) { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { UnpackKitPresenter.this.kitCode = kitCode; inventoryViewModels.clear(); List<KitProduct> kitProducts = productRepository.queryKitProductByKitCode(kitCode); for (KitProduct kitProduct : kitProducts) { final Product product = productRepository.getByCode(kitProduct.getProductCode()); InventoryViewModel inventoryViewModel = new UnpackKitInventoryViewModel(product); setExistingLotViewModels(inventoryViewModel); inventoryViewModel.setKitExpectQuantity(kitProduct.getQuantity() * kitNum); inventoryViewModel.setChecked(true); inventoryViewModels.add(inventoryViewModel); } subscriber.onNext(inventoryViewModels); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } }
UnpackKitPresenter extends Presenter { public Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum) { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { UnpackKitPresenter.this.kitCode = kitCode; inventoryViewModels.clear(); List<KitProduct> kitProducts = productRepository.queryKitProductByKitCode(kitCode); for (KitProduct kitProduct : kitProducts) { final Product product = productRepository.getByCode(kitProduct.getProductCode()); InventoryViewModel inventoryViewModel = new UnpackKitInventoryViewModel(product); setExistingLotViewModels(inventoryViewModel); inventoryViewModel.setKitExpectQuantity(kitProduct.getQuantity() * kitNum); inventoryViewModel.setChecked(true); inventoryViewModels.add(inventoryViewModel); } subscriber.onNext(inventoryViewModels); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } UnpackKitPresenter(); }
UnpackKitPresenter extends Presenter { public Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum) { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { UnpackKitPresenter.this.kitCode = kitCode; inventoryViewModels.clear(); List<KitProduct> kitProducts = productRepository.queryKitProductByKitCode(kitCode); for (KitProduct kitProduct : kitProducts) { final Product product = productRepository.getByCode(kitProduct.getProductCode()); InventoryViewModel inventoryViewModel = new UnpackKitInventoryViewModel(product); setExistingLotViewModels(inventoryViewModel); inventoryViewModel.setKitExpectQuantity(kitProduct.getQuantity() * kitNum); inventoryViewModel.setChecked(true); inventoryViewModels.add(inventoryViewModel); } subscriber.onNext(inventoryViewModels); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } UnpackKitPresenter(); @Override void attachView(BaseView v); Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum); Observable saveUnpackProductsObservable(final int kitUnpackQuantity, final String documentNumber, final String signature); }
UnpackKitPresenter extends Presenter { public Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum) { return Observable.create((Observable.OnSubscribe<List<InventoryViewModel>>) subscriber -> { try { UnpackKitPresenter.this.kitCode = kitCode; inventoryViewModels.clear(); List<KitProduct> kitProducts = productRepository.queryKitProductByKitCode(kitCode); for (KitProduct kitProduct : kitProducts) { final Product product = productRepository.getByCode(kitProduct.getProductCode()); InventoryViewModel inventoryViewModel = new UnpackKitInventoryViewModel(product); setExistingLotViewModels(inventoryViewModel); inventoryViewModel.setKitExpectQuantity(kitProduct.getQuantity() * kitNum); inventoryViewModel.setChecked(true); inventoryViewModels.add(inventoryViewModel); } subscriber.onNext(inventoryViewModels); subscriber.onCompleted(); } catch (LMISException e) { subscriber.onError(e); } }).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()); } UnpackKitPresenter(); @Override void attachView(BaseView v); Observable<List<InventoryViewModel>> getKitProductsObservable(final String kitCode, final int kitNum); Observable saveUnpackProductsObservable(final int kitUnpackQuantity, final String documentNumber, final String signature);  }