X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FDeleteReplyPageTest.java;h=88c87a1bbe11ae9e37ef07ab83b482c5e67d7524;hp=91c781b0633c2f0f595b0cc4187cebbb8fe9e9fa;hb=f9ddb56aac0ca9530fdcb22a5d59c1d32c9b658a;hpb=d338aacec01efa636f96c5f8aab11b2345147691 diff --git a/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java b/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java index 91c781b..88c87a1 100644 --- a/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java +++ b/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java @@ -1,61 +1,28 @@ package net.pterodactylus.sone.web; import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo; -import static org.mockito.ArgumentMatchers.any; +import static net.pterodactylus.util.web.Method.POST; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.util.Collections; - import net.pterodactylus.sone.data.PostReply; -import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.web.page.FreenetRequest; -import net.pterodactylus.util.notify.Notification; -import net.pterodactylus.util.template.Template; -import net.pterodactylus.util.template.TemplateContext; -import net.pterodactylus.util.web.Method; - -import freenet.support.api.HTTPRequest; import com.google.common.base.Optional; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; /** * Unit test for {@link DeleteReplyPage}. * * @author David ‘Bombe’ Roden */ -public class DeleteReplyPageTest { +public class DeleteReplyPageTest extends WebPageTest { - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - - private final Template template = new Template(); - private final WebInterface webInterface = mock(WebInterface.class, RETURNS_DEEP_STUBS); private final DeleteReplyPage page = new DeleteReplyPage(template, webInterface); - private final TemplateContext templateContext = new TemplateContext(); - private final FreenetRequest freenetRequest = mock(FreenetRequest.class); - private final HTTPRequest httpRequest = mock(HTTPRequest.class); - - @Before - public void setupWebInterface() { - when(webInterface.getNotifications(any(Sone.class))).thenReturn(Collections.emptyList()); - } - - @Before - public void setupHttpRequest() { - when(freenetRequest.getHttpRequest()).thenReturn(httpRequest); - } @Test public void tryingToDeleteAReplyWithAnInvalidIdResultsInNoPermissionPage() throws Exception { - when(freenetRequest.getMethod()).thenReturn(Method.POST); + request("", POST); when(httpRequest.getPartAsStringFailsafe(eq("reply"), anyInt())).thenReturn("id"); when(webInterface.getCore().getPostReply("id")).thenReturn(Optional.absent()); expectedException.expect(redirectsTo("noPermission.html"));