Bookmarking a post saves the database.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 4 Nov 2014 19:08:05 +0000 (20:08 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 4 Nov 2014 19:08:05 +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 34ff024..aae93dd 100644 (file)
@@ -63,6 +63,7 @@ public class MemoryBookmarkDatabase implements BookmarkDatabase {
                lock.writeLock().lock();
                try {
                        bookmarkedPosts.add(post.getId());
+                       saveBookmarkedPosts();
                } finally {
                        lock.writeLock().unlock();
                }
index 7a2fc0a..d6eae10 100644 (file)
@@ -6,6 +6,7 @@ import static org.hamcrest.Matchers.is;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -74,6 +75,15 @@ public class MemoryBookmarkDatabaseTest {
        }
 
        @Test
+       public void bookmarkingAPostSavesTheDatabase() {
+               for (Post post : posts.values()) {
+                       bookmarkDatabase.bookmarkPost(post);
+               }
+               verify(configurationLoader, times(posts.size()))
+                               .saveBookmarkedPosts(any(Set.class));
+       }
+
+       @Test
        public void removingABookmarkRemovesTheCorrectBookmark() {
                Set<Post> allPosts = new HashSet<Post>(posts.values());
                for (Post post : allPosts) {