@Test public void shouldValidateAndReturnNullIfGroupEmpty() throws Exception { assertThat(service.validateAndReturn(null), is(nullValue())); }
public ProductGroup validateAndReturn(ProductGroup group) { if (group == null) return null; String productGroupCode = group.getCode(); if (productGroupCode == null || productGroupCode.isEmpty()) return null; group = repository.getByCode(productGroupCode); if (group == null) throw new DataException("error.reference.data.invalid.product.group"); return group; }
ProductGroupService { public ProductGroup validateAndReturn(ProductGroup group) { if (group == null) return null; String productGroupCode = group.getCode(); if (productGroupCode == null || productGroupCode.isEmpty()) return null; group = repository.getByCode(productGroupCode); if (group == null) throw new DataException("error.reference.data.invalid.product.group"); return group; } }
ProductGroupService { public ProductGroup validateAndReturn(ProductGroup group) { if (group == null) return null; String productGroupCode = group.getCode(); if (productGroupCode == null || productGroupCode.isEmpty()) return null; group = repository.getByCode(productGroupCode); if (group == null) throw new DataException("error.reference.data.invalid.product.group"); return group; } @Autowired  ProductGroupService(ProductGroupRepository repository); }
ProductGroupService { public ProductGroup validateAndReturn(ProductGroup group) { if (group == null) return null; String productGroupCode = group.getCode(); if (productGroupCode == null || productGroupCode.isEmpty()) return null; group = repository.getByCode(productGroupCode); if (group == null) throw new DataException("error.reference.data.invalid.product.group"); return group; } @Autowired  ProductGroupService(ProductGroupRepository repository); void save(ProductGroup productGroup); ProductGroup getByCode(String code); List<ProductGroup> getAll(); ProductGroup validateAndReturn(ProductGroup group); }
ProductGroupService { public ProductGroup validateAndReturn(ProductGroup group) { if (group == null) return null; String productGroupCode = group.getCode(); if (productGroupCode == null || productGroupCode.isEmpty()) return null; group = repository.getByCode(productGroupCode); if (group == null) throw new DataException("error.reference.data.invalid.product.group"); return group; } @Autowired  ProductGroupService(ProductGroupRepository repository); void save(ProductGroup productGroup); ProductGroup getByCode(String code); List<ProductGroup> getAll(); ProductGroup validateAndReturn(ProductGroup group);  }