@Test public void shouldNotNotifyIfActiveFlagsChangeFromFFtoFT() throws Exception { String productCode = "P1"; Product product = new Product(); product.setActive(true); product.setCode(productCode); product.setId(2L); product.setPackSize(5); when(productGroupService.validateAndReturn(product.getProductGroup())).thenReturn(null); when(productFormService.validateAndReturn(product.getForm())).thenReturn(null); final ProgramProduct existingProgramProduct = make(a(defaultProgramProduct, with(active, false), with(productActive, false))); when(programProductService.getByProductCode(productCode)).thenReturn(asList(existingProgramProduct)); service.save(product); verify(programService, never()).setFeedSendFlag(any(Program.class), anyBoolean()); verify(productGroupService).validateAndReturn(null); verify(productFormService).validateAndReturn(null); }
@Transactional public void save(Product product) { product.validate(); ProductGroup productGroup = productGroupService.validateAndReturn(product.getProductGroup()); product.setProductGroup(productGroup); ProductForm productForm = productFormService.validateAndReturn(product.getForm()); product.setForm(productForm); DosageUnit dosageUnit = validateAndReturnDosageUnit(product.getDosageUnit()); product.setDosageUnit(dosageUnit); if (product.getId() == null) { repository.insert(product); return; } List<ProgramProduct> existingProgramProducts = programProductService.getByProductCode(product.getCode()); repository.update(product); notifyProgramCatalogChange(product, existingProgramProducts); }
ProductService { @Transactional public void save(Product product) { product.validate(); ProductGroup productGroup = productGroupService.validateAndReturn(product.getProductGroup()); product.setProductGroup(productGroup); ProductForm productForm = productFormService.validateAndReturn(product.getForm()); product.setForm(productForm); DosageUnit dosageUnit = validateAndReturnDosageUnit(product.getDosageUnit()); product.setDosageUnit(dosageUnit); if (product.getId() == null) { repository.insert(product); return; } List<ProgramProduct> existingProgramProducts = programProductService.getByProductCode(product.getCode()); repository.update(product); notifyProgramCatalogChange(product, existingProgramProducts); } }
ProductService { @Transactional public void save(Product product) { product.validate(); ProductGroup productGroup = productGroupService.validateAndReturn(product.getProductGroup()); product.setProductGroup(productGroup); ProductForm productForm = productFormService.validateAndReturn(product.getForm()); product.setForm(productForm); DosageUnit dosageUnit = validateAndReturnDosageUnit(product.getDosageUnit()); product.setDosageUnit(dosageUnit); if (product.getId() == null) { repository.insert(product); return; } List<ProgramProduct> existingProgramProducts = programProductService.getByProductCode(product.getCode()); repository.update(product); notifyProgramCatalogChange(product, existingProgramProducts); }  }
ProductService { @Transactional public void save(Product product) { product.validate(); ProductGroup productGroup = productGroupService.validateAndReturn(product.getProductGroup()); product.setProductGroup(productGroup); ProductForm productForm = productFormService.validateAndReturn(product.getForm()); product.setForm(productForm); DosageUnit dosageUnit = validateAndReturnDosageUnit(product.getDosageUnit()); product.setDosageUnit(dosageUnit); if (product.getId() == null) { repository.insert(product); return; } List<ProgramProduct> existingProgramProducts = programProductService.getByProductCode(product.getCode()); repository.update(product); notifyProgramCatalogChange(product, existingProgramProducts); }  @Transactional void save(Product product); Long getIdForCode(String code); Product getByCode(String code); boolean isActive(String code); Integer getTotalSearchResultCount(String searchParam); List<DosageUnit> getAllDosageUnits(); Product getById(Long id); }
ProductService { @Transactional public void save(Product product) { product.validate(); ProductGroup productGroup = productGroupService.validateAndReturn(product.getProductGroup()); product.setProductGroup(productGroup); ProductForm productForm = productFormService.validateAndReturn(product.getForm()); product.setForm(productForm); DosageUnit dosageUnit = validateAndReturnDosageUnit(product.getDosageUnit()); product.setDosageUnit(dosageUnit); if (product.getId() == null) { repository.insert(product); return; } List<ProgramProduct> existingProgramProducts = programProductService.getByProductCode(product.getCode()); repository.update(product); notifyProgramCatalogChange(product, existingProgramProducts); }  @Transactional void save(Product product); Long getIdForCode(String code); Product getByCode(String code); boolean isActive(String code); Integer getTotalSearchResultCount(String searchParam); List<DosageUnit> getAllDosageUnits(); Product getById(Long id);  }