Move verifiers to different package.
[Sone.git] / src / test / java / net / pterodactylus / sone / fcp / CreateReplyCommandTest.java
index 70f9996..bef609a 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.fcp;
 
 import static java.lang.System.currentTimeMillis;
+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.greaterThanOrEqualTo;
@@ -53,8 +54,8 @@ public class CreateReplyCommandTest {
 
        @Test
        public void verifyThatCreatingAFullySpecifiedReplyWorks() throws FcpException {
-               Sone sone = mocks.mockLocalSone("SoneId");
-               mocks.mockPost(sone, "PostId");
+               Sone sone = mocks.mockSone("SoneId").local().create();
+               mocks.mockPost(sone, "PostId").create();
                CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated();
                when(mocks.core.postReplyCreated()).thenReturn(Optional.<PostReplyCreated>of(capturingPostReplyCreated));
                SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder()
@@ -64,22 +65,20 @@ public class CreateReplyCommandTest {
                                .put("Text", "Text of the reply.")
                                .get();
                Response response = createReplyCommand.execute(createReplyFieldSet, null, DIRECT);
-               assertThat(response, notNullValue());
+               verifyAnswer(response, "ReplyCreated");
                assertThat(capturingPostReplyCreated.postReply, notNullValue());
                assertThat(capturingPostReplyCreated.postReply.getId(), notNullValue());
                assertThat(capturingPostReplyCreated.postReply.getPostId(), is("PostId"));
                assertThat(capturingPostReplyCreated.postReply.getSone(), is(sone));
                assertThat(capturingPostReplyCreated.postReply.getTime(), allOf(greaterThanOrEqualTo(now), lessThanOrEqualTo(currentTimeMillis())));
                assertThat(capturingPostReplyCreated.postReply.getText(), is("Text of the reply."));
-               assertThat(response.getReplyParameters(), notNullValue());
-               assertThat(response.getReplyParameters().get("Message"), is("ReplyCreated"));
                assertThat(response.getReplyParameters().get("Reply"), is(capturingPostReplyCreated.postReply.getId()));
        }
 
        @Test(expected = FcpException.class)
        public void verifyThatCreatingAReplyWithoutSoneCausesAnError() throws FcpException {
-               Sone sone = mocks.mockLocalSone("SoneId");
-               mocks.mockPost(sone, "PostId");
+               Sone sone = mocks.mockSone("SoneId").local().create();
+               mocks.mockPost(sone, "PostId").create();
                CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated();
                when(mocks.core.postReplyCreated()).thenReturn(Optional.<PostReplyCreated>of(capturingPostReplyCreated));
                SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder()
@@ -92,7 +91,7 @@ public class CreateReplyCommandTest {
 
        @Test(expected = FcpException.class)
        public void verifyThatCreatingAReplyWithoutPostCausesAnError() throws FcpException {
-               mocks.mockLocalSone("SoneId");
+               mocks.mockSone("SoneId").local().create();
                CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated();
                when(mocks.core.postReplyCreated()).thenReturn(Optional.<PostReplyCreated>of(capturingPostReplyCreated));
                SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder()
@@ -105,8 +104,8 @@ public class CreateReplyCommandTest {
 
        @Test(expected = FcpException.class)
        public void verifyThatCreatingAReplyWithoutTextCausesAnError() throws FcpException {
-               Sone sone = mocks.mockLocalSone("SoneId");
-               mocks.mockPost(sone, "PostId");
+               Sone sone = mocks.mockSone("SoneId").local().create();
+               mocks.mockPost(sone, "PostId").create();
                CapturingPostReplyCreated capturingPostReplyCreated = new CapturingPostReplyCreated();
                when(mocks.core.postReplyCreated()).thenReturn(Optional.<PostReplyCreated>of(capturingPostReplyCreated));
                SimpleFieldSet createReplyFieldSet = new SimpleFieldSetBuilder()