Unbookmarking a post saves the database.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 4 Nov 2014 19:08:16 +0000 (20:08 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 4 Nov 2014 19:08:16 +0000 (20:08 +0100)
src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java
src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java

index aae93dd..38c5bd0 100644 (file)
@@ -74,6 +74,7 @@ public class MemoryBookmarkDatabase implements BookmarkDatabase {
                lock.writeLock().lock();
                try {
                        bookmarkedPosts.remove(post.getId());
+                       saveBookmarkedPosts();
                } finally {
                        lock.writeLock().unlock();
                }
index d6eae10..c5ce475 100644 (file)
@@ -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<Post> allPosts = new HashSet<Post>(posts.values());
                for (Post post : allPosts) {