@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionOnSaveNull() { repo.save(null); }
public void save(RegimenCategory regimenCategory) { if(regimenCategory == null) throw new NullPointerException("RegimenCategory argument is null"); try { if(regimenCategory.hasId()) mapper.update(regimenCategory); else mapper.insert(regimenCategory); } catch (DuplicateKeyException dke) { throw new DataException("error.duplicate.regimen.category", dke); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length", dive); } }
RegimenCategoryRepository { public void save(RegimenCategory regimenCategory) { if(regimenCategory == null) throw new NullPointerException("RegimenCategory argument is null"); try { if(regimenCategory.hasId()) mapper.update(regimenCategory); else mapper.insert(regimenCategory); } catch (DuplicateKeyException dke) { throw new DataException("error.duplicate.regimen.category", dke); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length", dive); } } }
RegimenCategoryRepository { public void save(RegimenCategory regimenCategory) { if(regimenCategory == null) throw new NullPointerException("RegimenCategory argument is null"); try { if(regimenCategory.hasId()) mapper.update(regimenCategory); else mapper.insert(regimenCategory); } catch (DuplicateKeyException dke) { throw new DataException("error.duplicate.regimen.category", dke); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length", dive); } } @Autowired  RegimenCategoryRepository(RegimenCategoryMapper regimenCategoryMapper); }
RegimenCategoryRepository { public void save(RegimenCategory regimenCategory) { if(regimenCategory == null) throw new NullPointerException("RegimenCategory argument is null"); try { if(regimenCategory.hasId()) mapper.update(regimenCategory); else mapper.insert(regimenCategory); } catch (DuplicateKeyException dke) { throw new DataException("error.duplicate.regimen.category", dke); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length", dive); } } @Autowired  RegimenCategoryRepository(RegimenCategoryMapper regimenCategoryMapper); List<RegimenCategory> getAll(); RegimenCategory getByCode(String code); void save(RegimenCategory regimenCategory); }
RegimenCategoryRepository { public void save(RegimenCategory regimenCategory) { if(regimenCategory == null) throw new NullPointerException("RegimenCategory argument is null"); try { if(regimenCategory.hasId()) mapper.update(regimenCategory); else mapper.insert(regimenCategory); } catch (DuplicateKeyException dke) { throw new DataException("error.duplicate.regimen.category", dke); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length", dive); } } @Autowired  RegimenCategoryRepository(RegimenCategoryMapper regimenCategoryMapper); List<RegimenCategory> getAll(); RegimenCategory getByCode(String code); void save(RegimenCategory regimenCategory);  }