Add test for storing IDs on known post replies
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 24 Feb 2019 09:50:14 +0000 (10:50 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 24 Feb 2019 09:50:14 +0000 (10:50 +0100)
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt
src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java

index 962357e..d7e84e5 100644 (file)
@@ -298,6 +298,7 @@ class MemoryDatabase @Inject constructor(private val configuration: Configuratio
                                        knownPostReplies.add(postReply.id)
                                else
                                        knownPostReplies.remove(postReply.id)
+                               saveKnownPostReplies()
                        }
 
        private fun loadKnownPosts() =
index 0d20aad..60c8c53 100644 (file)
@@ -466,4 +466,14 @@ public class MemoryDatabaseTest {
                assertThat(configuration.getStringValue("KnownPosts/1/ID").getValue(), equalTo(null));
        }
 
+       @Test
+       public void markingAPostReplyAsKnownSavesConfiguration() throws ConfigurationException {
+               prepareConfigurationValues();
+               PostReply postReply = mock(PostReply.class);
+               when(postReply.getId()).thenReturn("post-reply-id");
+               memoryDatabase.setPostReplyKnown(postReply, true);
+               assertThat(configuration.getStringValue("KnownReplies/0/ID").getValue(), equalTo("post-reply-id"));
+               assertThat(configuration.getStringValue("KnownReplies/1/ID").getValue(), equalTo(null));
+       }
+
 }