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=8dfce3dfe426258ea455a1864da45cba36742173;hp=55b66eec5a8b437796e5a2f9ed6911ff02db3de2;hb=a6ced7a625540c5ac78568281d56afc4deb65d39;hpb=723de3522aa5c04634932f05bf4075304979c7a9 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..8dfce3d 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/ConfigurationLoaderTest.java @@ -10,9 +10,10 @@ import static org.mockito.Mockito.when; import java.util.HashSet; import java.util.Set; -import net.pterodactylus.sone.TestValue; +import net.pterodactylus.sone.test.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()); }