@Test public void fetchOrCreateJudgmentResult_FETCH() { JudgmentResult judgmentResult = new JudgmentResult(CourtType.SUPREME, "text"); when(judgmentResultRepository.findOneByCourtTypeAndTextIgnoreCase(judgmentResult.getCourtType(), judgmentResult.getText())) .thenReturn(judgmentResult); JudgmentResult retJudgmentResult = judgmentResultCreator.fetchOrCreateJudgmentResult(judgmentResult.getCourtType(), judgmentResult.getText()); assertTrue(judgmentResult == retJudgmentResult); verify(judgmentResultRepository).findOneByCourtTypeAndTextIgnoreCase(judgmentResult.getCourtType(), judgmentResult.getText()); verifyNoMoreInteractions(judgmentResultRepository); }
public JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text) { JudgmentResult judgmentResult = judgmentResultRepository.findOneByCourtTypeAndTextIgnoreCase(courtType, text); if (judgmentResult == null) { judgmentResult = new JudgmentResult(courtType, text); judgmentResultRepository.save(judgmentResult); judgmentResultRepository.flush(); } return judgmentResult; }
JudgmentResultCreator { public JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text) { JudgmentResult judgmentResult = judgmentResultRepository.findOneByCourtTypeAndTextIgnoreCase(courtType, text); if (judgmentResult == null) { judgmentResult = new JudgmentResult(courtType, text); judgmentResultRepository.save(judgmentResult); judgmentResultRepository.flush(); } return judgmentResult; } }
JudgmentResultCreator { public JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text) { JudgmentResult judgmentResult = judgmentResultRepository.findOneByCourtTypeAndTextIgnoreCase(courtType, text); if (judgmentResult == null) { judgmentResult = new JudgmentResult(courtType, text); judgmentResultRepository.save(judgmentResult); judgmentResultRepository.flush(); } return judgmentResult; }  }
JudgmentResultCreator { public JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text) { JudgmentResult judgmentResult = judgmentResultRepository.findOneByCourtTypeAndTextIgnoreCase(courtType, text); if (judgmentResult == null) { judgmentResult = new JudgmentResult(courtType, text); judgmentResultRepository.save(judgmentResult); judgmentResultRepository.flush(); } return judgmentResult; }  JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text); @Autowired void setJudgmentResultRepository(JudgmentResultRepository judgmentResultRepository); }
JudgmentResultCreator { public JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text) { JudgmentResult judgmentResult = judgmentResultRepository.findOneByCourtTypeAndTextIgnoreCase(courtType, text); if (judgmentResult == null) { judgmentResult = new JudgmentResult(courtType, text); judgmentResultRepository.save(judgmentResult); judgmentResultRepository.flush(); } return judgmentResult; }  JudgmentResult fetchOrCreateJudgmentResult(CourtType courtType, String text); @Autowired void setJudgmentResultRepository(JudgmentResultRepository judgmentResultRepository);  }