Add test for bookmark page
[Sone.git] / src / test / java / net / pterodactylus / sone / web / DeleteReplyPageTest.java
1 package net.pterodactylus.sone.web;
2
3 import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo;
4 import static net.pterodactylus.util.web.Method.POST;
5 import static org.mockito.ArgumentMatchers.anyInt;
6 import static org.mockito.ArgumentMatchers.eq;
7 import static org.mockito.Mockito.when;
8
9 import net.pterodactylus.sone.data.PostReply;
10
11 import com.google.common.base.Optional;
12 import org.junit.Test;
13
14 /**
15  * Unit test for {@link DeleteReplyPage}.
16  *
17  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
18  */
19 public class DeleteReplyPageTest extends WebPageTest {
20
21         private final DeleteReplyPage page = new DeleteReplyPage(template, webInterface);
22
23         @Test
24         public void tryingToDeleteAReplyWithAnInvalidIdResultsInNoPermissionPage() throws Exception {
25                 request("", POST);
26                 when(httpRequest.getPartAsStringFailsafe(eq("reply"), anyInt())).thenReturn("id");
27                 when(webInterface.getCore().getPostReply("id")).thenReturn(Optional.<PostReply>absent());
28                 expectedException.expect(redirectsTo("noPermission.html"));
29                 page.processTemplate(freenetRequest, templateContext);
30         }
31
32 }