package net.pterodactylus.sone.web;
+import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo;
+import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import net.pterodactylus.sone.data.TemporaryImage;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException;
import net.pterodactylus.util.notify.Notification;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
when(currentSone.getOptions()).thenReturn(new DefaultSoneOptions());
}
+ protected SoneTemplatePage getPage() {
+ return null;
+ }
+
protected void unsetCurrentSone() {
when(webInterface.getCurrentSone(toadletContext)).thenReturn(null);
when(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(null);
when(webInterface.getNotification(eq(notificationId))).thenReturn(Optional.of(notification));
}
+ protected void verifyRedirect(String target) throws RedirectException {
+ expectedException.expect(redirectsTo(target));
+ getPage().handleRequest(freenetRequest, templateContext);
+ }
+
+ protected void verifyRedirect(String target, Runnable verification) throws RedirectException {
+ expectedException.expect(redirectsTo(target));
+ try {
+ getPage().handleRequest(freenetRequest, templateContext);
+ fail();
+ } finally {
+ verification.run();
+ }
+ }
+
}