From 308b94c1c75e55637644142e2553aec8d7ce01ad 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:05 +0100 Subject: [PATCH] Bookmarking 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 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) { -- 2.7.4