From: David ‘Bombe’ Roden Date: Tue, 4 Nov 2014 19:08:05 +0000 (+0100) Subject: Bookmarking a post saves the database. X-Git-Tag: 0.9-rc1^2~3^2~44 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=308b94c1c75e55637644142e2553aec8d7ce01ad;p=Sone.git Bookmarking 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 34ff024..aae93dd 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java @@ -63,6 +63,7 @@ public class MemoryBookmarkDatabase implements BookmarkDatabase { lock.writeLock().lock(); try { bookmarkedPosts.add(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 7a2fc0a..d6eae10 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java @@ -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 allPosts = new HashSet(posts.values()); for (Post post : allPosts) {