From: David ‘Bombe’ Roden Date: Sun, 27 Oct 2013 21:58:44 +0000 (+0100) Subject: Require a Sone when mocking a post. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0c6789e2989672a6d08ed2c2184e978d7b1a266a;p=Sone.git Require a Sone when mocking a post. --- diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index a1c1a71..10d40a1 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -74,9 +74,10 @@ public class Mocks { return sone; } - public static Post mockPost(Core core, String postId) { + public static Post mockPost(Core core, Sone sone, String postId) { Post post = mock(Post.class); when(post.getId()).thenReturn(postId); + when(post.getSone()).thenReturn(sone); Database database = core.getDatabase(); when(database.getPost(eq(postId))).thenReturn(of(post)); return post; diff --git a/src/test/java/net/pterodactylus/sone/fcp/CreateReplyCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/CreateReplyCommandTest.java index e8c3057..6317c8f 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/CreateReplyCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/CreateReplyCommandTest.java @@ -60,7 +60,7 @@ public class CreateReplyCommandTest { @Test public void verifyThatCreatingAFullySpecifiedReplyWorks() throws FcpException { Sone sone = mockLocalSone(core, "SoneId"); - mockPost(core, "PostId"); + mockPost(core, sone, "PostId"); CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated(); when(core.postReplyCreated()).thenReturn(Optional.of(capturingPostReplyCreated)); SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder() @@ -84,7 +84,8 @@ public class CreateReplyCommandTest { @Test(expected = FcpException.class) public void verifyThatCreatingAReplyWithoutSoneCausesAnError() throws FcpException { - mockPost(core, "PostId"); + Sone sone = mockLocalSone(core, "SoneId"); + mockPost(core, sone, "PostId"); CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated(); when(core.postReplyCreated()).thenReturn(Optional.of(capturingPostReplyCreated)); SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder() @@ -110,8 +111,8 @@ public class CreateReplyCommandTest { @Test(expected = FcpException.class) public void verifyThatCreatingAReplyWithoutTextCausesAnError() throws FcpException { - mockLocalSone(core, "SoneId"); - mockPost(core, "PostId"); + Sone sone = mockLocalSone(core, "SoneId"); + mockPost(core, sone, "PostId"); CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated(); when(core.postReplyCreated()).thenReturn(Optional.of(capturingPostReplyCreated)); SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder()