X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FDeletePostCommandTest.java;h=683864c20968e692d7e58d9ab151b8f6a7705790;hb=2d37242d19f2e726cd402b99f935a0eba282f630;hp=5b062779c0ed8d69ac5c8affeb88908d979c0963;hpb=844bd06ee895aa3a050192b5063b1efe1a85f80b;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/fcp/DeletePostCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/DeletePostCommandTest.java index 5b06277..683864c 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/DeletePostCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/DeletePostCommandTest.java @@ -17,10 +17,10 @@ package net.pterodactylus.sone.fcp; +import static net.pterodactylus.sone.Verifiers.verifyAnswer; import static net.pterodactylus.sone.freenet.fcp.Command.AccessType.DIRECT; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; import static org.mockito.ArgumentCaptor.forClass; import static org.mockito.Mockito.doNothing; @@ -48,8 +48,8 @@ public class DeletePostCommandTest { @Test public void verifyThatDeletingAPostWorks() throws FcpException { - Sone sone = mocks.mockLocalSone("Sone"); - Post post = mocks.mockPost(sone, "PostId"); + Sone sone = mocks.mockSone("Sone").local().create(); + Post post = mocks.mockPost(sone, "PostId").create(); ArgumentCaptor deletedPost = forClass(Post.class); doNothing().when(mocks.core).deletePost(deletedPost.capture()); SimpleFieldSet deletePostFieldSet = new SimpleFieldSetBuilder() @@ -57,24 +57,20 @@ public class DeletePostCommandTest { .put("Post", "PostId") .get(); Response response = deletePostCommand.execute(deletePostFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("PostDeleted")); + verifyAnswer(response, "PostDeleted"); assertThat(deletedPost.getValue(), is(post)); } @Test public void verifyThatDeletingAPostFromANonLocalSoneCausesAnError() throws FcpException { - Sone sone = mocks.mockRemoteSone("Sone"); - Post post = mocks.mockPost(sone, "PostId"); + Sone sone = mocks.mockSone("Sone").create(); + Post post = mocks.mockPost(sone, "PostId").create(); SimpleFieldSet deletePostFieldSet = new SimpleFieldSetBuilder() .put("Message", "DeletePost") .put("Post", "PostId") .get(); Response response = deletePostCommand.execute(deletePostFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("Error")); + verifyAnswer(response, "Error"); assertThat(response.getReplyParameters().get("ErrorCode"), is("401")); } @@ -88,8 +84,6 @@ public class DeletePostCommandTest { @Test(expected = FcpException.class) public void verifyThatDeletingAPostWithAnInvalidPostIdCausesAnError() throws FcpException { - Sone sone = mocks.mockLocalSone("Sone"); - mocks.mockPost(sone, "PostId"); SimpleFieldSet deletePostFieldSet = new SimpleFieldSetBuilder() .put("Message", "DeletePost") .put("Post", "OtherPostId")