X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdatabase%2Fmemory%2FConfigurationLoaderTest.java;h=47e26b7a70a31aed5be44b547b645b8bc1f29d9c;hp=55b66eec5a8b437796e5a2f9ed6911ff02db3de2;hb=1a3f2a00bb5180470db1515e646615dff2744e39;hpb=2524f4d47c56874a263f9e53ec5c4035f2baa7e0 diff --git a/src/test/java/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.java b/src/test/java/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.java index 55b66ee..47e26b7 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.java @@ -13,6 +13,7 @@ import java.util.Set; import net.pterodactylus.sone.TestValue; import net.pterodactylus.util.config.Configuration; import net.pterodactylus.util.config.ConfigurationException; +import net.pterodactylus.util.config.Value; import org.junit.Test; @@ -30,11 +31,11 @@ public class ConfigurationLoaderTest { @Test public void loaderCanLoadKnownPosts() { when(configuration.getStringValue("KnownPosts/0/ID")) - .thenReturn(new TestValue("Post2")); + .thenReturn(TestValue.from("Post2")); when(configuration.getStringValue("KnownPosts/1/ID")) - .thenReturn(new TestValue("Post1")); + .thenReturn(TestValue.from("Post1")); when(configuration.getStringValue("KnownPosts/2/ID")) - .thenReturn(new TestValue(null)); + .thenReturn(TestValue.from(null)); Set knownPosts = configurationLoader.loadKnownPosts(); assertThat(knownPosts, containsInAnyOrder("Post1", "Post2")); } @@ -42,11 +43,11 @@ public class ConfigurationLoaderTest { @Test public void loaderCanLoadKnownPostReplies() { when(configuration.getStringValue("KnownReplies/0/ID")) - .thenReturn(new TestValue("PostReply2")); + .thenReturn(TestValue.from("PostReply2")); when(configuration.getStringValue("KnownReplies/1/ID")) - .thenReturn(new TestValue("PostReply1")); + .thenReturn(TestValue.from("PostReply1")); when(configuration.getStringValue("KnownReplies/2/ID")) - .thenReturn(new TestValue(null)); + .thenReturn(TestValue.from(null)); Set knownPosts = configurationLoader.loadKnownPostReplies(); assertThat(knownPosts, containsInAnyOrder("PostReply1", "PostReply2")); @@ -55,31 +56,27 @@ public class ConfigurationLoaderTest { @Test public void loaderCanLoadBookmarkedPosts() { when(configuration.getStringValue("Bookmarks/Post/0/ID")) - .thenReturn(new TestValue("Post2")); + .thenReturn(TestValue.from("Post2")); when(configuration.getStringValue("Bookmarks/Post/1/ID")) - .thenReturn(new TestValue("Post1")); + .thenReturn(TestValue.from("Post1")); when(configuration.getStringValue("Bookmarks/Post/2/ID")) - .thenReturn(new TestValue(null)); + .thenReturn(TestValue.from(null)); Set knownPosts = configurationLoader.loadBookmarkedPosts(); assertThat(knownPosts, containsInAnyOrder("Post1", "Post2")); } @Test public void loaderCanSaveBookmarkedPosts() throws ConfigurationException { - final TestValue post1 = new TestValue(null); - final TestValue post2 = new TestValue(null); - final TestValue post3 = new TestValue(null); - when(configuration.getStringValue("Bookmarks/Post/0/ID")) - .thenReturn(post1); - when(configuration.getStringValue("Bookmarks/Post/1/ID")) - .thenReturn(post2); - when(configuration.getStringValue("Bookmarks/Post/2/ID")) - .thenReturn(post3); - HashSet originalPosts = - new HashSet(asList("Post1", "Post2")); + final Value post1 = TestValue.from(null); + final Value post2 = TestValue.from(null); + final Value post3 = TestValue.from(null); + when(configuration.getStringValue("Bookmarks/Post/0/ID")).thenReturn(post1); + when(configuration.getStringValue("Bookmarks/Post/1/ID")).thenReturn(post2); + when(configuration.getStringValue("Bookmarks/Post/2/ID")).thenReturn(post3); + HashSet originalPosts = new HashSet(asList("Post1", "Post2")); configurationLoader.saveBookmarkedPosts(originalPosts); - HashSet extractedPosts = new HashSet( - asList(post1.getValue(), post2.getValue())); + HashSet extractedPosts = + new HashSet(asList(post1.getValue(), post2.getValue())); assertThat(extractedPosts, containsInAnyOrder("Post1", "Post2")); assertThat(post3.getValue(), nullValue()); }