From 04fbdc3d76e3b1140d178dc2600141ec92d22637 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 4 Nov 2014 20:08:16 +0100 Subject: [PATCH] Unbookmarking a post saves the database. --- .../sone/database/memory/MemoryBookmarkDatabase.java | 1 + .../sone/database/memory/MemoryBookmarkDatabaseTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java index aae93dd..38c5bd0 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java @@ -74,6 +74,7 @@ public class MemoryBookmarkDatabase implements BookmarkDatabase { lock.writeLock().lock(); try { bookmarkedPosts.remove(post.getId()); + saveBookmarkedPosts(); } finally { lock.writeLock().unlock(); } diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java index d6eae10..c5ce475 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java @@ -84,6 +84,16 @@ public class MemoryBookmarkDatabaseTest { } @Test + public void unbookmarkingAPostSavesTheDatabase() { + for (Post post : posts.values()) { + bookmarkDatabase.bookmarkPost(post); + bookmarkDatabase.unbookmarkPost(post); + } + verify(configurationLoader, times(posts.size() * 2)) + .saveBookmarkedPosts(any(Set.class)); + } + + @Test public void removingABookmarkRemovesTheCorrectBookmark() { Set allPosts = new HashSet(posts.values()); for (Post post : allPosts) { -- 2.7.4