mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add even more integration tests
This commit is contained in:
@@ -32,6 +32,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Singleton
|
||||
public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
|
||||
private static final String PART_SNIPPET = "snippet";
|
||||
|
||||
private static final JsonPointer CHANNEL_THUMBNAIL_URL = JsonPointer.compile("/items/0/snippet/thumbnails/default/url");
|
||||
private static final JsonPointer PLAYLIST_CHANNEL_ID = JsonPointer.compile("/items/0/snippet/channelId");
|
||||
|
||||
@@ -86,7 +88,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
bytes = iconResult.getContent();
|
||||
contentType = iconResult.getContentType();
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to retrieve YouTube icon", e);
|
||||
log.debug("Failed to retrieve YouTube icon", e);
|
||||
}
|
||||
|
||||
if (!isValidIconResponse(bytes, contentType)) {
|
||||
@@ -98,7 +100,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
private byte[] fetchForUser(String googleAuthKey, String userId)
|
||||
throws IOException, NotModifiedException, TooManyRequestsException, HostNotAllowedException, SchemeNotAllowedException {
|
||||
URI uri = UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels")
|
||||
.queryParam("part", "snippet")
|
||||
.queryParam("part", PART_SNIPPET)
|
||||
.queryParam("key", googleAuthKey)
|
||||
.queryParam("forUsername", userId)
|
||||
.build();
|
||||
@@ -108,7 +110,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
private byte[] fetchForChannel(String googleAuthKey, String channelId)
|
||||
throws IOException, NotModifiedException, TooManyRequestsException, HostNotAllowedException, SchemeNotAllowedException {
|
||||
URI uri = UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels")
|
||||
.queryParam("part", "snippet")
|
||||
.queryParam("part", PART_SNIPPET)
|
||||
.queryParam("key", googleAuthKey)
|
||||
.queryParam("id", channelId)
|
||||
.build();
|
||||
@@ -118,7 +120,7 @@ public class YoutubeFaviconFetcher extends AbstractFaviconFetcher {
|
||||
private byte[] fetchForPlaylist(String googleAuthKey, String playlistId)
|
||||
throws IOException, NotModifiedException, TooManyRequestsException, HostNotAllowedException, SchemeNotAllowedException {
|
||||
URI uri = UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/playlists")
|
||||
.queryParam("part", "snippet")
|
||||
.queryParam("part", PART_SNIPPET)
|
||||
.queryParam("key", googleAuthKey)
|
||||
.queryParam("id", playlistId)
|
||||
.build();
|
||||
|
||||
@@ -26,10 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class FeedUtils {
|
||||
|
||||
public static String truncate(String string, int length) {
|
||||
if (string != null) {
|
||||
string = string.substring(0, Math.min(length, string.length()));
|
||||
}
|
||||
return string;
|
||||
return StringUtils.truncate(string, length);
|
||||
}
|
||||
|
||||
public static boolean isRTL(String title, String content) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import jakarta.persistence.Table;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
|
||||
import com.commafeed.backend.feed.FeedUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -99,15 +98,4 @@ public class FeedEntryContent extends AbstractModel {
|
||||
.append(mediaThumbnailHeight, c.mediaThumbnailHeight)
|
||||
.build();
|
||||
}
|
||||
|
||||
public boolean isRTL() {
|
||||
if (direction == Direction.RTL) {
|
||||
return true;
|
||||
} else if (direction == Direction.LTR) {
|
||||
return false;
|
||||
} else {
|
||||
// detect on the fly for content that was inserted before the direction field was added
|
||||
return FeedUtils.isRTL(title, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class Entry implements Serializable {
|
||||
entry.setTags(status.getTags().stream().map(FeedEntryTag::getName).toList());
|
||||
|
||||
if (content != null) {
|
||||
entry.setRtl(content.isRTL());
|
||||
entry.setRtl(content.getDirection() == FeedEntryContent.Direction.RTL);
|
||||
entry.setTitle(content.getTitle());
|
||||
entry.setContent(proxyImages ? FeedUtils.proxyImages(content.getContent()) : content.getContent());
|
||||
entry.setAuthor(content.getAuthor());
|
||||
|
||||
@@ -80,7 +80,7 @@ public class AdminREST {
|
||||
roles.add(Role.ADMIN);
|
||||
}
|
||||
try {
|
||||
userService.register(req.getName(), req.getPassword(), req.getEmail(), roles, true);
|
||||
id = userService.register(req.getName(), req.getPassword(), req.getEmail(), roles, true).getId();
|
||||
} catch (Exception e) {
|
||||
return Response.status(Status.CONFLICT).entity(e.getMessage()).build();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class AdminREST {
|
||||
}
|
||||
|
||||
}
|
||||
return Response.ok().build();
|
||||
return Response.ok(id).build();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.commafeed.tools;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -8,6 +11,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
|
||||
import io.quarkus.annotation.processor.Outputs;
|
||||
@@ -31,16 +36,22 @@ public class CommaFeedPropertiesGenerator {
|
||||
private final List<String> lines = new ArrayList<>();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new CommaFeedPropertiesGenerator().generate(args);
|
||||
}
|
||||
|
||||
private void generate(String[] args) throws IOException {
|
||||
Path targetPath = Paths.get(args[0]);
|
||||
|
||||
ResolvedModel resolvedModel = JacksonMappers.yamlObjectReader()
|
||||
.readValue(targetPath.resolve(Outputs.QUARKUS_CONFIG_DOC_MODEL).toFile(), ResolvedModel.class);
|
||||
JavadocElements javadocElements = JacksonMappers.yamlObjectReader()
|
||||
.readValue(targetPath.resolve(Outputs.QUARKUS_CONFIG_DOC_JAVADOC).toFile(), JavadocElements.class);
|
||||
Path modelPath = targetPath.resolve(Outputs.QUARKUS_CONFIG_DOC_MODEL);
|
||||
Path javadocPath = targetPath.resolve(Outputs.QUARKUS_CONFIG_DOC_JAVADOC);
|
||||
Path outputPath = targetPath.resolve("quarkus-generated-doc").resolve("application.properties");
|
||||
|
||||
try (InputStream model = Files.newInputStream(modelPath);
|
||||
InputStream javadoc = Files.newInputStream(javadocPath);
|
||||
OutputStream output = Files.newOutputStream(outputPath)) {
|
||||
new CommaFeedPropertiesGenerator().generate(model, javadoc, output);
|
||||
}
|
||||
}
|
||||
|
||||
void generate(InputStream model, InputStream javadoc, OutputStream output) throws IOException {
|
||||
ResolvedModel resolvedModel = JacksonMappers.yamlObjectReader().readValue(model, ResolvedModel.class);
|
||||
JavadocElements javadocElements = JacksonMappers.yamlObjectReader().readValue(javadoc, JavadocElements.class);
|
||||
|
||||
for (ConfigRoot configRoot : resolvedModel.getConfigRoots()) {
|
||||
for (AbstractConfigItem item : configRoot.getItems()) {
|
||||
@@ -48,7 +59,7 @@ public class CommaFeedPropertiesGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
Files.writeString(targetPath.resolve("quarkus-generated-doc").resolve("application.properties"), String.join("\n", lines));
|
||||
IOUtils.write(String.join("\n", lines), output, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private void handleAbstractConfigItem(AbstractConfigItem item, JavadocElements javadocElements) {
|
||||
|
||||
Reference in New Issue
Block a user