@Test public void shouldThrowDataExceptionIfReportWithSameNameAlreadyExists() throws Exception { ReportRight reportRight = new ReportRight(); doThrow(DataIntegrityViolationException.class).when(reportRightMapper).insert(reportRight); expectedException.expect(DataException.class); expectedException.expectMessage("report.template.name.already.exists"); reportRightRepository.insert(reportRight); }
public void insert(ReportRight reportRight) { try { mapper.insert(reportRight); } catch (DataIntegrityViolationException integrityViolationException) { throw new DataException("report.template.name.already.exists"); } }
ReportRightRepository { public void insert(ReportRight reportRight) { try { mapper.insert(reportRight); } catch (DataIntegrityViolationException integrityViolationException) { throw new DataException("report.template.name.already.exists"); } } }
ReportRightRepository { public void insert(ReportRight reportRight) { try { mapper.insert(reportRight); } catch (DataIntegrityViolationException integrityViolationException) { throw new DataException("report.template.name.already.exists"); } }  }
ReportRightRepository { public void insert(ReportRight reportRight) { try { mapper.insert(reportRight); } catch (DataIntegrityViolationException integrityViolationException) { throw new DataException("report.template.name.already.exists"); } }  void insert(ReportRight reportRight); }
ReportRightRepository { public void insert(ReportRight reportRight) { try { mapper.insert(reportRight); } catch (DataIntegrityViolationException integrityViolationException) { throw new DataException("report.template.name.already.exists"); } }  void insert(ReportRight reportRight);  }