X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FCreateReplyPageTest.java;fp=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FCreateReplyPageTest.java;h=0000000000000000000000000000000000000000;hb=cfa969d6aa8dc49b2d6487c1ccaaeb3058e86ba9;hp=996f5c05c406c5357f83c677dac0d1db086c5687;hpb=0136315a9aeb2e583326721e103b1690d0e42fc3;p=Sone.git
diff --git a/src/test/java/net/pterodactylus/sone/web/CreateReplyPageTest.java b/src/test/java/net/pterodactylus/sone/web/CreateReplyPageTest.java
deleted file mode 100644
index 996f5c0..0000000
--- a/src/test/java/net/pterodactylus/sone/web/CreateReplyPageTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package net.pterodactylus.sone.web;
-
-import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo;
-import static net.pterodactylus.util.web.Method.GET;
-import static net.pterodactylus.util.web.Method.POST;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
-
-import org.junit.Test;
-
-/**
- * Unit test for {@link CreateReplyPageTest}.
- *
- * @author David âBombeâ Roden
- */
-public class CreateReplyPageTest extends WebPageTest {
-
- private final CreateReplyPage page = new CreateReplyPage(template, webInterface);
-
- @Test
- public void pageReturnsCorrectPath() {
- assertThat(page.getPath(), is("createReply.html"));
- }
-
- @Test
- public void replyIsCreatedCorrectly() throws Exception {
- request("", POST);
- addHttpRequestParameter("post", "post-id");
- addHttpRequestParameter("text", "some text");
- addHttpRequestParameter("returnPage", "returnPage.html");
- Post post = mock(Post.class);
- addPost("post-id", post);
- expectedException.expect(redirectsTo("returnPage.html"));
- try {
- page.processTemplate(freenetRequest, templateContext);
- } finally {
- verify(core).createReply(currentSone, post, "some text");
- }
- }
-
- @Test
- public void replyIsCreatedWithCorrectSender() throws Exception {
- request("", POST);
- addHttpRequestParameter("post", "post-id");
- addHttpRequestParameter("text", "some text");
- addHttpRequestParameter("returnPage", "returnPage.html");
- addHttpRequestParameter("sender", "sender-id");
- Sone sender = mock(Sone.class);
- addLocalSone("sender-id", sender);
- Post post = mock(Post.class);
- addPost("post-id", post);
- expectedException.expect(redirectsTo("returnPage.html"));
- try {
- page.processTemplate(freenetRequest, templateContext);
- } finally {
- verify(core).createReply(sender, post, "some text");
- }
- }
-
- @Test
- public void emptyTextSetsVariableInTemplateContext() throws Exception {
- request("", POST);
- addPost("post-id", mock(Post.class));
- addHttpRequestParameter("post", "post-id");
- addHttpRequestParameter("text", " ");
- addHttpRequestParameter("returnPage", "returnPage.html");
- page.processTemplate(freenetRequest, templateContext);
- assertThat(templateContext.get("errorTextEmpty", Boolean.class), is(true));
- verifyParametersAreCopied("");
- verify(core, never()).createReply(any(Sone.class), any(Post.class), anyString());
- }
-
- private void verifyParametersAreCopied(String text) {
- assertThat(templateContext.get("postId", String.class), is("post-id"));
- assertThat(templateContext.get("text", String.class), is(text));
- assertThat(templateContext.get("returnPage", String.class), is("returnPage.html"));
- }
-
- @Test
- public void userIsRedirectIfPostDoesNotExist() throws Exception {
- request("", POST);
- addHttpRequestParameter("post", "post-id");
- addHttpRequestParameter("text", "some text");
- addHttpRequestParameter("returnPage", "returnPage.html");
- expectedException.expect(redirectsTo("noPermission.html"));
- page.processTemplate(freenetRequest, templateContext);
- }
-
- @Test
- public void getRequestServesTemplateAndStoresParameters() throws Exception {
- request("", GET);
- addHttpRequestParameter("post", "post-id");
- addHttpRequestParameter("text", "some text");
- addHttpRequestParameter("returnPage", "returnPage.html");
- page.processTemplate(freenetRequest, templateContext);
- verifyParametersAreCopied("some text");
- }
-
-}