Add method to mock post replies, too.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 28 Oct 2013 18:21:00 +0000 (19:21 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:48 +0000 (22:25 +0100)
src/test/java/net/pterodactylus/sone/data/Mocks.java

index ba029b4..7ee612d 100644 (file)
@@ -54,6 +54,7 @@ public class Mocks {
                Database database = mock(Database.class);
                when(database.getSone(anyString())).thenReturn(Optional.<Sone>absent());
                when(database.getPost(anyString())).thenReturn(Optional.<Post>absent());
+               when(database.getPostReply(anyString())).thenReturn(Optional.<PostReply>absent());
                return database;
        }
 
@@ -96,4 +97,13 @@ public class Mocks {
                return post;
        }
 
+       public static PostReply mockPostReply(Core core, Sone sone, String replyId) {
+               PostReply postReply = mock(PostReply.class);
+               when(postReply.getId()).thenReturn(replyId);
+               when(postReply.getSone()).thenReturn(sone);
+               Database database = core.getDatabase();
+               when(database.getPostReply(eq(replyId))).thenReturn(of(postReply));
+               return postReply;
+       }
+
 }