From: David ‘Bombe’ Roden Date: Tue, 27 Jun 2017 20:33:31 +0000 (+0200) Subject: Replace web page test base with Kotlin version X-Git-Tag: 0.9.7^2~113 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2dd40fba7031cffb35a5156435547a5d964535c9;p=Sone.git Replace web page test base with Kotlin version --- diff --git a/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java b/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java deleted file mode 100644 index 9774915..0000000 --- a/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java +++ /dev/null @@ -1,419 +0,0 @@ -package net.pterodactylus.sone.web.pages; - -import static net.pterodactylus.sone.test.GuiceKt.supply; -import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo; -import static net.pterodactylus.util.web.Method.GET; -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 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.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.naming.SizeLimitExceededException; - -import net.pterodactylus.sone.core.Core; -import net.pterodactylus.sone.core.Preferences; -import net.pterodactylus.sone.core.UpdateChecker; -import net.pterodactylus.sone.data.Album; -import net.pterodactylus.sone.data.Image; -import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.PostReply; -import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.data.SoneOptions.DefaultSoneOptions; -import net.pterodactylus.sone.data.TemporaryImage; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; -import net.pterodactylus.sone.web.WebInterface; -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; -import net.pterodactylus.util.web.Method; -import net.pterodactylus.util.web.Response; - -import freenet.clients.http.ToadletContext; -import freenet.l10n.BaseL10n; -import freenet.support.SimpleReadOnlyArrayBucket; -import freenet.support.api.Bucket; -import freenet.support.api.HTTPRequest; -import freenet.support.api.HTTPUploadedFile; -import freenet.support.io.NullBucket; - -import com.google.common.base.Optional; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.eventbus.EventBus; -import com.google.common.io.ByteStreams; -import com.google.inject.Guice; -import com.google.inject.Injector; -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; - -/** - * Base class for web page tests. - * - * @author David ‘Bombe’ Roden - */ -public abstract class WebPageTest { - - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - - protected final Template template = new Template(); - protected final WebInterface webInterface = mock(WebInterface.class, RETURNS_DEEP_STUBS); - protected final EventBus eventBus = mock(EventBus.class); - protected final Core core = webInterface.getCore(); - protected final BaseL10n l10n = webInterface.getL10n(); - - protected final Sone currentSone = mock(Sone.class); - - protected final TemplateContext templateContext = new TemplateContext(); - protected final HTTPRequest httpRequest = mock(HTTPRequest.class); - protected final Multimap requestParameters = ArrayListMultimap.create(); - protected final Map requestParts = new HashMap<>(); - protected final Map requestHeaders = new HashMap<>(); - private final Map uploadedFilesNames = new HashMap<>(); - private final Map uploadedFilesContentTypes = new HashMap<>(); - private final Map uploadedFilesSources = new HashMap<>(); - protected final FreenetRequest freenetRequest = mock(FreenetRequest.class); - private final PipedOutputStream responseOutputStream = new PipedOutputStream(); - private final PipedInputStream responseInputStream; - protected final Response response = new Response(responseOutputStream); - protected final ToadletContext toadletContext = mock(ToadletContext.class); - - private final Set ownIdentities = new HashSet<>(); - private final Map sones = new HashMap<>(); - protected final List localSones = new ArrayList<>(); - private final ListMultimap postReplies = ArrayListMultimap.create(); - - protected final Injector injector = Guice.createInjector( - supply(WebInterface.class).byInstance(webInterface), - supply(Template.class).byInstance(template) - ); - - protected WebPageTest() { - try { - responseInputStream = new PipedInputStream(responseOutputStream); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Before - public final void setupFreenetRequest() throws SizeLimitExceededException { - setMethod(GET); - when(freenetRequest.getToadletContext()).thenReturn(toadletContext); - when(freenetRequest.getHttpRequest()).thenReturn(httpRequest); - when(httpRequest.getMultipleParam(anyString())).thenAnswer(new Answer() { - @Override - public String[] answer(InvocationOnMock invocation) throws Throwable { - return requestParameters.get(invocation.getArgument(0)).toArray(new String[0]); - } - }); - when(httpRequest.isPartSet(anyString())).thenAnswer(new Answer() { - @Override - public Boolean answer(InvocationOnMock invocation) throws Throwable { - return requestParts.get(invocation.getArgument(0)) != null; - } - }); - when(httpRequest.getParts()).thenAnswer(new Answer() { - @Override - public String[] answer(InvocationOnMock invocation) throws Throwable { - return requestParts.keySet().toArray(new String[requestParts.size()]); - } - }); - when(httpRequest.getPartAsStringFailsafe(anyString(), anyInt())).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - String parameter = invocation.getArgument(0); - int maxLength = invocation.getArgument(1); - String value = requestParts.get(parameter); - return requestParts.containsKey(parameter) ? value.substring(0, Math.min(maxLength, value.length())) : ""; - } - }); - when(httpRequest.getPartAsStringThrowing(anyString(), anyInt())).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - String partName = invocation.getArgument(0); - if (!requestParts.containsKey(partName)) throw new NoSuchElementException(); - String partValue = requestParts.get(partName); - if (partValue.length() > invocation.getArgument(1)) throw new SizeLimitExceededException(); - return partValue; - } - }); - when(httpRequest.hasParameters()).thenAnswer(new Answer() { - @Override - public Boolean answer(InvocationOnMock invocation) throws Throwable { - return !requestParameters.isEmpty(); - } - }); - when(httpRequest.getParameterNames()).thenAnswer(new Answer>() { - @Override - public Collection answer(InvocationOnMock invocation) throws Throwable { - return requestParameters.keySet(); - } - }); - when(httpRequest.getParam(anyString())).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - String parameter = invocation.getArgument(0); - return requestParameters.containsKey(parameter) ? requestParameters.get(parameter).iterator().next() : ""; - } - }); - when(httpRequest.getParam(anyString(), ArgumentMatchers.any())).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - String parameter = invocation.getArgument(0); - return requestParameters.containsKey(parameter) ? requestParameters.get(parameter).iterator().next() : invocation.getArgument(1); - } - }); - when(httpRequest.isParameterSet(anyString())).thenAnswer(new Answer() { - @Override - public Boolean answer(InvocationOnMock invocation) throws Throwable { - return requestParameters.containsKey(invocation.getArgument(0)) && - requestParameters.get(invocation.getArgument(0)).iterator().next() != null; - } - }); - when(httpRequest.getHeader(anyString())).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - return requestHeaders.get(invocation.getArgument(0).toLowerCase()); - } - }); - when(httpRequest.getUploadedFile(anyString())).thenAnswer(new Answer() { - @Override - public HTTPUploadedFile answer(InvocationOnMock invocation) throws Throwable { - final String name = invocation.getArgument(0); - if (!uploadedFilesSources.containsKey(name)) { - return null; - } - return new HTTPUploadedFile() { - @Override - public String getContentType() { - return uploadedFilesContentTypes.get(name); - } - - @Override - public Bucket getData() { - try (InputStream inputStream = getClass().getResourceAsStream(uploadedFilesSources.get(name))) { - byte[] bytes = ByteStreams.toByteArray(inputStream); - return new SimpleReadOnlyArrayBucket(bytes, 0, bytes.length); - } catch (IOException ioe1) { - return new NullBucket(); - } - } - - @Override - public String getFilename() { - return uploadedFilesNames.get(name); - } - }; - } - }); - } - - @Before - public final void setupCore() { - UpdateChecker updateChecker = mock(UpdateChecker.class); - when(core.getUpdateChecker()).thenReturn(updateChecker); - when(core.getPreferences()).thenReturn(new Preferences(eventBus)); - when(core.getLocalSone(anyString())).thenReturn(null); - when(core.getLocalSones()).thenReturn(localSones); - when(core.getSone(anyString())).thenReturn(Optional.absent()); - when(core.getSones()).thenAnswer(new Answer>() { - @Override - public Collection answer(InvocationOnMock invocation) throws Throwable { - return sones.values(); - } - }); - when(core.getSone(anyString())).thenAnswer(new Answer>() { - @Override - public Optional answer(InvocationOnMock invocation) throws Throwable { - return Optional.fromNullable(sones.get(invocation.getArgument(0))); - } - }); - when(core.getPost(anyString())).thenReturn(Optional.absent()); - when(core.getPostReply(anyString())).thenReturn(Optional.absent()); - when(core.getReplies(anyString())).thenAnswer(new Answer>() { - @Override - public List answer(InvocationOnMock invocation) throws Throwable { - return postReplies.get(invocation.getArgument(0)); - } - }); - when(core.getAlbum(anyString())).thenReturn(null); - when(core.getImage(anyString())).thenReturn(null); - when(core.getImage(anyString(), anyBoolean())).thenReturn(null); - when(core.getTemporaryImage(anyString())).thenReturn(null); - } - - @Before - public void setupL10n() { - when(l10n.getString(anyString())).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - return invocation.getArgument(0); - } - }); - } - - @Before - public final void setupIdentityManager() { - when(core.getIdentityManager().getAllOwnIdentities()).thenReturn(ownIdentities); - } - - @Before - public final void setupWebInterface() { - when(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(currentSone); - when(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone); - when(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone); - when(webInterface.getNotification(anyString())).thenReturn(Optional.absent()); - when(webInterface.getNotifications(Mockito.any())).thenReturn(new ArrayList()); - } - - @Before - public void setupSone() { - when(currentSone.getOptions()).thenReturn(new DefaultSoneOptions()); - } - - protected SoneTemplatePage getPage() { - return null; - } - - protected void unsetCurrentSone() { - when(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(null); - when(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(null); - 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) { - try { - when(httpRequest.getPath()).thenReturn(uri); - when(freenetRequest.getUri()).thenReturn(new URI(uri)); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - protected void addHttpRequestHeader(@Nonnull String name, String value) { - requestHeaders.put(name.toLowerCase(), value); - } - - protected void addHttpRequestParameter(String name, final String value) { - requestParameters.put(name, value); - } - - protected void addHttpRequestPart(String name, String value) { - requestParts.put(name, value); - } - - protected void addPost(String postId, Post post) { - when(core.getPost(postId)).thenReturn(Optional.fromNullable(post)); - } - - protected void addPostReply(String postReplyId, PostReply postReply) { - if (postReply.getPostId() != null) { - postReplies.put(postReply.getPostId(), postReply); - } - when(core.getPostReply(postReplyId)).thenReturn(Optional.fromNullable(postReply)); - } - - protected void addSone(String soneId, Sone sone) { - sones.put(soneId, sone); - } - - protected void addLocalSone(String soneId, Sone sone) { - when(core.getLocalSone(eq(soneId))).thenReturn(sone); - localSones.add(sone); - } - - protected void addOwnIdentity(OwnIdentity ownIdentity) { - ownIdentities.add(ownIdentity); - } - - protected void addAlbum(String albumId, Album album) { - when(core.getAlbum(eq(albumId))).thenReturn(album); - } - - protected void addImage(String imageId, Image image) { - when(core.getImage(eq(imageId))).thenReturn(image); - when(core.getImage(eq(imageId), anyBoolean())).thenReturn(image); - } - - protected void addTemporaryImage(String imageId, TemporaryImage temporaryImage) { - when(core.getTemporaryImage(eq(imageId))).thenReturn(temporaryImage); - } - - protected void addUploadedFile(@Nonnull String name, @Nonnull String filename, @Nonnull String contentType, @Nonnull String resource) { - uploadedFilesNames.put(name, filename); - uploadedFilesContentTypes.put(name, contentType); - uploadedFilesSources.put(name, resource); - } - - protected byte[] getResponseBytes() throws IOException { - response.getContent().close(); - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { - ByteStreams.copy(responseInputStream, outputStream); - return outputStream.toByteArray(); - } - } - - protected void addNotification(String notificationId, Notification notification) { - 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(); - } - } - - 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); - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt index c692960..142bf81 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/AboutPageTest.kt @@ -10,12 +10,13 @@ import org.junit.Test /** * Unit test for [AboutPage]. */ -class AboutPageTest: WebPageTest() { +class AboutPageTest: WebPageTest({ template, webInterface -> AboutPage(template, webInterface, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) { - private val version = "0.1.2" - private val year = 1234 - private val homepage = "home://page" - private val page = AboutPage(template, webInterface, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) + companion object { + private const val version = "0.1.2" + private const val year = 1234 + private const val homepage = "home://page" + } @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarkPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarkPageTest.kt index c03706b..a805843 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarkPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarkPageTest.kt @@ -13,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [BookmarkPage]. */ -class BookmarkPageTest: WebPageTest2(::BookmarkPage) { +class BookmarkPageTest: WebPageTest(::BookmarkPage) { @Test fun `path is set correctly`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt index 04446a2..e853199 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/BookmarksPageTest.kt @@ -13,7 +13,7 @@ import org.junit.Test /** * Unit test for [BookmarksPage]. */ -class BookmarksPageTest: WebPageTest2(::BookmarksPage) { +class BookmarksPageTest: WebPageTest(::BookmarksPage) { private val post1 = createLoadedPost(1000) private val post2 = createLoadedPost(3000) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPageTest.kt index 4d8ec26..5cc463a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPageTest.kt @@ -16,7 +16,7 @@ import org.mockito.Mockito.verify /** * Unit test for [CreateAlbumPage]. */ -class CreateAlbumPageTest: WebPageTest2(::CreateAlbumPage) { +class CreateAlbumPageTest: WebPageTest(::CreateAlbumPage) { private val parentAlbum = createAlbum("parent-id") private val newAlbum = createAlbum("album-id") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt index 35ec597..3b1cc8c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt @@ -13,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [CreatePostPage]. */ -class CreatePostPageTest: WebPageTest2(::CreatePostPage) { +class CreatePostPageTest: WebPageTest(::CreatePostPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPageTest.kt index 778de4d..71e83bc 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPageTest.kt @@ -12,7 +12,7 @@ import org.mockito.Mockito.verify /** * Unit test for [CreateReplyPage]. */ -class CreateReplyPageTest: WebPageTest2(::CreateReplyPage) { +class CreateReplyPageTest: WebPageTest(::CreateReplyPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt index 95afaa8..9cbf2c3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/CreateSonePageTest.kt @@ -16,7 +16,7 @@ import org.mockito.Mockito.verify /** * Unit test for [CreateSonePage]. */ -class CreateSonePageTest: WebPageTest2(::CreateSonePage) { +class CreateSonePageTest: WebPageTest(::CreateSonePage) { private val localSones_ = listOf( createSone("local-sone1"), diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPageTest.kt index 6800ef4..969a133 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPageTest.kt @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DeleteAlbumPage]. */ -class DeleteAlbumPageTest: WebPageTest2(::DeleteAlbumPage) { +class DeleteAlbumPageTest: WebPageTest(::DeleteAlbumPage) { private val sone = mock() private val album = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePageTest.kt index 9a0c990..1b90c4a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePageTest.kt @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DeleteImagePage]. */ -class DeleteImagePageTest: WebPageTest2(::DeleteImagePage) { +class DeleteImagePageTest: WebPageTest(::DeleteImagePage) { private val image = mock() private val sone = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeletePostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeletePostPageTest.kt index 383e38c..5ccd5c2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeletePostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeletePostPageTest.kt @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DeletePostPage]. */ -class DeletePostPageTest: WebPageTest2(::DeletePostPage) { +class DeletePostPageTest: WebPageTest(::DeletePostPage) { private val post = mock() private val sone = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPageTest.kt index 862fff4..8f344eb 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPageTest.kt @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DeleteProfileFieldPage]. */ -class DeleteProfileFieldPageTest: WebPageTest2(::DeleteProfileFieldPage) { +class DeleteProfileFieldPageTest: WebPageTest(::DeleteProfileFieldPage) { private val profile = Profile(currentSone) private val field = profile.addField("name") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPageTest.kt index ba40988..c332557 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPageTest.kt @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DeleteReplyPage]. */ -class DeleteReplyPageTest: WebPageTest2(::DeleteReplyPage) { +class DeleteReplyPageTest: WebPageTest(::DeleteReplyPage) { private val sone = mock() private val reply = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePageTest.kt index 5d73338..415adf6 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePageTest.kt @@ -12,7 +12,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DeleteSonePage]. */ -class DeleteSonePageTest: WebPageTest2(::DeleteSonePage) { +class DeleteSonePageTest: WebPageTest(::DeleteSonePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt index acb3d0a..41f47aa 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt @@ -13,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DismissNotificationPage]. */ -class DismissNotificationPageTest: WebPageTest2(::DismissNotificationPage) { +class DismissNotificationPageTest: WebPageTest(::DismissNotificationPage) { private val notification = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt index a1a59b9..3261df6 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt @@ -12,7 +12,7 @@ import org.mockito.Mockito.verify /** * Unit test for [DistrustPage]. */ -class DistrustPageTest: WebPageTest2(::DistrustPage) { +class DistrustPageTest: WebPageTest(::DistrustPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPageTest.kt index 5ef276f..b4328c6 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPageTest.kt @@ -17,7 +17,7 @@ import org.mockito.Mockito.verify /** * Unit test for [EditAlbumPage]. */ -class EditAlbumPageTest: WebPageTest2(::EditAlbumPage) { +class EditAlbumPageTest: WebPageTest(::EditAlbumPage) { private val album = mock() private val parentAlbum = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt index 73b6eca..f6eb02e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt @@ -20,7 +20,7 @@ import org.mockito.Mockito.verify /** * Unit test for [EditImagePage]. */ -class EditImagePageTest: WebPageTest2(::EditImagePage) { +class EditImagePageTest: WebPageTest(::EditImagePage) { private val image = mock() private val modifier = mockBuilder() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt index 8e931e5..b4acc7e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt @@ -13,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [EditProfileFieldPage]. */ -class EditProfileFieldPageTest: WebPageTest2(::EditProfileFieldPage) { +class EditProfileFieldPageTest: WebPageTest(::EditProfileFieldPage) { private val profile = Profile(currentSone) private val field = profile.addField("Name") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt index bb8e179..f76786a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt @@ -17,7 +17,7 @@ import org.mockito.Mockito.verify /** * Unit test for [EditProfilePage]. */ -class EditProfilePageTest: WebPageTest2(::EditProfilePage) { +class EditProfilePageTest: WebPageTest(::EditProfilePage) { private val profile = Profile(currentSone) private val firstField = profile.addField("First Field") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/FollowSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/FollowSonePageTest.kt index 3e80cc5..21964aa 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/FollowSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/FollowSonePageTest.kt @@ -16,7 +16,7 @@ import org.mockito.Mockito.verify /** * Unit test for [FollowSonePage]. */ -class FollowSonePageTest: WebPageTest2(::FollowSonePage) { +class FollowSonePageTest: WebPageTest(::FollowSonePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt index 6c34e3f..b5efeac 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt @@ -11,7 +11,7 @@ import org.junit.Test */ class GetImagePageTest { - private val scaffolding = WebPageTest2() + private val scaffolding = WebPageTest() private val page = GetImagePage(scaffolding.webInterface) private val freenetRequest = scaffolding.freenetRequest private val response = scaffolding.response diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt index d426845..2c581ac 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt @@ -13,7 +13,7 @@ import org.junit.Test /** * Unit test for [ImageBrowserPage]. */ -class ImageBrowserPageTest: WebPageTest2(::ImageBrowserPage) { +class ImageBrowserPageTest: WebPageTest(::ImageBrowserPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt index ead3cbb..b51627d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt @@ -19,7 +19,7 @@ import org.mockito.ArgumentMatchers /** * Unit test for [IndexPage]. */ -class IndexPageTest: WebPageTest2({ template, webInterface -> IndexPage(template, webInterface, postVisibilityFilter) }) { +class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, webInterface, postVisibilityFilter) }) { companion object { private val postVisibilityFilter = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPageTest.kt index 5109818..70a5eea 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPageTest.kt @@ -20,7 +20,7 @@ import org.junit.Test /** * Unit test for [KnownSonesPage]. */ -class KnownSonesPageTest: WebPageTest2(::KnownSonesPage) { +class KnownSonesPageTest: WebPageTest(::KnownSonesPage) { private val sones = listOf( createSone(1000, 4, 7, 2, "sone2", true, true), diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt index 9a293cc..9a08737 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt @@ -10,7 +10,7 @@ import org.mockito.Mockito.verifyNoMoreInteractions /** * Unit test for [LikePage]. */ -class LikePageTest: WebPageTest2(::LikePage) { +class LikePageTest: WebPageTest(::LikePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/LockSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/LockSonePageTest.kt index 8cc6028..2a9b4ed 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/LockSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/LockSonePageTest.kt @@ -13,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [LockSonePage]. */ -class LockSonePageTest: WebPageTest2(::LockSonePage) { +class LockSonePageTest: WebPageTest(::LockSonePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt index e9fdb5c..1b409b7 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt @@ -19,7 +19,7 @@ import org.mockito.Mockito.verify /** * Unit test for [LoginPage]. */ -class LoginPageTest: WebPageTest2(::LoginPage) { +class LoginPageTest: WebPageTest(::LoginPage) { private val sones = listOf(createSone("Sone", "Test"), createSone("Test"), createSone("Sone")) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/LogoutPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/LogoutPageTest.kt index cb53646..9dbc82a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/LogoutPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/LogoutPageTest.kt @@ -9,7 +9,7 @@ import org.mockito.Mockito.verify /** * Unit test for [LogoutPage]. */ -class LogoutPageTest: WebPageTest2(::LogoutPage) { +class LogoutPageTest: WebPageTest(::LogoutPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPageTest.kt index 3744b5b..d9a132a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPageTest.kt @@ -13,7 +13,7 @@ import org.mockito.Mockito.verify /** * Unit test for [MarkAsKnownPage]. */ -class MarkAsKnownPageTest: WebPageTest2(::MarkAsKnownPage) { +class MarkAsKnownPageTest: WebPageTest(::MarkAsKnownPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/NewPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/NewPageTest.kt index fb4f46d..96427e7 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/NewPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/NewPageTest.kt @@ -17,7 +17,7 @@ import java.util.Arrays.asList /** * Unit test for [NewPage]. */ -class NewPageTest: WebPageTest2(::NewPage) { +class NewPageTest: WebPageTest(::NewPage) { @Before fun setupNumberOfPostsPerPage() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt index 28844b9..4e4c02e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt @@ -18,7 +18,7 @@ import org.junit.Test /** * Unit test for [OptionsPage]. */ -class OptionsPageTest: WebPageTest2(::OptionsPage) { +class OptionsPageTest: WebPageTest(::OptionsPage) { @Before fun setupPreferences() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt index bb94fbf..e8ec10a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt @@ -15,7 +15,7 @@ import org.mockito.Mockito.verify /** * Unit test for [RescuePage]. */ -class RescuePageTest: WebPageTest2(::RescuePage) { +class RescuePageTest: WebPageTest(::RescuePage) { private val soneRescuer = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/SearchPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/SearchPageTest.kt index c93ac0c..94af5da 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/SearchPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/SearchPageTest.kt @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger /** * Unit test for [SearchPage]. */ -class SearchPageTest: WebPageTest2({ template, webInterface -> SearchPage(template, webInterface, ticker) }) { +class SearchPageTest: WebPageTest({ template, webInterface -> SearchPage(template, webInterface, ticker) }) { companion object { val ticker = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt index c872b08..10dfb6e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt @@ -21,7 +21,7 @@ import org.mockito.Mockito.verify /** * Unit test for [SoneTemplatePage]. */ -class SoneTemplatePageTest: WebPageTest2({ template, webInterface -> object : SoneTemplatePage("path.html", template, webInterface, true) {}}) { +class SoneTemplatePageTest: WebPageTest({ template, webInterface -> object : SoneTemplatePage("path.html", template, webInterface, true) {}}) { @Test fun `current sone is retrieved from web interface`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt index e16d001..cc77203 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt @@ -14,7 +14,7 @@ import org.mockito.Mockito.verify /** * Unit test for [TrustPage]. */ -class TrustPageTest: WebPageTest2(::TrustPage) { +class TrustPageTest: WebPageTest(::TrustPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPageTest.kt index 5bf7f85..a9f784e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPageTest.kt @@ -17,7 +17,7 @@ import org.mockito.Mockito.verify /** * Unit test for [UnbookmarkPage]. */ -class UnbookmarkPageTest: WebPageTest2(::UnbookmarkPage) { +class UnbookmarkPageTest: WebPageTest(::UnbookmarkPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePageTest.kt index 444a355..01721cd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePageTest.kt @@ -9,7 +9,7 @@ import org.mockito.Mockito.verify /** * Unit test for [UnfollowSonePage]. */ -class UnfollowSonePageTest: WebPageTest2(::UnfollowSonePage) { +class UnfollowSonePageTest: WebPageTest(::UnfollowSonePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt index d3dd60a..fe00729 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt @@ -11,7 +11,7 @@ import org.mockito.Mockito.verify /** * Unit test for [UnlikePage]. */ -class UnlikePageTest: WebPageTest2(::UnlikePage) { +class UnlikePageTest: WebPageTest(::UnlikePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePageTest.kt index 9cde13c..6d46922 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePageTest.kt @@ -14,7 +14,7 @@ import org.mockito.Mockito.verify /** * Unit test for [UnlockSonePage]. */ -class UnlockSonePageTest: WebPageTest2(::UnlockSonePage) { +class UnlockSonePageTest: WebPageTest(::UnlockSonePage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt index 1f5a31e..9d18162 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt @@ -14,7 +14,7 @@ import org.mockito.Mockito.verify /** * Unit test for [UntrustPage]. */ -class UntrustPageTest: WebPageTest2(::UntrustPage) { +class UntrustPageTest: WebPageTest(::UntrustPage) { @Test fun `page returns correct path`() { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UploadImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UploadImagePageTest.kt index 9c0d144..58e63a2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UploadImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UploadImagePageTest.kt @@ -20,7 +20,7 @@ import org.mockito.Mockito.verify /** * Unit test for [UploadImagePage]. */ -class UploadImagePageTest: WebPageTest2(::UploadImagePage) { +class UploadImagePageTest: WebPageTest(::UploadImagePage) { private val parentAlbum = mock().apply { whenever(id).thenReturn("parent-id") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt index e3259f5..b66f6cc 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt @@ -12,7 +12,7 @@ import org.junit.Test /** * Unit test for [ViewPostPage]. */ -class ViewPostPageTest: WebPageTest2(::ViewPostPage) { +class ViewPostPageTest: WebPageTest(::ViewPostPage) { private val post = mock() diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt index 7df6b7e..d7ff46d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt @@ -19,7 +19,7 @@ import org.junit.Test /** * Unit test for [ViewSonePage]. */ -class ViewSonePageTest: WebPageTest2(::ViewSonePage) { +class ViewSonePageTest: WebPageTest(::ViewSonePage) { init { whenever(currentSone.id).thenReturn("sone-id") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt new file mode 100644 index 0000000..fc59639 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt @@ -0,0 +1,251 @@ +package net.pterodactylus.sone.web.pages + +import com.google.common.eventbus.EventBus +import freenet.clients.http.ToadletContext +import freenet.support.SimpleReadOnlyArrayBucket +import freenet.support.api.HTTPRequest +import freenet.support.api.HTTPUploadedFile +import net.pterodactylus.sone.core.Preferences +import net.pterodactylus.sone.data.Album +import net.pterodactylus.sone.data.Image +import net.pterodactylus.sone.data.Post +import net.pterodactylus.sone.data.PostReply +import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.data.TemporaryImage +import net.pterodactylus.sone.freenet.wot.OwnIdentity +import net.pterodactylus.sone.test.deepMock +import net.pterodactylus.sone.test.get +import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.whenever +import net.pterodactylus.sone.utils.asList +import net.pterodactylus.sone.utils.asOptional +import net.pterodactylus.sone.web.WebInterface +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 +import net.pterodactylus.util.web.Method +import net.pterodactylus.util.web.Method.GET +import net.pterodactylus.util.web.Response +import org.junit.Assert.fail +import org.mockito.ArgumentMatchers.anyBoolean +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.ArgumentMatchers.anyLong +import org.mockito.ArgumentMatchers.anyString +import org.mockito.ArgumentMatchers.eq +import java.io.ByteArrayOutputStream +import java.net.URI +import java.nio.charset.Charset +import kotlin.text.Charsets.UTF_8 + +/** + * Base class for web page tests. + */ +open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePage = { _, _ -> mock() }) { + + val currentSone = mock() + val template = mock