reformat using google-java-format 2.0

This commit is contained in:
Athou
2026-10-30 19:39:53 +01:00
parent 8f9be28002
commit f979f5426f
23 changed files with 382 additions and 441 deletions

View File

@@ -66,8 +66,7 @@ public class HttpClientFactory {
String userAgent = String userAgent =
config.httpClient() config.httpClient()
.userAgent() .userAgent()
.orElseGet( .orElseGet(() ->
() ->
String.format( String.format(
"CommaFeed/%s (https://github.com/Athou/commafeed)", "CommaFeed/%s (https://github.com/Athou/commafeed)",
version.getVersion())); version.getVersion()));

View File

@@ -283,8 +283,7 @@ public class HttpGetter {
} }
return CacheBuilder.newBuilder() return CacheBuilder.newBuilder()
.weigher( .weigher((HttpRequest key, HttpResponse value) ->
(HttpRequest key, HttpResponse value) ->
value.content() != null ? value.content().length : 0) value.content() != null ? value.content().length : 0)
.maximumWeight(cacheConfig.maximumMemorySize().asLongValue()) .maximumWeight(cacheConfig.maximumMemorySize().asLongValue())
.expireAfterWrite(cacheConfig.expiration()) .expireAfterWrite(cacheConfig.expiration())

View File

@@ -124,10 +124,8 @@ public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> {
Set<Long> categoryIds = Set<Long> categoryIds =
categories.stream().map(AbstractModel::getId).collect(Collectors.toSet()); categories.stream().map(AbstractModel::getId).collect(Collectors.toSet());
return findAll(user).stream() return findAll(user).stream()
.filter( .filter(s ->
s -> s.getCategory() != null && categoryIds.contains(s.getCategory().getId()))
s.getCategory() != null
&& categoryIds.contains(s.getCategory().getId()))
.toList(); .toList();
} }

View File

