@Test public void shouldRestoreDraftInventoryWithLDraftLotItems() throws Exception { ArrayList<InventoryViewModel> inventoryViewModels = getStockCardViewModels(); ArrayList<DraftInventory> draftInventories = new ArrayList<>(); DraftInventory draftInventory = new DraftInventory(); draftInventory.setStockCard(stockCardWithIdNine); draftInventory.setQuantity(20L); LotMovementViewModel lotMovementViewModel1 = new LotMovementViewModelBuilder().setLotNumber("test").setExpiryDate("Sep 2016").setQuantity("10").build(); LotMovementViewModel lotMovementViewModel2 = new LotMovementViewModelBuilder().setLotNumber("testNew").setExpiryDate("Sep 2016").setQuantity("10").build(); inventoryViewModels.get(0).setExistingLotMovementViewModelList(newArrayList(lotMovementViewModel1)); DraftLotItem draftLotItem1 = new DraftLotItem(lotMovementViewModel1, stockCardWithIdNine.getProduct(), false); DraftLotItem draftLotItem2 = new DraftLotItem(lotMovementViewModel2, stockCardWithIdNine.getProduct(), true); draftInventory.setDraftLotItemListWrapper(newArrayList(draftLotItem1, draftLotItem2)); draftInventories.add(draftInventory); when(mockInventoryRepository.queryAllDraft()).thenReturn(draftInventories); presenter.getInventoryViewModelList().addAll(inventoryViewModels); presenter.restoreDraftInventory(); assertThat(inventoryViewModels.get(0).getNewLotMovementViewModelList().get(0).getLotNumber(), is("testNew")); assertThat(inventoryViewModels.get(0).getExistingLotMovementViewModelList().get(0).getLotNumber(), is("test")); }
protected void restoreDraftInventory() throws LMISException { List<DraftInventory> draftList = inventoryRepository.queryAllDraft(); for (DraftInventory draftInventory : draftList) { for (InventoryViewModel viewModel : inventoryViewModelList) { if (viewModel.getStockCardId() == draftInventory.getStockCard().getId()) { ((PhysicalInventoryViewModel) viewModel).setDraftInventory(draftInventory); } } } }
PhysicalInventoryPresenter extends InventoryPresenter { protected void restoreDraftInventory() throws LMISException { List<DraftInventory> draftList = inventoryRepository.queryAllDraft(); for (DraftInventory draftInventory : draftList) { for (InventoryViewModel viewModel : inventoryViewModelList) { if (viewModel.getStockCardId() == draftInventory.getStockCard().getId()) { ((PhysicalInventoryViewModel) viewModel).setDraftInventory(draftInventory); } } } } }
PhysicalInventoryPresenter extends InventoryPresenter { protected void restoreDraftInventory() throws LMISException { List<DraftInventory> draftList = inventoryRepository.queryAllDraft(); for (DraftInventory draftInventory : draftList) { for (InventoryViewModel viewModel : inventoryViewModelList) { if (viewModel.getStockCardId() == draftInventory.getStockCard().getId()) { ((PhysicalInventoryViewModel) viewModel).setDraftInventory(draftInventory); } } } }  }
PhysicalInventoryPresenter extends InventoryPresenter { protected void restoreDraftInventory() throws LMISException { List<DraftInventory> draftList = inventoryRepository.queryAllDraft(); for (DraftInventory draftInventory : draftList) { for (InventoryViewModel viewModel : inventoryViewModelList) { if (viewModel.getStockCardId() == draftInventory.getStockCard().getId()) { ((PhysicalInventoryViewModel) viewModel).setDraftInventory(draftInventory); } } } }  @Override Observable<List<InventoryViewModel>> loadInventory(); Observable<Object> saveDraftInventoryObservable(); Observable<Object> doInventory(final String sign); void updateAvgMonthlyConsumption(); int getCompleteCount(); }
PhysicalInventoryPresenter extends InventoryPresenter { protected void restoreDraftInventory() throws LMISException { List<DraftInventory> draftList = inventoryRepository.queryAllDraft(); for (DraftInventory draftInventory : draftList) { for (InventoryViewModel viewModel : inventoryViewModelList) { if (viewModel.getStockCardId() == draftInventory.getStockCard().getId()) { ((PhysicalInventoryViewModel) viewModel).setDraftInventory(draftInventory); } } } }  @Override Observable<List<InventoryViewModel>> loadInventory(); Observable<Object> saveDraftInventoryObservable(); Observable<Object> doInventory(final String sign); void updateAvgMonthlyConsumption(); int getCompleteCount();  }