@Test public void shouldNotUpdateBannerWhenExistingProductIsNull() throws Exception { Product product = new Product(); when(productRepository.getByCode(anyString())).thenReturn(null); syncDownManager.updateDeactivateProductNotifyList(product); verify(stockRepository, times(0)).queryStockCardByProductId(anyLong()); }
protected void updateDeactivateProductNotifyList(Product product) throws LMISException { Product existingProduct = productRepository.getByCode(product.getCode()); if (existingProduct == null) { return; } if (product.isActive() == existingProduct.isActive()) { return; } if (product.isActive()) { sharedPreferenceMgr.removeShowUpdateBannerTextWhenReactiveProduct(existingProduct.getPrimaryName()); return; } StockCard stockCard = stockRepository.queryStockCardByProductId(existingProduct.getId()); if (stockCard == null) { return; } if (stockCard.getProduct().isArchived()) { return; } if (stockCard.getStockOnHand() == 0) { sharedPreferenceMgr.setIsNeedShowProductsUpdateBanner(true, product.getPrimaryName()); } }
SyncDownManager { protected void updateDeactivateProductNotifyList(Product product) throws LMISException { Product existingProduct = productRepository.getByCode(product.getCode()); if (existingProduct == null) { return; } if (product.isActive() == existingProduct.isActive()) { return; } if (product.isActive()) { sharedPreferenceMgr.removeShowUpdateBannerTextWhenReactiveProduct(existingProduct.getPrimaryName()); return; } StockCard stockCard = stockRepository.queryStockCardByProductId(existingProduct.getId()); if (stockCard == null) { return; } if (stockCard.getProduct().isArchived()) { return; } if (stockCard.getStockOnHand() == 0) { sharedPreferenceMgr.setIsNeedShowProductsUpdateBanner(true, product.getPrimaryName()); } } }
SyncDownManager { protected void updateDeactivateProductNotifyList(Product product) throws LMISException { Product existingProduct = productRepository.getByCode(product.getCode()); if (existingProduct == null) { return; } if (product.isActive() == existingProduct.isActive()) { return; } if (product.isActive()) { sharedPreferenceMgr.removeShowUpdateBannerTextWhenReactiveProduct(existingProduct.getPrimaryName()); return; } StockCard stockCard = stockRepository.queryStockCardByProductId(existingProduct.getId()); if (stockCard == null) { return; } if (stockCard.getProduct().isArchived()) { return; } if (stockCard.getStockOnHand() == 0) { sharedPreferenceMgr.setIsNeedShowProductsUpdateBanner(true, product.getPrimaryName()); } } SyncDownManager(); }
SyncDownManager { protected void updateDeactivateProductNotifyList(Product product) throws LMISException { Product existingProduct = productRepository.getByCode(product.getCode()); if (existingProduct == null) { return; } if (product.isActive() == existingProduct.isActive()) { return; } if (product.isActive()) { sharedPreferenceMgr.removeShowUpdateBannerTextWhenReactiveProduct(existingProduct.getPrimaryName()); return; } StockCard stockCard = stockRepository.queryStockCardByProductId(existingProduct.getId()); if (stockCard == null) { return; } if (stockCard.getProduct().isArchived()) { return; } if (stockCard.getStockOnHand() == 0) { sharedPreferenceMgr.setIsNeedShowProductsUpdateBanner(true, product.getPrimaryName()); } } SyncDownManager(); void syncDownServerData(Subscriber<SyncProgress> subscriber); void syncDownServerData(); void fetchKitChangeProduct(); Observable<Void> saveStockCardsFromLastYear(final List<StockCard> stockCards); Observable<Void> saveStockCards(final List<StockCard> stockCards, Scheduler scheduler); }
SyncDownManager { protected void updateDeactivateProductNotifyList(Product product) throws LMISException { Product existingProduct = productRepository.getByCode(product.getCode()); if (existingProduct == null) { return; } if (product.isActive() == existingProduct.isActive()) { return; } if (product.isActive()) { sharedPreferenceMgr.removeShowUpdateBannerTextWhenReactiveProduct(existingProduct.getPrimaryName()); return; } StockCard stockCard = stockRepository.queryStockCardByProductId(existingProduct.getId()); if (stockCard == null) { return; } if (stockCard.getProduct().isArchived()) { return; } if (stockCard.getStockOnHand() == 0) { sharedPreferenceMgr.setIsNeedShowProductsUpdateBanner(true, product.getPrimaryName()); } } SyncDownManager(); void syncDownServerData(Subscriber<SyncProgress> subscriber); void syncDownServerData(); void fetchKitChangeProduct(); Observable<Void> saveStockCardsFromLastYear(final List<StockCard> stockCards); Observable<Void> saveStockCards(final List<StockCard> stockCards, Scheduler scheduler);  }