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

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

View File

@@ -317,18 +317,17 @@ class HttpGetterTest {
this.mockServerClient
.when(HttpRequest.request().withMethod("GET"))
.respond(
req -> {
calls.incrementAndGet();
.respond(req -> {
calls.incrementAndGet();
if (req.containsHeader(HttpHeaders.COOKIE)) {
throw new Exception("cookie should not be sent by the client");
}
if (req.containsHeader(HttpHeaders.COOKIE)) {
throw new Exception("cookie should not be sent by the client");
}
return HttpResponse.response()
.withBody("ok")
.withHeader(HttpHeaders.SET_COOKIE, "foo=bar");
});
return HttpResponse.response()
.withBody("ok")
.withHeader(HttpHeaders.SET_COOKIE, "foo=bar");
});
Assertions.assertDoesNotThrow(() -> getter.get(this.feedUrl));
Assertions.assertDoesNotThrow(() -> getter.get(this.feedUrl + "?foo=bar"));
@@ -341,11 +340,10 @@ class HttpGetterTest {
this.mockServerClient
.when(HttpRequest.request().withMethod("GET"))
.respond(
req -> {
calls.incrementAndGet();
return HttpResponse.response().withBody("ok");
});
.respond(req -> {
calls.incrementAndGet();
return HttpResponse.response().withBody("ok");
});
HttpResult result = getter.get(this.feedUrl);
Assertions.assertEquals(result, getter.get(this.feedUrl));
@@ -400,17 +398,15 @@ class HttpGetterTest {
this.mockServerClient
.when(HttpRequest.request().withMethod("GET"))
.respond(
req -> {
calls.incrementAndGet();
.respond(req -> {
calls.incrementAndGet();
if (req.containsHeader(HttpHeaders.UPGRADE)) {
throw new Exception(
"upgrade header should not be sent by the client");
}
if (req.containsHeader(HttpHeaders.UPGRADE)) {
throw new Exception("upgrade header should not be sent by the client");
}
return HttpResponse.response().withBody("ok");
});
return HttpResponse.response().withBody("ok");
});
Assertions.assertDoesNotThrow(() -> getter.get(this.feedUrl));
Assertions.assertEquals(1, calls.get());
@@ -438,33 +434,30 @@ class HttpGetterTest {
HttpGetterTest.this
.mockServerClient
.when(HttpRequest.request().withMethod("GET"))
.respond(
req -> {
try {
String acceptEncodingHeader =
req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING);
if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) {
throw new Exception(
"Wrong value in the Accept-Encoding header, should be '%s' but was '%s'"
.formatted(
ACCEPT_ENCODING,
acceptEncodingHeader));
}
.respond(req -> {
try {
String acceptEncodingHeader =
req.getFirstHeader(HttpHeaders.ACCEPT_ENCODING);
if (!ACCEPT_ENCODING.equals(acceptEncodingHeader)) {
throw new Exception(
"Wrong value in the Accept-Encoding header, should be '%s' but was '%s'"
.formatted(ACCEPT_ENCODING, acceptEncodingHeader));
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (OutputStream compressionOutputStream =
compressionFunction.apply(output)) {
compressionOutputStream.write(body.getBytes());
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (OutputStream compressionOutputStream =
compressionFunction.apply(output)) {
compressionOutputStream.write(body.getBytes());
}
return HttpResponse.response()
.withBody(output.toByteArray())
.withHeader(HttpHeaders.CONTENT_ENCODING, encoding);
} catch (Exception e) {
log.error("Error in compression callback", e);
throw e;
}
});
return HttpResponse.response()
.withBody(output.toByteArray())
.withHeader(HttpHeaders.CONTENT_ENCODING, encoding);
} catch (Exception e) {
log.error("Error in compression callback", e);
throw e;
}
});
HttpResult result = getter.get(HttpGetterTest.this.feedUrl);
Assertions.assertEquals(body, new String(result.content()));

View File

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

View File

@@ -226,14 +226,16 @@ class XMLCleanerTest {
void testRemoveMultilineDoctype() {
String source =
"""
<!DOCTYPE
html
>
<html><head></head><body></body></html>""";
<!DOCTYPE
html
>
<html><head></head><body></body></html>\
""";
Assertions.assertEquals(
"""
<html><head></head><body></body></html>""",
<html><head></head><body></body></html>\
""",
xmlCleaner.removeDoctypeDeclarations(source));
}

View File

@@ -12,23 +12,23 @@ class FeedEntryContentCleaningServiceTest {
void testClean() {
String content =
"""
<p>
Some text
<img width="965" height="320" src="https://localhost/an-image.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="alt-desc" decoding="async" sizes="(max-width: 965px) 100vw, 965px" style="width: 100%; opacity: 0">
<iframe src="https://localhost/an-iframe" style="width: 100%; opacity: 0"></iframe>
<forbidden-element>aaa</forbidden-element>
""";
<p>
Some text
<img width="965" height="320" src="https://localhost/an-image.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="alt-desc" decoding="async" sizes="(max-width: 965px) 100vw, 965px" style="width: 100%; opacity: 0">
<iframe src="https://localhost/an-iframe" style="width: 100%; opacity: 0"></iframe>
<forbidden-element>aaa</forbidden-element>
""";
String result = feedEntryContentCleaningService.clean(content, "baseUri", false);
Assertions.assertLinesMatch(
"""
<p>
Some text
<img width="965" height="320" src="https://localhost/an-image.png" alt="alt-desc" style="width:100%;">
<iframe src="https://localhost/an-iframe" style="width:100%;"></iframe>
aaa
</p>
"""
<p>
Some text
<img width="965" height="320" src="https://localhost/an-image.png" alt="alt-desc" style="width:100%;">
<iframe src="https://localhost/an-iframe" style="width:100%;"></iframe>
aaa
</p>
"""
.lines(),
result.lines());
}

View File

@@ -98,19 +98,19 @@ class PushNotificationServiceTest {
.withBody(
JsonBody.json(
"""
{
"title": "Test Feed",
"message": "Test Entry",
"priority": 5,
"extras": {
"client::notification": {
"click": {
"url": "http://example.com/entry"
}
}
}
}
""")))
{
"title": "Test Feed",
"message": "Test Entry",
"priority": 5,
"extras": {
"client::notification": {
"click": {
"url": "http://example.com/entry"
}
}
}
}
""")))
.respond(HttpResponse.response().withStatusCode(200));
Assertions.assertDoesNotThrow(

View File

@@ -14,14 +14,15 @@ class InPageReferenceFeedURLProviderTest {
String url = "http://example.com";
String html =
"""
<html>
<head>
<link type="application/atom+xml" href="/feed.atom">
<link type="application/rss+xml" href="/feed.rss">
</head>
<body>
</body>
</html>""";
<html>
<head>
<link type="application/atom+xml" href="/feed.atom">
<link type="application/rss+xml" href="/feed.rss">
</head>
<body>
</body>
</html>\
""";
Assertions.assertIterableEquals(
List.of("http://example.com/feed.atom", "http://example.com/feed.rss"),
@@ -33,9 +34,10 @@ class InPageReferenceFeedURLProviderTest {
String url = "http://example.com";
String html =
"""
<?xml version="1.0"?>
<feed></feed>
</xml>""";
<?xml version="1.0"?>
<feed></feed>
</xml>\
""";
Assertions.assertTrue(provider.get(url, html).isEmpty());
}
@@ -45,13 +47,14 @@ class InPageReferenceFeedURLProviderTest {
String url = "http://example.com";
String html =
"""
<html>
<head>
<link type="text/css" href="/style.css">
</head>
<body>
</body>
</html>""";
<html>
<head>
<link type="text/css" href="/style.css">
</head>
<body>
</body>
</html>\
""";
Assertions.assertTrue(provider.get(url, html).isEmpty());
}

View File

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