@Test(expected=NullPointerException.class) public void shouldThrowNullPointerExceptionOnSaveWithNull() { repo.save(null); }
public void save(FacilityOperator facilityOperator) { if(facilityOperator == null) throw new NullPointerException("facilityOperator argument is null"); try { if(facilityOperator.hasId()) facilityOperatorMapper.update(facilityOperator); else facilityOperatorMapper.insert(facilityOperator); } catch(DuplicateKeyException dke) { throw new DataException("error.duplicate.facility.operator.code"); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length"); } }
FacilityOperatorRepository { public void save(FacilityOperator facilityOperator) { if(facilityOperator == null) throw new NullPointerException("facilityOperator argument is null"); try { if(facilityOperator.hasId()) facilityOperatorMapper.update(facilityOperator); else facilityOperatorMapper.insert(facilityOperator); } catch(DuplicateKeyException dke) { throw new DataException("error.duplicate.facility.operator.code"); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length"); } } }
FacilityOperatorRepository { public void save(FacilityOperator facilityOperator) { if(facilityOperator == null) throw new NullPointerException("facilityOperator argument is null"); try { if(facilityOperator.hasId()) facilityOperatorMapper.update(facilityOperator); else facilityOperatorMapper.insert(facilityOperator); } catch(DuplicateKeyException dke) { throw new DataException("error.duplicate.facility.operator.code"); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length"); } } @Autowired  FacilityOperatorRepository(FacilityOperatorMapper facilityOperatorMapper); }
FacilityOperatorRepository { public void save(FacilityOperator facilityOperator) { if(facilityOperator == null) throw new NullPointerException("facilityOperator argument is null"); try { if(facilityOperator.hasId()) facilityOperatorMapper.update(facilityOperator); else facilityOperatorMapper.insert(facilityOperator); } catch(DuplicateKeyException dke) { throw new DataException("error.duplicate.facility.operator.code"); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length"); } } @Autowired  FacilityOperatorRepository(FacilityOperatorMapper facilityOperatorMapper); FacilityOperator getByCode(String code); void save(FacilityOperator facilityOperator); FacilityOperator getById(long id); List<FacilityOperator> getAll(); }
FacilityOperatorRepository { public void save(FacilityOperator facilityOperator) { if(facilityOperator == null) throw new NullPointerException("facilityOperator argument is null"); try { if(facilityOperator.hasId()) facilityOperatorMapper.update(facilityOperator); else facilityOperatorMapper.insert(facilityOperator); } catch(DuplicateKeyException dke) { throw new DataException("error.duplicate.facility.operator.code"); } catch(DataIntegrityViolationException dive) { throw new DataException("error.incorrect.length"); } } @Autowired  FacilityOperatorRepository(FacilityOperatorMapper facilityOperatorMapper); FacilityOperator getByCode(String code); void save(FacilityOperator facilityOperator); FacilityOperator getById(long id); List<FacilityOperator> getAll();  }