From b798049da3b4d4a58d5ff12314bc1022808171bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 24 Feb 2019 10:50:14 +0100 Subject: [PATCH] Add test for storing IDs on known post replies --- .../net/pterodactylus/sone/database/memory/MemoryDatabase.kt | 1 + .../pterodactylus/sone/database/memory/MemoryDatabaseTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt index 962357e..d7e84e5 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.kt @@ -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() = diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java index 0d20aad..60c8c53 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java @@ -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)); + } + } -- 2.7.4