X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FWebPageTest.java;h=c785e36c9809216f2744b82c9de80486a36c8863;hb=adfa1ad91aece5798cb1ffbffc1b0792a62ca4e0;hp=e04e780d6c0bf3d64f764195adf537b54e9a831c;hpb=8da648b3e2b33064cb72aa87c4dc198b60bf0a7f;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java b/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java index e04e780..c785e36 100644 --- a/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java +++ b/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java @@ -70,6 +70,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.rules.ExpectedException; import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -290,7 +291,7 @@ public abstract class WebPageTest { when(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone); when(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone); when(webInterface.getNotification(anyString())).thenReturn(Optional.absent()); - when(webInterface.getNotifications(currentSone)).thenReturn(new ArrayList()); + when(webInterface.getNotifications(Mockito.any())).thenReturn(new ArrayList()); } @Before @@ -308,6 +309,11 @@ public abstract class WebPageTest { when(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(null); } + protected void setMethod(Method method) { + when(freenetRequest.getMethod()).thenReturn(method); + when(httpRequest.getMethod()).thenReturn(method.name()); + } + protected void request(String uri, Method method) { try { when(httpRequest.getPath()).thenReturn(uri); @@ -401,4 +407,13 @@ public abstract class WebPageTest { } } + protected void verifyNoRedirect(Runnable verification) throws RedirectException { + getPage().handleRequest(freenetRequest, templateContext); + verification.run(); + } + + protected void addTranslation(@Nonnull String key, @Nonnull String value) { + when(l10n.getString(key)).thenReturn(value); + } + }