@@ -104,17 +104,14 @@ public class FeedRefreshEngine {
private void startFeedProcessingLoop() { private void startFeedProcessingLoop() {
// take a feed from the queue, process it, rince, repeat // take a feed from the queue, process it, rince, repeat
feedProcessingLoopExecutor.submit( feedProcessingLoopExecutor.submit(() -> {
() -> {
while (!feedProcessingLoopExecutor.isShutdown()) { while (!feedProcessingLoopExecutor.isShutdown()) {
try { try {
// take() is blocking until a feed is available from the queue // take() is blocking until a feed is available from the queue
Feed feed = queue.take(); Feed feed = queue.take();
// send the feed to be processed // send the feed to be processed
log.debug( log.debug("got feed {} from the queue, send it for processing", feed.getId());
"got feed {} from the queue, send it for processing",
feed.getId());
processFeedAsync(feed); processFeedAsync(feed);
// we removed a feed from the queue, try to refill it as it may now be // we removed a feed from the queue, try to refill it as it may now be
@@ -135,8 +132,7 @@ public class FeedRefreshEngine {
private void startRefillLoop() { private void startRefillLoop() {
// refill the queue at regular intervals if it's empty // refill the queue at regular intervals if it's empty
refillLoopExecutor.submit( refillLoopExecutor.submit(() -> {
() -> {
while (!refillLoopExecutor.isShutdown()) { while (!refillLoopExecutor.isShutdown()) {
try { try {
if (queue.isEmpty()) { if (queue.isEmpty()) {
@@ -184,8 +180,7 @@ public class FeedRefreshEngine {
} }
}, },
refillExecutor) refillExecutor)
.whenComplete( .whenComplete((data, ex) -> {
(data, ex) -> {
if (ex != null) { if (ex != null) {
log.error("error while refilling the queue", ex); log.error("error while refilling the queue", ex);
} }
@@ -195,49 +190,38 @@ public class FeedRefreshEngine {
private void processFeedAsync(Feed feed) { private void processFeedAsync(Feed feed) {
CompletableFuture.supplyAsync(() -> worker.update(feed), workerExecutor) CompletableFuture.supplyAsync(() -> worker.update(feed), workerExecutor)
.thenApplyAsync(r -> updater.update(r.feed(), r.entries()), databaseUpdaterExecutor) .thenApplyAsync(r -> updater.update(r.feed(), r.entries()), databaseUpdaterExecutor)
.thenCompose( .thenCompose(r -> {
r -> {
List<CompletableFuture<Void>> futures = List<CompletableFuture<Void>> futures =
r.insertedUnreadEntriesBySubscription().entrySet().stream() r.insertedUnreadEntriesBySubscription().entrySet().stream()
.map( .map(e -> {
e -> {
FeedSubscription sub = e.getKey(); FeedSubscription sub = e.getKey();
List<FeedEntry> entries = e.getValue(); List<FeedEntry> entries = e.getValue();
notifier.notifyOverWebsocket(sub, entries); notifier.notifyOverWebsocket(sub, entries);
return CompletableFuture.runAsync( return CompletableFuture.runAsync(
() -> () -> notifier.sendPushNotifications(sub, entries),
notifier
.sendPushNotifications(
sub,
entries),
notifierExecutor); notifierExecutor);
}) })
.toList(); .toList();
return CompletableFuture.allOf( return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
futures.toArray(CompletableFuture[]::new));
}) })
.exceptionally( .exceptionally(ex -> {
ex -> {
log.error("error while processing feed {}", feed.getUrl(), ex); log.error("error while processing feed {}", feed.getUrl(), ex);
return null; return null;
}); });
} }
private List<Feed> getNextUpdatableFeeds(int max) { private List<Feed> getNextUpdatableFeeds(int max) {
return unitOfWork.call( return unitOfWork.call(() -> {
() -> {
Instant lastLoginThreshold = Instant lastLoginThreshold =
config.feedRefresh().userInactivityPeriod().isZero() config.feedRefresh().userInactivityPeriod().isZero()
? null ? null
: Instant.now() : Instant.now().minus(config.feedRefresh().userInactivityPeriod());
.minus(config.feedRefresh().userInactivityPeriod());
List<Feed> feeds = feedDAO.findNextUpdatable(max, lastLoginThreshold); List<Feed> feeds = feedDAO.findNextUpdatable(max, lastLoginThreshold);
if (!feeds.isEmpty()) { if (!feeds.isEmpty()) {
// update disabledUntil to prevent feeds from being returned again by // update disabledUntil to prevent feeds from being returned again by
// feedDAO.findNextUpdatable() // feedDAO.findNextUpdatable()
Instant nextUpdateDate = Instant nextUpdateDate = Instant.now().plus(config.feedRefresh().interval());
Instant.now().plus(config.feedRefresh().interval());
feedDAO.setDisabledUntil( feedDAO.setDisabledUntil(
feeds.stream().map(AbstractModel::getId).toList(), nextUpdateDate); feeds.stream().map(AbstractModel::getId).toList(), nextUpdateDate);
} }
@@ -292,8 +276,7 @@ public class FeedRefreshEngine {
ThreadPoolExecutor pool = ThreadPoolExecutor pool =
new ThreadPoolExecutor( new ThreadPoolExecutor(
threads, threads, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>()); threads, threads, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>());
pool.setRejectedExecutionHandler( pool.setRejectedExecutionHandler((r, e) -> {
(r, e) -> {
if (e.isShutdown()) { if (e.isShutdown()) {
return; return;
} }

View File

@@ -91,8 +91,7 @@ public class FeedRefreshUpdater {
if (locked1 && locked2) { if (locked1 && locked2) {
processed = true; processed = true;
insertedEntry = insertedEntry =
unitOfWork.call( unitOfWork.call(() -> {
() -> {
if (feedEntryService.find(feed, entry) != null) { if (feedEntryService.find(feed, entry) != null) {
// entry already exists, nothing to do // entry already exists, nothing to do
return null; return null;
@@ -101,8 +100,7 @@ public class FeedRefreshUpdater {
FeedEntry feedEntry = feedEntryService.create(feed, entry); FeedEntry feedEntry = feedEntryService.create(feed, entry);
entryInserted.mark(); entryInserted.mark();
for (FeedSubscription sub : subscriptions) { for (FeedSubscription sub : subscriptions) {
boolean unread = boolean unread = feedEntryService.applyFilter(sub, feedEntry);
feedEntryService.applyFilter(sub, feedEntry);
if (unread) { if (unread) {
subscriptionsForWhichEntryIsUnread.add(sub); subscriptionsForWhichEntryIsUnread.add(sub);
} }
@@ -147,8 +145,7 @@ public class FeedRefreshUpdater {
AddEntryResult addEntryResult = addEntry(feed, entry, subscriptions); AddEntryResult addEntryResult = addEntry(feed, entry, subscriptions);
processed &= addEntryResult.processed; processed &= addEntryResult.processed;
inserted += addEntryResult.insertedEntry != null ? 1 : 0; inserted += addEntryResult.insertedEntry != null ? 1 : 0;
addEntryResult.subscriptionsForWhichEntryIsUnread.forEach( addEntryResult.subscriptionsForWhichEntryIsUnread.forEach(sub -> {
sub -> {
if (addEntryResult.insertedEntry != null) { if (addEntryResult.insertedEntry != null) {
insertedUnreadEntriesBySubscription insertedUnreadEntriesBySubscription
.computeIfAbsent(sub, k -> new ArrayList<>()) .computeIfAbsent(sub, k -> new ArrayList<>())

View File

@@ -65,18 +65,15 @@ public class OPMLExporter {
for (FeedCategory child : for (FeedCategory child :
categories.stream() categories.stream()
.filter( .filter(c ->
c -> c.getParent() != null && c.getParent().getId().equals(cat.getId()))
c.getParent() != null
&& c.getParent().getId().equals(cat.getId()))
.toList()) { .toList()) {
outline.getChildren().add(buildCategoryOutline(child, categories, subscriptions)); outline.getChildren().add(buildCategoryOutline(child, categories, subscriptions));
} }
for (FeedSubscription sub : for (FeedSubscription sub :
subscriptions.stream() subscriptions.stream()
.filter( .filter(s ->
s ->
s.getCategory() != null s.getCategory() != null
&& s.getCategory().getId().equals(cat.getId())) && s.getCategory().getId().equals(cat.getId()))
.toList()) { .toList()) {

View File

@@ -148,15 +148,13 @@ public class FeedEntryService {
List<FeedEntryStatus> statusesToMark = List<FeedEntryStatus> statusesToMark =
statuses.stream() statuses.stream()
.filter(FeedEntryStatus::isMarkable) .filter(FeedEntryStatus::isMarkable)
.filter( .filter(s -> {
s -> {
Instant entryDate = s.getEntry().getPublished(); Instant entryDate = s.getEntry().getPublished();
return olderThan == null return olderThan == null
|| entryDate == null || entryDate == null
|| entryDate.isBefore(olderThan); || entryDate.isBefore(olderThan);
}) })
.filter( .filter(s -> {
s -> {
Instant insertedDate = s.getEntry().getInserted(); Instant insertedDate = s.getEntry().getInserted();
return insertedBefore == null return insertedBefore == null
|| insertedDate == null || insertedDate == null
@@ -164,8 +162,7 @@ public class FeedEntryService {
}) })
.toList(); .toList();
statusesToMark.forEach( statusesToMark.forEach(s -> {
s -> {
s.setRead(true); s.setRead(true);
feedEntryStatusDAO.merge(s); feedEntryStatusDAO.merge(s);
}); });

View File

@@ -47,8 +47,7 @@ public class FeedSubscriptionService {
// we need to use this hook because the feed needs to have been persisted before being // we need to use this hook because the feed needs to have been persisted before being
// processed // processed
// by the feed engine // by the feed engine
feedSubscriptionDAO.onPostCommitInsert( feedSubscriptionDAO.onPostCommitInsert(sub -> {
sub -> {
Feed feed = sub.getFeed(); Feed feed = sub.getFeed();
if (feed.getDisabledUntil() == null if (feed.getDisabledUntil() == null
|| feed.getDisabledUntil().isBefore(Instant.now())) { || feed.getDisabledUntil().isBefore(Instant.now())) {

View File

@@ -79,13 +79,10 @@ public class DatabaseCleaningService {
} while (entriesDeleted > 0); } while (entriesDeleted > 0);
} }
deleted = deleted =
unitOfWork.call( unitOfWork.call(() ->
() ->
feedDAO.delete( feedDAO.delete(
feedDAO.findByIds( feedDAO.findByIds(
feeds.stream() feeds.stream().map(AbstractModel::getId).toList())));
.map(AbstractModel::getId)
.toList())));
total += deleted; total += deleted;
log.debug("removed {} feeds without subscriptions", total); log.debug("removed {} feeds without subscriptions", total);
} while (deleted != 0); } while (deleted != 0);
@@ -119,8 +116,7 @@ public class DatabaseCleaningService {
} }
List<FeedCapacity> feeds = List<FeedCapacity> feeds =
unitOfWork.call( unitOfWork.call(() ->
() ->
feedEntryDAO.findFeedsExceedingCapacity( feedEntryDAO.findFeedsExceedingCapacity(
maxFeedCapacity, batchSize, keepStarredEntries)); maxFeedCapacity, batchSize, keepStarredEntries));
if (feeds.isEmpty()) { if (feeds.isEmpty()) {
@@ -139,8 +135,7 @@ public class DatabaseCleaningService {
final long rem = remaining; final long rem = remaining;
deleted = deleted =
unitOfWork.call( unitOfWork.call(() ->
() ->
feedEntryDAO.deleteOldEntries( feedEntryDAO.deleteOldEntries(
feed.id(), feed.id(),
Math.min(batchSize, rem), Math.min(batchSize, rem),
@@ -166,8 +161,7 @@ public class DatabaseCleaningService {
} }
deleted = deleted =
unitOfWork.call( unitOfWork.call(() ->
() ->
feedEntryDAO.deleteEntriesOlderThan( feedEntryDAO.deleteEntriesOlderThan(
olderThan, batchSize, keepStarredEntries)); olderThan, batchSize, keepStarredEntries));
entriesDeletedMeter.mark(deleted); entriesDeletedMeter.mark(deleted);

View File

@@ -31,8 +31,7 @@ public class DemoAccountCleanupTask extends ScheduledTask {
} }
log.info("recreating demo user account"); log.info("recreating demo user account");
unitOfWork.run( unitOfWork.run(() -> {
() -> {
User demoUser = userDAO.findByName(CommaFeedConstants.USERNAME_DEMO); User demoUser = userDAO.findByName(CommaFeedConstants.USERNAME_DEMO);
if (demoUser == null) { if (demoUser == null) {
return; return;

View File

@@ -140,14 +140,9 @@ public class FeverREST {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.getFirst())); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.getFirst()));
form.getValues() form.getValues()
.forEach( .forEach((k, v) ->
(k, v) ->
params.put( params.put(
k, k, v.stream().map(FormValue::getValue).findFirst().orElse(null)));
v.stream()
.map(FormValue::getValue)
.findFirst()
.orElse(null)));
return handle(userId, params); return handle(userId, params);
} }
@@ -246,12 +241,10 @@ public class FeverREST {
s -> s.getCategory() == null ? 0 : s.getCategory().getId())) s -> s.getCategory() == null ? 0 : s.getCategory().getId()))
.entrySet() .entrySet()
.stream() .stream()
.map( .map(e -> {
e -> {
FeverFeedGroup fg = new FeverFeedGroup(); FeverFeedGroup fg = new FeverFeedGroup();
fg.setGroupId(e.getKey()); fg.setGroupId(e.getKey());
fg.setFeedIds( fg.setFeedIds(e.getValue().stream().map(FeedSubscription::getId).toList());
e.getValue().stream().map(FeedSubscription::getId).toList());
return fg; return fg;
}) })
.toList(); .toList();
@@ -259,8 +252,7 @@ public class FeverREST {
private List<FeverGroup> buildGroups(List<FeedCategory> categories) { private List<FeverGroup> buildGroups(List<FeedCategory> categories) {
return categories.stream() return categories.stream()
.map( .map(c -> {
c -> {
FeverGroup g = new FeverGroup(); FeverGroup g = new FeverGroup();
g.setId(c.getId()); g.setId(c.getId());
g.setTitle(c.getName()); g.setTitle(c.getName());
@@ -271,8 +263,7 @@ public class FeverREST {
private List<FeverFeed> buildFeeds(List<FeedSubscription> subscriptions) { private List<FeverFeed> buildFeeds(List<FeedSubscription> subscriptions) {
return subscriptions.stream() return subscriptions.stream()
.map( .map(s -> {
s -> {
FeverFeed f = new FeverFeed(); FeverFeed f = new FeverFeed();
f.setId(s.getId()); f.setId(s.getId());
f.setFaviconId(s.getId()); f.setFaviconId(s.getId());
@@ -367,8 +358,7 @@ public class FeverREST {
private List<FeverFavicon> buildFavicons(List<FeedSubscription> subscriptions) { private List<FeverFavicon> buildFavicons(List<FeedSubscription> subscriptions) {
return subscriptions.stream() return subscriptions.stream()
.map( .map(s -> {
s -> {
Favicon favicon = feedFaviconService.fetchFavicon(s.getFeed()); Favicon favicon = feedFaviconService.fetchFavicon(s.getFeed());
FeverFavicon f = new FeverFavicon(); FeverFavicon f = new FeverFavicon();

View File

@@ -216,8 +216,7 @@ public class GoogleReaderREST {
List<GoogleReaderModel.Tag> tags = new ArrayList<>(); List<GoogleReaderModel.Tag> tags = new ArrayList<>();
feedCategoryDAO feedCategoryDAO
.findAll(user) .findAll(user)
.forEach( .forEach(c ->
c ->
tags.add( tags.add(
new GoogleReaderModel.Tag( new GoogleReaderModel.Tag(
GoogleReaderStreamId.label(c.getName())))); GoogleReaderStreamId.label(c.getName()))));
@@ -259,8 +258,7 @@ public class GoogleReaderREST {
Map<Long, FeedCategory> categoriesById = Map<Long, FeedCategory> categoriesById =
feedCategoryDAO.findAll(user).stream() feedCategoryDAO.findAll(user).stream()
.collect(Collectors.toMap(FeedCategory::getId, c -> c)); .collect(Collectors.toMap(FeedCategory::getId, c -> c));
unreadByCategory.forEach( unreadByCategory.forEach((categoryId, count) -> {
(categoryId, count) -> {
if (categoryId == 0) { if (categoryId == 0) {
return; return;
} }
@@ -268,8 +266,7 @@ public class GoogleReaderREST {
if (category == null) { if (category == null) {
return; return;
} }
GoogleReaderModel.UnreadCountEntry entry = GoogleReaderModel.UnreadCountEntry entry = new GoogleReaderModel.UnreadCountEntry();
new GoogleReaderModel.UnreadCountEntry();
entry.setId(GoogleReaderStreamId.label(category.getName())); entry.setId(GoogleReaderStreamId.label(category.getName()));
entry.setCount(count); entry.setCount(count);
entries.add(entry); entries.add(entry);
@@ -334,10 +331,8 @@ public class GoogleReaderREST {
GoogleReaderModel.ItemRefs resp = new GoogleReaderModel.ItemRefs(); GoogleReaderModel.ItemRefs resp = new GoogleReaderModel.ItemRefs();
resp.setItemRefs( resp.setItemRefs(
paged.statuses().stream() paged.statuses().stream()
.map( .map(s ->
s -> new GoogleReaderModel.ItemRef(String.valueOf(s.getEntry().getId())))
new GoogleReaderModel.ItemRef(
String.valueOf(s.getEntry().getId())))
.toList()); .toList());
resp.setContinuation(paged.continuation()); resp.setContinuation(paged.continuation());
return resp; return resp;

View File

@@ -38,13 +38,11 @@ public class DatabaseApiKeyIdentityProvider
@Override @Override
public Uni<SecurityIdentity> authenticate( public Uni<SecurityIdentity> authenticate(
TokenAuthenticationRequest request, AuthenticationRequestContext context) { TokenAuthenticationRequest request, AuthenticationRequestContext context) {
return context.runBlocking( return context.runBlocking(() -> {
() -> {
Optional<User> user = Optional<User> user =
unitOfWork.call(() -> userService.login(request.getToken().getToken())); unitOfWork.call(() -> userService.login(request.getToken().getToken()));
if (user.isEmpty()) { if (user.isEmpty()) {
throw new AuthenticationFailedException( throw new AuthenticationFailedException("could not find a user with this api key");
"could not find a user with this api key");
} }
Set<Role> roles = unitOfWork.call(() -> userService.getRoles(user.get())); Set<Role> roles = unitOfWork.call(() -> userService.getRoles(user.get()));

View File

@@ -39,15 +39,12 @@ public class DatabaseUsernamePasswordIdentityProvider
@Override @Override
public Uni<SecurityIdentity> authenticate( public Uni<SecurityIdentity> authenticate(
UsernamePasswordAuthenticationRequest request, AuthenticationRequestContext context) { UsernamePasswordAuthenticationRequest request, AuthenticationRequestContext context) {
return context.runBlocking( return context.runBlocking(() -> {
() -> {
Optional<User> user = Optional<User> user =
unitOfWork.call( unitOfWork.call(() ->
() ->
userService.login( userService.login(
request.getUsername(), request.getUsername(),
new String( new String(request.getPassword().getPassword())));
request.getPassword().getPassword())));
if (user.isEmpty()) { if (user.isEmpty()) {
throw new CommaFeedApplicationException( throw new CommaFeedApplicationException(
CommaFeedExceptionType.WRONG_USERNAME_OR_PASSWORD); CommaFeedExceptionType.WRONG_USERNAME_OR_PASSWORD);

View File

@@ -40,8 +40,7 @@ public class TrustedIdentityProvider implements IdentityProvider<TrustedAuthenti
@Override @Override
public Uni<SecurityIdentity> authenticate( public Uni<SecurityIdentity> authenticate(
TrustedAuthenticationRequest request, AuthenticationRequestContext context) { TrustedAuthenticationRequest request, AuthenticationRequestContext context) {
return context.runBlocking( return context.runBlocking(() -> {
() -> {
Long userId = Long.valueOf(request.getPrincipal()); Long userId = Long.valueOf(request.getPrincipal());
User user = unitOfWork.call(() -> userDAO.findById(userId)); User user = unitOfWork.call(() -> userDAO.findById(userId));
if (user == null) { if (user == null) {

View File

@@ -41,8 +41,7 @@ class NativeImageClassesTest {
WireFeedGenerator.class)) { WireFeedGenerator.class)) {
Set<Class<?>> moduleClasses = Set<Class<?>> moduleClasses =
new HashSet<>(reflections.get(Scanners.SubTypes.of(clazz).asClass())); new HashSet<>(reflections.get(Scanners.SubTypes.of(clazz).asClass()));
moduleClasses.removeIf( moduleClasses.removeIf(c ->
c ->
c.isInterface() c.isInterface()
|| Modifier.isAbstract(c.getModifiers()) || Modifier.isAbstract(c.getModifiers())
|| !Modifier.isPublic(c.getModifiers())); || !Modifier.isPublic(c.getModifiers()));

View File

@@ -317,8 +317,7 @@ class HttpGetterTest {
this.mockServerClient this.mockServerClient
.when(HttpRequest.request().withMethod("GET")) .when(HttpRequest.request().withMethod("GET"))
.respond( .respond(req -> {
req -> {
calls.incrementAndGet(); calls.incrementAndGet();
if (req.containsHeader(HttpHeaders.COOKIE)) { if (req.containsHeader(HttpHeaders.COOKIE)) {
@@ -341,8 +340,7 @@ class HttpGetterTest {
this.mockServerClient this.mockServerClient
.when(HttpRequest.request().withMethod("GET")) .when(HttpRequest.request().withMethod("GET"))
.respond( .respond(req -> {
req -> {
calls.incrementAndGet(); calls.incrementAndGet();
return HttpResponse.response().withBody("ok"); return HttpResponse.response().withBody("ok");
}); });
@@ -400,13 +398,11 @@ class HttpGetterTest {
this.mockServerClient this.mockServerClient
.when(HttpRequest.request().withMethod("GET")) .when(HttpRequest.request().withMethod("GET"))
.respond( .respond(req -> {
req -> {
calls.incrementAndGet(); calls.incrementAndGet();
if (req.containsHeader(HttpHeaders.UPGRADE)) { if (req.containsHeader(HttpHeaders.UPGRADE)) {
throw new Exception( throw new Exception("upgrade header should not be sent by the client");
"upgrade header should not be sent by the client");
} }
return HttpResponse.response().withBody("ok"); return HttpResponse.response().withBody("ok");
@@ -438,17 +434,14 @@ class HttpGetterTest {
HttpGetterTest.this HttpGetterTest.this
.mockServerClient .mockServerClient
.when(HttpRequest.request().withMethod("GET")) .when(HttpRequest.request().withMethod("GET"))
.respond( .respond(req -> {
req -> {
try { try {
String acceptEncodingHeader = String acceptEncodingHeader =
req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING); req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING);
if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) { if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) {
throw new Exception( throw new Exception(
"Wrong value in the Accept-Encoding header, should be '%s' but was '%s'" "Wrong value in the Accept-Encoding header, should be '%s' but was '%s'"
.formatted( .formatted(ACCEPT_ENCODING, acceptEncodingHeader));
ACCEPT_ENCODING,
acceptEncodingHeader));
} }
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();

View File

@@ -68,7 +68,8 @@ class YoutubeFaviconFetcherTest {
byte[] apiResponse = byte[] apiResponse =
""" """
{"items":[{"snippet":{"thumbnails":{"default":{"url":"https://example.com/icon.png"}}}}]}""" {"items":[{"snippet":{"thumbnails":{"default":{"url":"https://example.com/icon.png"}}}}]}\
"""
.getBytes(); .getBytes();
HttpResult apiHttpResult = HttpResult apiHttpResult =
new HttpResult(apiResponse, "application/json", null, null, null, Duration.ZERO); new HttpResult(apiResponse, "application/json", null, null, null, Duration.ZERO);
@@ -102,7 +103,8 @@ class YoutubeFaviconFetcherTest {
byte[] apiResponse = byte[] apiResponse =
""" """
{"items":[{"snippet":{"thumbnails":{"default":{"url":"https://example.com/icon.png"}}}}]}""" {"items":[{"snippet":{"thumbnails":{"default":{"url":"https://example.com/icon.png"}}}}]}\
"""
.getBytes(); .getBytes();
HttpResult apiHttpResult = HttpResult apiHttpResult =
new HttpResult(apiResponse, "application/json", null, null, null, Duration.ZERO); new HttpResult(apiResponse, "application/json", null, null, null, Duration.ZERO);
@@ -136,7 +138,8 @@ class YoutubeFaviconFetcherTest {
byte[] playlistResponse = byte[] playlistResponse =
""" """
{"items":[{"snippet":{"channelId":"testChannelId"}}]}""" {"items":[{"snippet":{"channelId":"testChannelId"}}]}\
"""
.getBytes(); .getBytes();
HttpResult playlistHttpResult = HttpResult playlistHttpResult =
new HttpResult( new HttpResult(
@@ -151,7 +154,8 @@ class YoutubeFaviconFetcherTest {
byte[] channelResponse = byte[] channelResponse =
""" """
{"items":[{"snippet":{"thumbnails":{"default":{"url":"https://example.com/icon.png"}}}}]}""" {"items":[{"snippet":{"thumbnails":{"default":{"url":"https://example.com/icon.png"}}}}]}\
"""
.getBytes(); .getBytes();
HttpResult channelHttpResult = HttpResult channelHttpResult =
new HttpResult( new HttpResult(

View File

@@ -229,11 +229,13 @@ class XMLCleanerTest {
<!DOCTYPE <!DOCTYPE
html html
> >
<html><head></head><body></body></html>"""; <html><head></head><body></body></html>\
""";
Assertions.assertEquals( Assertions.assertEquals(
""" """
<html><head></head><body></body></html>""", <html><head></head><body></body></html>\
""",
xmlCleaner.removeDoctypeDeclarations(source)); xmlCleaner.removeDoctypeDeclarations(source));
} }

View File

@@ -21,7 +21,8 @@ class InPageReferenceFeedURLProviderTest {
</head> </head>
<body> <body>
</body> </body>
</html>"""; </html>\
""";
Assertions.assertIterableEquals( Assertions.assertIterableEquals(
List.of("http://example.com/feed.atom", "http://example.com/feed.rss"), List.of("http://example.com/feed.atom", "http://example.com/feed.rss"),
@@ -35,7 +36,8 @@ class InPageReferenceFeedURLProviderTest {
""" """
<?xml version="1.0"?> <?xml version="1.0"?>
<feed></feed> <feed></feed>
</xml>"""; </xml>\
""";
Assertions.assertTrue(provider.get(url, html).isEmpty()); Assertions.assertTrue(provider.get(url, html).isEmpty());
} }
@@ -51,7 +53,8 @@ class InPageReferenceFeedURLProviderTest {
</head> </head>
<body> <body>
</body> </body>
</html>"""; </html>\
""";
Assertions.assertTrue(provider.get(url, html).isEmpty()); Assertions.assertTrue(provider.get(url, html).isEmpty());
} }

View File

@@ -170,8 +170,7 @@ class GoogleReaderIT extends BaseIT {
client.get(BASE + "/reader/api/0/unread-count").as(UnreadCounts.class); client.get(BASE + "/reader/api/0/unread-count").as(UnreadCounts.class);
Assertions.assertTrue( Assertions.assertTrue(
counts.getUnreadCounts().stream() counts.getUnreadCounts().stream()
.anyMatch( .anyMatch(c ->
c ->
c.getId().equals("user/-/state/com.google/reading-list") c.getId().equals("user/-/state/com.google/reading-list")
&& c.getCount() == 2)); && c.getCount() == 2));
} }