From: David ‘Bombe’ Roden Date: Tue, 4 Nov 2014 19:08:16 +0000 (+0100) Subject: Unbookmarking a post saves the database. X-Git-Tag: 0.9-rc1^2~3^2~43 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=04fbdc3d76e3b1140d178dc2600141ec92d22637;p=Sone.git Unbookmarking a post saves the database. --- 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) {