X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FBookmarkAjaxPageTest.java;h=ed07a5b14ffa33e47d2a1ee8d7d21625300dac29;hp=02394644f00e83cce080c6073c1da5bab93a918c;hb=b30df9db8b6400e00e431ce2a92370cda91615c7;hpb=3892f56f769b352fe1d1d7c6b9f2c6805a46678f diff --git a/src/test/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.java b/src/test/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.java index 0239464..ed07a5b 100644 --- a/src/test/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.java +++ b/src/test/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.java @@ -13,6 +13,7 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.net.URISyntaxException; @@ -42,20 +43,22 @@ public class BookmarkAjaxPageTest { @Test public void testBookmarkingExistingPost() throws URISyntaxException { - JsonReturnObject jsonReturnObject = performRequest("/ajax/bookmark.ajax?post=abc", bookmarkAjaxPage); + JsonReturnObject jsonReturnObject = performRequest(bookmarkAjaxPage, "abc"); verifySuccessfulJsonResponse(jsonReturnObject); verify(core, times(1)).bookmarkPost(eq("abc")); } @Test public void testBookmarkingMissingPost() throws URISyntaxException { - JsonReturnObject jsonReturnObject = performRequest("/ajax/bookmark.ajax", bookmarkAjaxPage); + JsonReturnObject jsonReturnObject = performRequest(bookmarkAjaxPage, null); verifyJsonError(jsonReturnObject, "invalid-post-id"); verify(core, never()).bookmarkPost(anyString()); } - private JsonReturnObject performRequest(String path, BookmarkAjaxPage bookmarkAjaxPage) throws URISyntaxException { - FreenetRequest request = mocks.mockRequest(path); + private JsonReturnObject performRequest(BookmarkAjaxPage bookmarkAjaxPage, String postId) throws URISyntaxException { + FreenetRequest request = mocks.mockRequest(""); + when(request.getHttpRequest().getParam("post")).thenReturn(postId); + when(request.getHttpRequest().getParam("post", null)).thenReturn(postId); return bookmarkAjaxPage.createJsonObject(request); }