Add methods to mock a post.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 27 Oct 2013 21:15:18 +0000 (22:15 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:47 +0000 (22:25 +0100)
src/test/java/net/pterodactylus/sone/data/Mocks.java

index 34b25f3..a1c1a71 100644 (file)
@@ -52,6 +52,7 @@ public class Mocks {
        public static Database mockDatabase() {
                Database database = mock(Database.class);
                when(database.getSone(anyString())).thenReturn(Optional.<Sone>absent());
+               when(database.getPost(anyString())).thenReturn(Optional.<Post>absent());
                return database;
        }
 
@@ -73,4 +74,12 @@ public class Mocks {
                return sone;
        }
 
+       public static Post mockPost(Core core, String postId) {
+               Post post = mock(Post.class);
+               when(post.getId()).thenReturn(postId);
+               Database database = core.getDatabase();
+               when(database.getPost(eq(postId))).thenReturn(of(post));
+               return post;
+       }
+
 }