@Test public void getOrCreateJudgmentKeyword_Get() { String phrase = keyword.getPhrase(); CourtType courtType = CourtType.COMMON; JudgmentKeyword foundKeyword = keywordCreator.getOrCreateJudgmentKeyword(courtType, phrase); verify(judgmentKeywordRepository, never()).save(Mockito.any(JudgmentKeyword.class)); verify(judgmentKeywordRepository).findOneByCourtTypeAndPhraseIgnoreCase(courtType, phrase); assertEquals(phrase, foundKeyword.getPhrase()); assertTrue(foundKeyword == keyword); }
public JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase) { JudgmentKeyword keyword = judgmentKeywordRepository.findOneByCourtTypeAndPhraseIgnoreCase(courtType, phrase); if (keyword == null) { keyword = new JudgmentKeyword(courtType, phrase); judgmentKeywordRepository.save(keyword); judgmentKeywordRepository.flush(); } return keyword; }
JudgmentKeywordCreator { public JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase) { JudgmentKeyword keyword = judgmentKeywordRepository.findOneByCourtTypeAndPhraseIgnoreCase(courtType, phrase); if (keyword == null) { keyword = new JudgmentKeyword(courtType, phrase); judgmentKeywordRepository.save(keyword); judgmentKeywordRepository.flush(); } return keyword; } }
JudgmentKeywordCreator { public JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase) { JudgmentKeyword keyword = judgmentKeywordRepository.findOneByCourtTypeAndPhraseIgnoreCase(courtType, phrase); if (keyword == null) { keyword = new JudgmentKeyword(courtType, phrase); judgmentKeywordRepository.save(keyword); judgmentKeywordRepository.flush(); } return keyword; }  }
JudgmentKeywordCreator { public JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase) { JudgmentKeyword keyword = judgmentKeywordRepository.findOneByCourtTypeAndPhraseIgnoreCase(courtType, phrase); if (keyword == null) { keyword = new JudgmentKeyword(courtType, phrase); judgmentKeywordRepository.save(keyword); judgmentKeywordRepository.flush(); } return keyword; }  JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase); @Autowired void setJudgmentKeywordRepository(JudgmentKeywordRepository judgmentKeywordRepository); }
JudgmentKeywordCreator { public JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase) { JudgmentKeyword keyword = judgmentKeywordRepository.findOneByCourtTypeAndPhraseIgnoreCase(courtType, phrase); if (keyword == null) { keyword = new JudgmentKeyword(courtType, phrase); judgmentKeywordRepository.save(keyword); judgmentKeywordRepository.flush(); } return keyword; }  JudgmentKeyword getOrCreateJudgmentKeyword(CourtType courtType, String phrase); @Autowired void setJudgmentKeywordRepository(JudgmentKeywordRepository judgmentKeywordRepository);  }