@Test public void shouldNotNotifyOnUpdateIfActiveFlagsChangeFromTFAndBecomeFF() throws Exception { String product = "product"; Long existingProgramProductId = 2L; ProgramProduct programProductForUpdate = make( a(defaultProgramProduct, with(productCode, product), with(ProgramProductBuilder.programCode, "program"), with(active, false))); programProductForUpdate.setId(existingProgramProductId); ProgramProduct existingProgramProduct = make( a(defaultProgramProduct, with(active, true), with(productActive, false))); when(programProductRepository.getById(existingProgramProductId)).thenReturn(existingProgramProduct); service.save(programProductForUpdate); verify(programService, never()).setFeedSendFlag(programProductForUpdate.getProgram(), true); }
public void save(ProgramProduct programProduct) { validateAndSetProductCategory(programProduct); if (programProduct.getId() == null) { boolean globalProductStatus = productService.isActive(programProduct.getProduct().getCode()); if (globalProductStatus && programProduct.getActive()) programService.setFeedSendFlag(programProduct.getProgram(), true); } else { ProgramProduct existingProgramProduct = programProductRepository.getById(programProduct.getId()); if (existingProgramProduct.getProduct().getActive() && (existingProgramProduct.getActive() != programProduct.getActive())) { programService.setFeedSendFlag(programProduct.getProgram(), true); } } programProductRepository.save(programProduct); }
ProgramProductService { public void save(ProgramProduct programProduct) { validateAndSetProductCategory(programProduct); if (programProduct.getId() == null) { boolean globalProductStatus = productService.isActive(programProduct.getProduct().getCode()); if (globalProductStatus && programProduct.getActive()) programService.setFeedSendFlag(programProduct.getProgram(), true); } else { ProgramProduct existingProgramProduct = programProductRepository.getById(programProduct.getId()); if (existingProgramProduct.getProduct().getActive() && (existingProgramProduct.getActive() != programProduct.getActive())) { programService.setFeedSendFlag(programProduct.getProgram(), true); } } programProductRepository.save(programProduct); } }
ProgramProductService { public void save(ProgramProduct programProduct) { validateAndSetProductCategory(programProduct); if (programProduct.getId() == null) { boolean globalProductStatus = productService.isActive(programProduct.getProduct().getCode()); if (globalProductStatus && programProduct.getActive()) programService.setFeedSendFlag(programProduct.getProgram(), true); } else { ProgramProduct existingProgramProduct = programProductRepository.getById(programProduct.getId()); if (existingProgramProduct.getProduct().getActive() && (existingProgramProduct.getActive() != programProduct.getActive())) { programService.setFeedSendFlag(programProduct.getProgram(), true); } } programProductRepository.save(programProduct); }  }
ProgramProductService { public void save(ProgramProduct programProduct) { validateAndSetProductCategory(programProduct); if (programProduct.getId() == null) { boolean globalProductStatus = productService.isActive(programProduct.getProduct().getCode()); if (globalProductStatus && programProduct.getActive()) programService.setFeedSendFlag(programProduct.getProgram(), true); } else { ProgramProduct existingProgramProduct = programProductRepository.getById(programProduct.getId()); if (existingProgramProduct.getProduct().getActive() && (existingProgramProduct.getActive() != programProduct.getActive())) { programService.setFeedSendFlag(programProduct.getProgram(), true); } } programProductRepository.save(programProduct); }  Long getIdByProgramIdAndProductId(Long programId, Long productId); void updateProgramProductPrice(ProgramProductPrice programProductPrice); void save(ProgramProduct programProduct); void saveAndLogPriceChange(ProgramProduct programProduct); ProgramProduct getByProgramAndProductCode(ProgramProduct programProduct); ProgramProductPrice getProgramProductPrice(ProgramProduct programProduct); List<ProgramProduct> getByProgram(Program program); List<ProgramProduct> getByProductCode(String productCode); List<ProgramProduct> getProgramProductsBy(String programCode, String facilityTypeCode); List<ProgramProduct> getNonFullSupplyProductsForProgram(Program program); List<ProgramProduct> getActiveByProgram(Long programId); ProgramProduct getByProgramAndProductId(Long programId, Long productId); List<ProgramProduct> search(String searchParam, Pagination pagination, String column); List<ProgramProduct> getUnapprovedProgramProducts(Long facilityTypeId, Long programId); Integer getTotalSearchResultCount(String searchParam, String column); @Transactional void saveAll(List<ProgramProduct> programProducts, Product product); void insertISA(ProgramProductISA isa); void updateISA(ProgramProductISA isa); }
ProgramProductService { public void save(ProgramProduct programProduct) { validateAndSetProductCategory(programProduct); if (programProduct.getId() == null) { boolean globalProductStatus = productService.isActive(programProduct.getProduct().getCode()); if (globalProductStatus && programProduct.getActive()) programService.setFeedSendFlag(programProduct.getProgram(), true); } else { ProgramProduct existingProgramProduct = programProductRepository.getById(programProduct.getId()); if (existingProgramProduct.getProduct().getActive() && (existingProgramProduct.getActive() != programProduct.getActive())) { programService.setFeedSendFlag(programProduct.getProgram(), true); } } programProductRepository.save(programProduct); }  Long getIdByProgramIdAndProductId(Long programId, Long productId); void updateProgramProductPrice(ProgramProductPrice programProductPrice); void save(ProgramProduct programProduct); void saveAndLogPriceChange(ProgramProduct programProduct); ProgramProduct getByProgramAndProductCode(ProgramProduct programProduct); ProgramProductPrice getProgramProductPrice(ProgramProduct programProduct); List<ProgramProduct> getByProgram(Program program); List<ProgramProduct> getByProductCode(String productCode); List<ProgramProduct> getProgramProductsBy(String programCode, String facilityTypeCode); List<ProgramProduct> getNonFullSupplyProductsForProgram(Program program); List<ProgramProduct> getActiveByProgram(Long programId); ProgramProduct getByProgramAndProductId(Long programId, Long productId); List<ProgramProduct> search(String searchParam, Pagination pagination, String column); List<ProgramProduct> getUnapprovedProgramProducts(Long facilityTypeId, Long programId); Integer getTotalSearchResultCount(String searchParam, String column); @Transactional void saveAll(List<ProgramProduct> programProducts, Product product); void insertISA(ProgramProductISA isa); void updateISA(ProgramProductISA isa);  }