### Question:
LawJournalEntryCreator { public LawJournalEntry getOrCreateLawJournalEntry(LawJournalEntryData entryData) { LawJournalEntry lawJournalEntry = lawJournalEntryRepository.findOneByYearAndEntry(entryData.getYear(), entryData.getEntry()); if (lawJournalEntry == null) { lawJournalEntry = new LawJournalEntry(entryData.getYear(), entryData.getJournalNo(), entryData.getEntry(), entryData.getTitle()); lawJournalEntryRepository.save(lawJournalEntry); lawJournalEntryRepository.flush(); } return lawJournalEntry; }  LawJournalEntry getOrCreateLawJournalEntry(LawJournalEntryData entryData); @Autowired void setLawJournalEntryRepository(LawJournalEntryRepository lawJournalEntryRepository);  }### Answer:
@Test public void testGetOrCreateLawJournalEntry_Get() { LawJournalEntryData entryData = new LawJournalEntryData(lawJournalEntry.getYear(), lawJournalEntry.getJournalNo(), lawJournalEntry.getEntry(), "Tiisiss"); LawJournalEntry foundLawJournalEntry = lawJournalEntryCreator.getOrCreateLawJournalEntry(entryData); verify(lawJournalEntryRepository, never()).save(Mockito.any(LawJournalEntry.class)); assertEquals(lawJournalEntry, foundLawJournalEntry); assertTrue(lawJournalEntry == foundLawJournalEntry); }
@Test public void testGetOrCreateLawJournalEntry_Create() { int entry = lawJournalEntry.getEntry() + 2; String title = "Tiiiis"; LawJournalEntryData entryData = new LawJournalEntryData(lawJournalEntry.getYear(), lawJournalEntry.getJournalNo(), entry, title); LawJournalEntry foundLawJournalEntry = lawJournalEntryCreator.getOrCreateLawJournalEntry(entryData); verify(lawJournalEntryRepository).save(Mockito.any(LawJournalEntry.class)); verify(lawJournalEntryRepository).findOneByYearAndEntry(lawJournalEntry.getYear(), entry); assertEquals(title, foundLawJournalEntry.getTitle()); assertEquals(lawJournalEntry.getYear(), foundLawJournalEntry.getYear()); assertEquals(lawJournalEntry.getJournalNo(), foundLawJournalEntry.getJournalNo()); assertEquals(entry, foundLawJournalEntry.getEntry()); assertFalse(lawJournalEntry == foundLawJournalEntry); }