@Test public void canIncrementDocCount() { Document doc = new Document(); final int oldCount = doc.getCount(); doAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]) .when(dao).merge(any(Document.class)); Document result = service.incrementDocRequestCount(doc); assertThat(result.getCount()).isEqualTo(oldCount + 1); verify(dao).merge(doc); }
@Transactional public Document incrementDocRequestCount(Document doc) { doc.incrementCount(); return documentDAO.merge(doc); }
DocumentService { @Transactional public Document incrementDocRequestCount(Document doc) { doc.incrementCount(); return documentDAO.merge(doc); } }
DocumentService { @Transactional public Document incrementDocRequestCount(Document doc) { doc.incrementCount(); return documentDAO.merge(doc); } @Inject  DocumentService(DocumentDAO documentDAO); @SuppressWarnings("unused")  DocumentService(); }
DocumentService { @Transactional public Document incrementDocRequestCount(Document doc) { doc.incrementCount(); return documentDAO.merge(doc); } @Inject  DocumentService(DocumentDAO documentDAO); @SuppressWarnings("unused")  DocumentService(); @Transactional Document getOrCreateByUrl(String url, Locale fromLocale, Locale toLocale); @Transactional List<Document> getByUrl(@NotNull String url,
            Optional<LocaleCode> fromLocaleCode, Optional<LocaleCode> toLocaleCode,
            Optional<DateRange> dateParam); @Transactional Document incrementDocRequestCount(Document doc); }
DocumentService { @Transactional public Document incrementDocRequestCount(Document doc) { doc.incrementCount(); return documentDAO.merge(doc); } @Inject  DocumentService(DocumentDAO documentDAO); @SuppressWarnings("unused")  DocumentService(); @Transactional Document getOrCreateByUrl(String url, Locale fromLocale, Locale toLocale); @Transactional List<Document> getByUrl(@NotNull String url,
            Optional<LocaleCode> fromLocaleCode, Optional<LocaleCode> toLocaleCode,
            Optional<DateRange> dateParam); @Transactional Document incrementDocRequestCount(Document doc);  }