mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
UnitOfWork is now injectable
This commit is contained in:
@@ -1,20 +1,29 @@
|
||||
package com.commafeed.backend.dao;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.context.internal.ManagedSessionContext;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
|
||||
@Singleton
|
||||
public class UnitOfWork {
|
||||
|
||||
public static void run(SessionFactory sessionFactory, SessionRunner sessionRunner) {
|
||||
call(sessionFactory, () -> {
|
||||
private final SessionFactory sessionFactory;
|
||||
|
||||
public void run(SessionRunner sessionRunner) {
|
||||
call(() -> {
|
||||
sessionRunner.runInSession();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> T call(SessionFactory sessionFactory, SessionRunnerReturningValue<T> sessionRunner) {
|
||||
public <T> T call(SessionRunnerReturningValue<T> sessionRunner) {
|
||||
T t = null;
|
||||
|
||||
boolean sessionAlreadyBound = ManagedSessionContext.hasBind(sessionFactory);
|
||||
|
||||
@@ -16,7 +16,6 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.codahale.metrics.Gauge;
|
||||
import com.codahale.metrics.Meter;
|
||||
@@ -34,7 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Singleton
|
||||
public class FeedRefreshEngine implements Managed {
|
||||
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final FeedDAO feedDAO;
|
||||
private final FeedRefreshWorker worker;
|
||||
private final FeedRefreshUpdater updater;
|
||||
@@ -50,9 +49,9 @@ public class FeedRefreshEngine implements Managed {
|
||||
private final ThreadPoolExecutor databaseUpdaterExecutor;
|
||||
|
||||
@Inject
|
||||
public FeedRefreshEngine(SessionFactory sessionFactory, FeedDAO feedDAO, FeedRefreshWorker worker, FeedRefreshUpdater updater,
|
||||
public FeedRefreshEngine(UnitOfWork unitOfWork, FeedDAO feedDAO, FeedRefreshWorker worker, FeedRefreshUpdater updater,
|
||||
CommaFeedConfiguration config, MetricRegistry metrics) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.unitOfWork = unitOfWork;
|
||||
this.feedDAO = feedDAO;
|
||||
this.worker = worker;
|
||||
this.updater = updater;
|
||||
@@ -161,7 +160,7 @@ public class FeedRefreshEngine implements Managed {
|
||||
}
|
||||
|
||||
private List<Feed> getNextUpdatableFeeds(int max) {
|
||||
return UnitOfWork.call(sessionFactory, () -> {
|
||||
return unitOfWork.call(() -> {
|
||||
List<Feed> feeds = feedDAO.findNextUpdatable(max);
|
||||
// update disabledUntil to prevent feeds from being returned again by feedDAO.findNextUpdatable()
|
||||
Date nextUpdateDate = DateUtils.addMinutes(new Date(), config.getApplicationSettings().getRefreshIntervalMinutes());
|
||||
|
||||
@@ -15,7 +15,6 @@ import javax.inject.Singleton;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.codahale.metrics.Meter;
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
@@ -46,7 +45,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Singleton
|
||||
public class FeedRefreshUpdater implements Managed {
|
||||
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final FeedService feedService;
|
||||
private final FeedEntryService feedEntryService;
|
||||
private final PubSubService pubSubService;
|
||||
@@ -63,10 +62,10 @@ public class FeedRefreshUpdater implements Managed {
|
||||
private final Meter entryInserted;
|
||||
|
||||
@Inject
|
||||
public FeedRefreshUpdater(SessionFactory sessionFactory, FeedService feedService, FeedEntryService feedEntryService,
|
||||
public FeedRefreshUpdater(UnitOfWork unitOfWork, FeedService feedService, FeedEntryService feedEntryService,
|
||||
PubSubService pubSubService, CommaFeedConfiguration config, MetricRegistry metrics, FeedSubscriptionDAO feedSubscriptionDAO,
|
||||
CacheService cache, WebSocketSessions webSocketSessions) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.unitOfWork = unitOfWork;
|
||||
this.feedService = feedService;
|
||||
this.feedEntryService = feedEntryService;
|
||||
this.pubSubService = pubSubService;
|
||||
@@ -107,7 +106,7 @@ public class FeedRefreshUpdater implements Managed {
|
||||
locked2 = lock2.tryLock(1, TimeUnit.MINUTES);
|
||||
if (locked1 && locked2) {
|
||||
processed = true;
|
||||
inserted = UnitOfWork.call(sessionFactory, () -> feedEntryService.addEntry(feed, entry, subscriptions));
|
||||
inserted = unitOfWork.call(() -> feedEntryService.addEntry(feed, entry, subscriptions));
|
||||
if (inserted) {
|
||||
entryInserted.mark();
|
||||
}
|
||||
@@ -164,7 +163,7 @@ public class FeedRefreshUpdater implements Managed {
|
||||
if (!lastEntries.contains(cacheKey)) {
|
||||
log.debug("cache miss for {}", entry.getUrl());
|
||||
if (subscriptions == null) {
|
||||
subscriptions = UnitOfWork.call(sessionFactory, () -> feedSubscriptionDAO.findByFeed(feed));
|
||||
subscriptions = unitOfWork.call(() -> feedSubscriptionDAO.findByFeed(feed));
|
||||
}
|
||||
AddEntryResult addEntryResult = addEntry(feed, entry, subscriptions);
|
||||
processed &= addEntryResult.processed;
|
||||
@@ -204,7 +203,7 @@ public class FeedRefreshUpdater implements Managed {
|
||||
feedUpdated.mark();
|
||||
}
|
||||
|
||||
UnitOfWork.run(sessionFactory, () -> feedService.save(feed));
|
||||
unitOfWork.run(() -> feedService.save(feed));
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryContentDAO;
|
||||
import com.commafeed.backend.dao.FeedEntryDAO;
|
||||
@@ -30,7 +28,7 @@ public class DatabaseCleaningService {
|
||||
|
||||
private static final int BATCH_SIZE = 100;
|
||||
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final FeedDAO feedDAO;
|
||||
private final FeedEntryDAO feedEntryDAO;
|
||||
private final FeedEntryContentDAO feedEntryContentDAO;
|
||||
@@ -42,16 +40,16 @@ public class DatabaseCleaningService {
|
||||
int deleted = 0;
|
||||
long entriesTotal = 0;
|
||||
do {
|
||||
List<Feed> feeds = UnitOfWork.call(sessionFactory, () -> feedDAO.findWithoutSubscriptions(1));
|
||||
List<Feed> feeds = unitOfWork.call(() -> feedDAO.findWithoutSubscriptions(1));
|
||||
for (Feed feed : feeds) {
|
||||
int entriesDeleted = 0;
|
||||
do {
|
||||
entriesDeleted = UnitOfWork.call(sessionFactory, () -> feedEntryDAO.delete(feed.getId(), BATCH_SIZE));
|
||||
entriesDeleted = unitOfWork.call(() -> feedEntryDAO.delete(feed.getId(), BATCH_SIZE));
|
||||
entriesTotal += entriesDeleted;
|
||||
log.info("removed {} entries for feeds without subscriptions", entriesTotal);
|
||||
} while (entriesDeleted > 0);
|
||||
}
|
||||
deleted = UnitOfWork.call(sessionFactory, () -> feedDAO.delete(feeds));
|
||||
deleted = unitOfWork.call(() -> feedDAO.delete(feeds));
|
||||
total += deleted;
|
||||
log.info("removed {} feeds without subscriptions", total);
|
||||
} while (deleted != 0);
|
||||
@@ -64,7 +62,7 @@ public class DatabaseCleaningService {
|
||||
long total = 0;
|
||||
int deleted = 0;
|
||||
do {
|
||||
deleted = UnitOfWork.call(sessionFactory, () -> feedEntryContentDAO.deleteWithoutEntries(BATCH_SIZE));
|
||||
deleted = unitOfWork.call(() -> feedEntryContentDAO.deleteWithoutEntries(BATCH_SIZE));
|
||||
total += deleted;
|
||||
log.info("removed {} contents without entries", total);
|
||||
} while (deleted != 0);
|
||||
@@ -75,8 +73,7 @@ public class DatabaseCleaningService {
|
||||
public long cleanEntriesForFeedsExceedingCapacity(final int maxFeedCapacity) {
|
||||
long total = 0;
|
||||
while (true) {
|
||||
List<FeedCapacity> feeds = UnitOfWork.call(sessionFactory,
|
||||
() -> feedEntryDAO.findFeedsExceedingCapacity(maxFeedCapacity, BATCH_SIZE));
|
||||
List<FeedCapacity> feeds = unitOfWork.call(() -> feedEntryDAO.findFeedsExceedingCapacity(maxFeedCapacity, BATCH_SIZE));
|
||||
if (feeds.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -85,8 +82,7 @@ public class DatabaseCleaningService {
|
||||
long remaining = feed.getCapacity() - maxFeedCapacity;
|
||||
do {
|
||||
final long rem = remaining;
|
||||
int deleted = UnitOfWork.call(sessionFactory,
|
||||
() -> feedEntryDAO.deleteOldEntries(feed.getId(), Math.min(BATCH_SIZE, rem)));
|
||||
int deleted = unitOfWork.call(() -> feedEntryDAO.deleteOldEntries(feed.getId(), Math.min(BATCH_SIZE, rem)));
|
||||
total += deleted;
|
||||
remaining -= deleted;
|
||||
log.info("removed {} entries for feeds exceeding capacity", total);
|
||||
@@ -102,8 +98,7 @@ public class DatabaseCleaningService {
|
||||
long total = 0;
|
||||
int deleted = 0;
|
||||
do {
|
||||
deleted = UnitOfWork.call(sessionFactory,
|
||||
() -> feedEntryStatusDAO.delete(feedEntryStatusDAO.getOldStatuses(olderThan, BATCH_SIZE)));
|
||||
deleted = unitOfWork.call(() -> feedEntryStatusDAO.delete(feedEntryStatusDAO.getOldStatuses(olderThan, BATCH_SIZE)));
|
||||
total += deleted;
|
||||
log.info("removed {} old read statuses", total);
|
||||
} while (deleted != 0);
|
||||
|
||||
@@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Singleton
|
||||
public class DatabaseStartupService implements Managed {
|
||||
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UserDAO userDAO;
|
||||
private final UserService userService;
|
||||
@@ -35,9 +36,9 @@ public class DatabaseStartupService implements Managed {
|
||||
@Override
|
||||
public void start() {
|
||||
updateSchema();
|
||||
long count = UnitOfWork.call(sessionFactory, userDAO::count);
|
||||
long count = unitOfWork.call(userDAO::count);
|
||||
if (count == 0) {
|
||||
UnitOfWork.run(sessionFactory, this::initialData);
|
||||
unitOfWork.run(this::initialData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.HttpGetter;
|
||||
@@ -40,7 +39,7 @@ public class PubSubService {
|
||||
|
||||
private final CommaFeedConfiguration config;
|
||||
private final FeedService feedService;
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
|
||||
public void subscribe(Feed feed) {
|
||||
String hub = feed.getPushHub();
|
||||
@@ -75,7 +74,7 @@ public class PubSubService {
|
||||
if (code == 400 && StringUtils.contains(message, pushpressError)) {
|
||||
String[] tokens = message.split(" ");
|
||||
feed.setPushTopic(tokens[tokens.length - 1]);
|
||||
UnitOfWork.run(sessionFactory, () -> feedService.save(feed));
|
||||
unitOfWork.run(() -> feedService.save(feed));
|
||||
log.debug("handled pushpress subfeed {} : {}", topic, feed.getPushTopic());
|
||||
} else {
|
||||
throw new Exception(
|
||||
|
||||
@@ -6,7 +6,6 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
@@ -22,7 +21,7 @@ public class PostLoginActivities {
|
||||
|
||||
private final UserDAO userDAO;
|
||||
private final FeedSubscriptionService feedSubscriptionService;
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final CommaFeedConfiguration config;
|
||||
|
||||
public void executeFor(User user) {
|
||||
@@ -49,7 +48,7 @@ public class PostLoginActivities {
|
||||
// We update the user in a new transaction to update the user immediately.
|
||||
// If we didn't and the webservice call takes time, subsequent webservice calls would have to wait for the first call to
|
||||
// finish even if they didn't use the same database tables, because they updated the user too.
|
||||
UnitOfWork.run(sessionFactory, () -> userDAO.saveOrUpdate(user));
|
||||
unitOfWork.run(() -> userDAO.saveOrUpdate(user));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.CommaFeedApplication;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
@@ -23,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class DemoAccountCleanupTask extends ScheduledTask {
|
||||
|
||||
private final CommaFeedConfiguration config;
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final UserDAO userDAO;
|
||||
private final UserService userService;
|
||||
|
||||
@@ -34,7 +32,7 @@ public class DemoAccountCleanupTask extends ScheduledTask {
|
||||
}
|
||||
|
||||
log.info("recreating demo user account");
|
||||
UnitOfWork.run(sessionFactory, () -> {
|
||||
unitOfWork.run(() -> {
|
||||
User demoUser = userDAO.findByName(CommaFeedApplication.USERNAME_DEMO);
|
||||
if (demoUser == null) {
|
||||
return;
|
||||
|
||||
@@ -7,8 +7,6 @@ import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
import com.commafeed.backend.dao.UserSettingsDAO;
|
||||
import com.commafeed.backend.model.User;
|
||||
@@ -22,7 +20,7 @@ abstract class AbstractCustomCodeServlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final UserSettingsDAO userSettingsDAO;
|
||||
|
||||
@Override
|
||||
@@ -34,7 +32,7 @@ abstract class AbstractCustomCodeServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
UserSettings settings = UnitOfWork.call(sessionFactory, () -> userSettingsDAO.findByUser(user.get()));
|
||||
UserSettings settings = unitOfWork.call(() -> userSettingsDAO.findByUser(user.get()));
|
||||
if (settings == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ package com.commafeed.frontend.servlet;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
import com.commafeed.backend.dao.UserSettingsDAO;
|
||||
import com.commafeed.backend.model.UserSettings;
|
||||
|
||||
@@ -12,8 +11,8 @@ public class CustomCssServlet extends AbstractCustomCodeServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Inject
|
||||
public CustomCssServlet(SessionFactory sessionFactory, UserSettingsDAO userSettingsDAO) {
|
||||
super(sessionFactory, userSettingsDAO);
|
||||
public CustomCssServlet(UnitOfWork unitOfWork, UserSettingsDAO userSettingsDAO) {
|
||||
super(unitOfWork, userSettingsDAO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.commafeed.frontend.servlet;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
import com.commafeed.backend.dao.UserSettingsDAO;
|
||||
import com.commafeed.backend.model.UserSettings;
|
||||
|
||||
@@ -14,8 +13,8 @@ public class CustomJsServlet extends AbstractCustomCodeServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Inject
|
||||
public CustomJsServlet(SessionFactory sessionFactory, UserSettingsDAO userSettingsDAO) {
|
||||
super(sessionFactory, userSettingsDAO);
|
||||
public CustomJsServlet(UnitOfWork unitOfWork, UserSettingsDAO userSettingsDAO) {
|
||||
super(unitOfWork, userSettingsDAO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||
@@ -39,7 +38,7 @@ public class NextUnreadServlet extends HttpServlet {
|
||||
private static final String PARAM_CATEGORYID = "category";
|
||||
private static final String PARAM_READINGORDER = "order";
|
||||
|
||||
private final SessionFactory sessionFactory;
|
||||
private final UnitOfWork unitOfWork;
|
||||
private final FeedSubscriptionDAO feedSubscriptionDAO;
|
||||
private final FeedEntryStatusDAO feedEntryStatusDAO;
|
||||
private final FeedCategoryDAO feedCategoryDAO;
|
||||
@@ -54,7 +53,7 @@ public class NextUnreadServlet extends HttpServlet {
|
||||
SessionHelper sessionHelper = new SessionHelper(req);
|
||||
Optional<User> user = sessionHelper.getLoggedInUser();
|
||||
if (user.isPresent()) {
|
||||
UnitOfWork.run(sessionFactory, () -> userService.performPostLoginActivities(user.get()));
|
||||
unitOfWork.run(() -> userService.performPostLoginActivities(user.get()));
|
||||
}
|
||||
if (!user.isPresent()) {
|
||||
resp.sendRedirect(resp.encodeRedirectURL(config.getApplicationSettings().getPublicUrl()));
|
||||
@@ -63,7 +62,7 @@ public class NextUnreadServlet extends HttpServlet {
|
||||
|
||||
final ReadingOrder order = StringUtils.equals(orderParam, "asc") ? ReadingOrder.asc : ReadingOrder.desc;
|
||||
|
||||
FeedEntryStatus status = UnitOfWork.call(sessionFactory, () -> {
|
||||
FeedEntryStatus status = unitOfWork.call(() -> {
|
||||
FeedEntryStatus s = null;
|
||||
if (StringUtils.isBlank(categoryId) || CategoryREST.ALL.equals(categoryId)) {
|
||||
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user.get());
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.commafeed.backend.service;
|
||||
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -16,6 +15,7 @@ import org.mockserver.model.HttpResponse;
|
||||
import org.mockserver.model.MediaType;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.backend.dao.UnitOfWork;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
|
||||
@ExtendWith(MockServerExtension.class)
|
||||
@@ -28,7 +28,7 @@ class PubSubServiceTest {
|
||||
private FeedService feedService;
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private SessionFactory sessionFactory;
|
||||
private UnitOfWork unitOfWork;
|
||||
|
||||
@Mock
|
||||
private Feed feed;
|
||||
@@ -43,7 +43,7 @@ class PubSubServiceTest {
|
||||
this.client = client;
|
||||
this.client.reset();
|
||||
|
||||
this.underTest = new PubSubService(config, feedService, sessionFactory);
|
||||
this.underTest = new PubSubService(config, feedService, unitOfWork);
|
||||
|
||||
Integer port = client.getPort();
|
||||
String hubUrl = String.format("http://localhost:%s/hub", port);
|
||||
@@ -72,7 +72,7 @@ class PubSubServiceTest {
|
||||
.withMethod("POST")
|
||||
.withPath("/hub"));
|
||||
Mockito.verify(feed, Mockito.never()).setPushTopic(Mockito.anyString());
|
||||
Mockito.verifyNoInteractions(feedService);
|
||||
Mockito.verifyNoInteractions(unitOfWork);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +86,7 @@ class PubSubServiceTest {
|
||||
|
||||
// Assert
|
||||
Mockito.verify(feed).setPushTopic(Mockito.anyString());
|
||||
Mockito.verify(feedService).save(feed);
|
||||
Mockito.verify(unitOfWork).run(Mockito.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +99,7 @@ class PubSubServiceTest {
|
||||
|
||||
// Assert
|
||||
Mockito.verify(feed, Mockito.never()).setPushTopic(Mockito.anyString());
|
||||
Mockito.verifyNoInteractions(feedService);
|
||||
Mockito.verifyNoInteractions(unitOfWork);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user