diff --git a/src/test/java/swiss/fihlon/apus/plugin/social/bluesky/DefaultBlueSkyLoaderTest.java b/src/test/java/swiss/fihlon/apus/plugin/social/bluesky/DefaultBlueSkyLoaderTest.java new file mode 100644 index 0000000..1850827 --- /dev/null +++ b/src/test/java/swiss/fihlon/apus/plugin/social/bluesky/DefaultBlueSkyLoaderTest.java @@ -0,0 +1,51 @@ +/* + * Apus - A social wall for conferences with additional features. + * Copyright (C) Marcus Fihlon and the individual contributors to Apus. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package swiss.fihlon.apus.plugin.social.bluesky; + +import org.json.JSONArray; +import org.junit.jupiter.api.Test; +import social.bigbone.api.entity.Status; +import swiss.fihlon.apus.plugin.social.mastodon.DefaultMastodonLoader; +import swiss.fihlon.apus.plugin.social.mastodon.MastodonException; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class DefaultBlueSkyLoaderTest { + + @Test + void getPosts() throws BlueSkyException { + final JSONArray jsonPosts = new DefaultBlueSkyLoader() + .getPosts("public.api.bsky.app", "java", "https://%s/xrpc/app.bsky.feed.searchPosts?q=%s"); + assertNotNull(jsonPosts); + assertFalse(jsonPosts.isEmpty()); + } + + @Test + void throwException() { + final var exception = assertThrows(BlueSkyException.class, + () -> new DefaultBlueSkyLoader() + .getPosts("non.existent.server", "java", "https://%s/xrpc/app.bsky.feed.searchPosts?q=%s")); + assertEquals("Unable to load posts with hashtag 'java' from BlueSky instance 'non.existent.server'", exception.getMessage()); + } + +}