X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FMocks.java;h=e1b91026398b6e7fbc7c4ef5d6fd943f44eeb474;hb=3d08e91faa3faaf496fdec77b9a11a03b8be1041;hp=ba029b4f1bb106841114bb242cd054aa6c043350;hpb=36f8de0f94fcf2d69baf6924f2b4c8952f7593e8;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index ba029b4..e1b9102 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -54,12 +54,12 @@ public class Mocks { Database database = mock(Database.class); when(database.getSone(anyString())).thenReturn(Optional.absent()); when(database.getPost(anyString())).thenReturn(Optional.absent()); + when(database.getPostReply(anyString())).thenReturn(Optional.absent()); return database; } public static Sone mockLocalSone(Core core, final String id) { - Sone sone = mock(Sone.class); - when(sone.getId()).thenReturn(id); + Sone sone = mockRemoteSone(core, id); when(sone.isLocal()).thenReturn(true); final Database database = core.getDatabase(); when(sone.newPostBuilder()).thenReturn(new DefaultPostBuilder(database, id)); @@ -70,8 +70,6 @@ public class Mocks { return new DefaultPostReplyBuilder(database, id, postIdCaptor.getValue()); } }); - when(core.getSone(eq(id))).thenReturn(of(sone)); - when(database.getSone(eq(id))).thenReturn(of(sone)); return sone; } @@ -79,8 +77,9 @@ public class Mocks { Sone sone = mock(Sone.class); when(sone.getId()).thenReturn(id); when(sone.isLocal()).thenReturn(false); + when(sone.getProfile()).thenReturn(new Profile(sone)); final Database database = core.getDatabase(); - when(sone.newPostBuilder()).thenReturn(new DefaultPostBuilder(database, id)); + when(sone.newPostBuilder()).thenThrow(IllegalStateException.class); when(sone.newPostReplyBuilder(Matchers.anyObject())).thenThrow(IllegalStateException.class); when(core.getSone(eq(id))).thenReturn(of(sone)); when(database.getSone(eq(id))).thenReturn(of(sone)); @@ -96,4 +95,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; + } + }