class AboutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer,
private val pluginVersion: PluginVersion,
private val pluginYear: PluginYear,
- private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.About.Title") {
+ private val pluginHomepage: PluginHomepage) : SoneTemplatePage("about.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.About.Title") {
override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
templateContext["version"] = pluginVersion.version
* Page that lets the user create a new album.
*/
@TemplatePath("/templates/createAlbum.html")
-class CreateAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class CreateAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("createAlbum.html", "Page.CreateAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* This page lets the user create a new [Post].
*/
@TemplatePath("/templates/createPost.html")
-class CreatePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class CreatePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("createPost.html", "Page.CreatePost.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* This page lets the user post a reply to a post.
*/
@TemplatePath("/templates/createReply.html")
-class CreateReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class CreateReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("createReply.html", "Page.CreateReply.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
*/
@MenuName("CreateSone")
@TemplatePath("/templates/createSone.html")
-class CreateSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class CreateSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("createSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.CreateSone.Title") {
private val logger = Logger.getLogger(CreateSonePage::class.java.name)
* Page that lets the user delete an {@link Album}.
*/
@TemplatePath("/templates/deleteAlbum.html")
-class DeleteAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DeleteAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("deleteAlbum.html", "Page.DeleteAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* Page that lets the user delete an {@link Image}.
*/
@TemplatePath("/templates/deleteImage.html")
-class DeleteImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DeleteImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("deleteImage.html", "Page.DeleteImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* Lets the user delete a post they made.
*/
@TemplatePath("/templates/deletePost.html")
-class DeletePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DeletePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("deletePost.html", "Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* Page that lets the user confirm the deletion of a profile field.
*/
@TemplatePath("/templates/deleteProfileField.html")
-class DeleteProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DeleteProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("deleteProfileField.html", "Page.DeleteProfileField.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* This page lets the user delete a reply.
*/
@TemplatePath("/templates/deleteReply.html")
-class DeleteReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DeleteReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("deleteReply.html", "Page.DeleteReply.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
*/
@MenuName("DeleteSone")
@TemplatePath("/templates/deleteSone.html")
-class DeleteSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DeleteSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("deleteSone.html", "Page.DeleteSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
/**
* Page that lets the user dismiss a notification.
*/
-class DismissNotificationPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DismissNotificationPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("dismissNotification.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
*
* @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
*/
-class DistrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class DistrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("distrust.html", "Page.Distrust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
/**
* Page that lets the user edit the name and description of an album.
*/
-class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("editAlbum.html", "Page.EditAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
/**
* Page that lets the user edit title and description of an {@link Image}.
*/
-class EditImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class EditImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("editImage.html", "Page.EditImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
/**
* This page lets the user follow another Sone.
*/
-class FollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class FollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("followSone.html", "Page.FollowSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
/**
* Page that delivers a {@link TemporaryImage} to the browser.
*/
-class GetImagePage @Inject constructor(webInterface: WebInterface): FreenetPage {
+class GetImagePage @Inject constructor(webInterface: WebInterface) : FreenetPage {
private val core = webInterface.core
*/
@MenuName("ImageBrowser")
@TemplatePath("/templates/imageBrowser.html")
-class ImageBrowserPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class ImageBrowserPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("imageBrowser.html", "Page.ImageBrowser.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
albums.paginate(soneRequest.core.preferences.imagesPerPage)
.turnTo(soneRequest.parameters["page"]?.toIntOrNull() ?: 0)
.also { pagination ->
- templateContext["albumPagination"] = pagination
- templateContext["albums"] = pagination.items
- }
+ templateContext["albumPagination"] = pagination
+ templateContext["albums"] = pagination.items
+ }
}
} else {
templateContext["soneRequested"] = true
*/
@MenuName("KnownSones")
@TemplatePath("/templates/knownSones.html")
-class KnownSonesPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class KnownSonesPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("knownSones.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.KnownSones.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
/**
* This page lets the user lock a [net.pterodactylus.sone.data.Sone] to prevent it from being inserted.
*/
-class LockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class LockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("lockSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.LockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
*/
@MenuName("Login")
@TemplatePath("/templates/login.html")
-class LoginPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class LoginPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("login.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Login.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
* Logs a user out.
*/
@MenuName("Logout")
-class LogoutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class LogoutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("logout.html", "Page.Logout.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
* Page that lets the user mark a number of [net.pterodactylus.sone.data.Sone]s, [Post]s, or
* [Replie][net.pterodactylus.sone.data.Reply]s as known.
*/
-class MarkAsKnownPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class MarkAsKnownPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("markAsKnown.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.MarkAsKnown.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
*/
@MenuName("New")
@TemplatePath("/templates/new.html")
-class NewPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class NewPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("new.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.New.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) =
*/
@MenuName("Options")
@TemplatePath("/templates/options.html")
-class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("options.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Options.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
/**
* [Page] implementation that delivers static files from the filesystem.
*/
-class ReloadingPage<R: Request> @Inject constructor(private val prefix: String, private val path: String, private val mimeType: String): Page<R> {
+class ReloadingPage<R : Request> @Inject constructor(private val prefix: String, private val path: String, private val mimeType: String) : Page<R> {
override fun isPrefixPage() = true
*/
@MenuName("Rescue")
@TemplatePath("/templates/rescue.html")
-class RescuePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class RescuePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("rescue.html", "Page.Rescue.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
class SearchPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, ticker: Ticker = Ticker.systemTicker()) :
SoneTemplatePage("search.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Search.Title") {
- @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ @Inject
+ constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
this(webInterface, loaders, templateRenderer, Ticker.systemTicker())
private val cache: Cache<Iterable<Phrase>, Pagination<Post>> = CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, MINUTES).build()
/**
* Page that lets the user unbookmark a post.
*/
-class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("unbookmark.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
/**
* Page that lets the user unlike a [net.pterodactylus.sone.data.Post] or [net.pterodactylus.sone.data.Reply].
*/
-class UnlikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class UnlikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("unlike.html", "Page.Unlike.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
/**
* This page lets the user unlock a [net.pterodactylus.sone.data.Sone] to allow its insertion.
*/
-class UnlockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class UnlockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("unlockSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.UnlockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
* Page implementation that lets the user upload an image.
*/
@TemplatePath("/templates/invalid.html")
-class UploadImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class UploadImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
LoggedInPage("uploadImage.html", "Page.UploadImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
ImageIO.read(it)
}
- private val ByteArray.mimeType get() = ByteArrayInputStream(this).use {
- ImageIO.createImageInputStream(it).use {
- ImageIO.getImageReaders(it).asSequence()
- .firstOrNull()?.originatingProvider?.mimeTypes?.firstOrNull()
- ?: UNKNOWN_MIME_TYPE
+ private val ByteArray.mimeType
+ get() = ByteArrayInputStream(this).use {
+ ImageIO.createImageInputStream(it).use {
+ ImageIO.getImageReaders(it).asSequence()
+ .firstOrNull()?.originatingProvider?.mimeTypes?.firstOrNull()
+ ?: UNKNOWN_MIME_TYPE
+ }
}
- }
}
* This page lets the user view a post and all its replies.
*/
@TemplatePath("/templates/viewPost.html")
-class ViewPostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class ViewPostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("viewPost.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.ViewPost.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
* Lets the user browser another Sone.
*/
@TemplatePath("/templates/viewSone.html")
-class ViewSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+class ViewSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
SoneTemplatePage("viewSone.html", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("About"))
+ assertThat(page.menuName, equalTo("About"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/about.html"))
+ assertThat(page.templatePath, equalTo("/templates/about.html"))
}
}
/**
* Unit test for [BookmarksPage].
*/
-class BookmarksPageTest: WebPageTest(::BookmarksPage) {
+class BookmarksPageTest : WebPageTest(::BookmarksPage) {
private val post1 = createLoadedPost(1000)
private val post2 = createLoadedPost(3000)
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Bookmarks"))
+ assertThat(page.menuName, equalTo("Bookmarks"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/bookmarks.html"))
+ assertThat(page.templatePath, equalTo("/templates/bookmarks.html"))
}
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/createAlbum.html"))
+ assertThat(page.templatePath, equalTo("/templates/createAlbum.html"))
}
}
/**
* Unit test for [CreatePostPage].
*/
-class CreatePostPageTest: WebPageTest(::CreatePostPage) {
+class CreatePostPageTest : WebPageTest(::CreatePostPage) {
@Test
fun `page returns correct path`() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<CreatePostPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<CreatePostPage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/createPost.html"))
+ assertThat(page.templatePath, equalTo("/templates/createPost.html"))
}
}
/**
* Unit test for [CreateReplyPage].
*/
-class CreateReplyPageTest: WebPageTest(::CreateReplyPage) {
+class CreateReplyPageTest : WebPageTest(::CreateReplyPage) {
@Test
fun `page returns correct path`() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<CreateReplyPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<CreateReplyPage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/createReply.html"))
+ assertThat(page.templatePath, equalTo("/templates/createReply.html"))
}
}
@Test
fun `page is annotated with the correct menuname`() {
- assertThat(page.menuName, equalTo("CreateSone"))
+ assertThat(page.menuName, equalTo("CreateSone"))
}
@Test
fun `page is annotated with the correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/createSone.html"))
+ assertThat(page.templatePath, equalTo("/templates/createSone.html"))
}
}
/**
* Unit test for [DeleteAlbumPage].
*/
-class DeleteAlbumPageTest: WebPageTest(::DeleteAlbumPage) {
+class DeleteAlbumPageTest : WebPageTest(::DeleteAlbumPage) {
private val sone = mock<Sone>()
private val album = mock<Album>()
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/deleteAlbum.html"))
+ assertThat(page.templatePath, equalTo("/templates/deleteAlbum.html"))
}
}
/**
* Unit test for [DeleteImagePage].
*/
-class DeleteImagePageTest: WebPageTest(::DeleteImagePage) {
+class DeleteImagePageTest : WebPageTest(::DeleteImagePage) {
private val image = mock<Image>()
private val sone = mock<Sone>()
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<DeleteImagePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<DeleteImagePage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/deleteImage.html"))
+ assertThat(page.templatePath, equalTo("/templates/deleteImage.html"))
}
}
/**
* Unit test for [DeletePostPage].
*/
-class DeletePostPageTest: WebPageTest(::DeletePostPage) {
+class DeletePostPageTest : WebPageTest(::DeletePostPage) {
private val post = mock<Post>()
private val sone = mock<Sone>()
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("deletePost.html"))
+ assertThat(page.path, equalTo("deletePost.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<DeletePostPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<DeletePostPage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/deletePost.html"))
+ assertThat(page.templatePath, equalTo("/templates/deletePost.html"))
}
}
/**
* Unit test for [DeleteProfileFieldPage].
*/
-class DeleteProfileFieldPageTest: WebPageTest(::DeleteProfileFieldPage) {
+class DeleteProfileFieldPageTest : WebPageTest(::DeleteProfileFieldPage) {
private val profile = Profile(currentSone)
private val field = profile.addField("name")
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/deleteProfileField.html"))
+ assertThat(page.templatePath, equalTo("/templates/deleteProfileField.html"))
}
}
/**
* Unit test for [DeleteReplyPage].
*/
-class DeleteReplyPageTest: WebPageTest(::DeleteReplyPage) {
+class DeleteReplyPageTest : WebPageTest(::DeleteReplyPage) {
private val sone = mock<Sone>()
private val reply = mock<PostReply>()
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("deleteReply.html"))
+ assertThat(page.path, equalTo("deleteReply.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/deleteReply.html"))
+ assertThat(page.templatePath, equalTo("/templates/deleteReply.html"))
}
}
/**
* Unit test for [DeleteSonePage].
*/
-class DeleteSonePageTest: WebPageTest(::DeleteSonePage) {
+class DeleteSonePageTest : WebPageTest(::DeleteSonePage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("deleteSone.html"))
+ assertThat(page.path, equalTo("deleteSone.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- whenever(l10n.getString("Page.DeleteSone.Title")).thenReturn("delete sone page")
+ whenever(l10n.getString("Page.DeleteSone.Title")).thenReturn("delete sone page")
assertThat(page.getPageTitle(soneRequest), equalTo("delete sone page"))
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("DeleteSone"))
+ assertThat(page.menuName, equalTo("DeleteSone"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/deleteSone.html"))
+ assertThat(page.templatePath, equalTo("/templates/deleteSone.html"))
}
}
/**
* Unit test for [DismissNotificationPage].
*/
-class DismissNotificationPageTest: WebPageTest(::DismissNotificationPage) {
+class DismissNotificationPageTest : WebPageTest(::DismissNotificationPage) {
private val notification = mock<Notification>()
/**
* Unit test for [DistrustPage].
*/
-class DistrustPageTest: WebPageTest(::DistrustPage) {
+class DistrustPageTest : WebPageTest(::DistrustPage) {
@Test
fun `page returns correct path`() {
/**
* Unit test for [EditAlbumPage].
*/
-class EditAlbumPageTest: WebPageTest(::EditAlbumPage) {
+class EditAlbumPageTest : WebPageTest(::EditAlbumPage) {
private val album = mock<Album>()
private val parentAlbum = mock<Album>()
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<EditAlbumPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<EditAlbumPage>(), notNullValue())
}
}
/**
* Unit test for [EditImagePage].
*/
-class EditImagePageTest: WebPageTest(::EditImagePage) {
+class EditImagePageTest : WebPageTest(::EditImagePage) {
private val image = mock<Image>()
private val modifier = mockBuilder<Modifier>()
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
whenever(l10n.getString("Page.EditImage.Title")).thenReturn("edit image page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("edit image page title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("edit image page title"))
}
@Test
/**
* Unit test for [EditProfileFieldPage].
*/
-class EditProfileFieldPageTest: WebPageTest(::EditProfileFieldPage) {
+class EditProfileFieldPageTest : WebPageTest(::EditProfileFieldPage) {
private val profile = Profile(currentSone)
private val field = profile.addField("Name")
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("editProfileField.html"))
+ assertThat(page.path, equalTo("editProfileField.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
whenever(l10n.getString("Page.EditProfileField.Title")).thenReturn("edit profile field title")
- assertThat(page.getPageTitle(soneRequest), equalTo("edit profile field title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("edit profile field title"))
}
@Test
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/editProfileField.html"))
+ assertThat(page.templatePath, equalTo("/templates/editProfileField.html"))
}
}
/**
* Unit test for [EditProfilePage].
*/
-class EditProfilePageTest: WebPageTest(::EditProfilePage) {
+class EditProfilePageTest : WebPageTest(::EditProfilePage) {
private val profile = Profile(currentSone)
private val firstField = profile.addField("First Field")
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("editProfile.html"))
+ assertThat(page.path, equalTo("editProfile.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- whenever(l10n.getString("Page.EditProfile.Title")).thenReturn("edit profile page title")
+ whenever(l10n.getString("Page.EditProfile.Title")).thenReturn("edit profile page title")
assertThat(page.getPageTitle(soneRequest), equalTo("edit profile page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<EditProfilePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<EditProfilePage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("EditProfile"))
+ assertThat(page.menuName, equalTo("EditProfile"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/editProfile.html"))
+ assertThat(page.templatePath, equalTo("/templates/editProfile.html"))
}
}
/**
* Unit test for [FollowSonePage].
*/
-class FollowSonePageTest: WebPageTest(::FollowSonePage) {
+class FollowSonePageTest : WebPageTest(::FollowSonePage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("followSone.html"))
+ assertThat(page.path, equalTo("followSone.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- whenever(l10n.getString("Page.FollowSone.Title")).thenReturn("follow sone page title")
+ whenever(l10n.getString("Page.FollowSone.Title")).thenReturn("follow sone page title")
assertThat(page.getPageTitle(soneRequest), equalTo("follow sone page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<FollowSonePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<FollowSonePage>(), notNullValue())
}
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<GetImagePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<GetImagePage>(), notNullValue())
}
}
/**
* Unit test for [ImageBrowserPage].
*/
-class ImageBrowserPageTest: WebPageTest(::ImageBrowserPage) {
+class ImageBrowserPageTest : WebPageTest(::ImageBrowserPage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("imageBrowser.html"))
+ assertThat(page.path, equalTo("imageBrowser.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
whenever(l10n.getString("Page.ImageBrowser.Title")).thenReturn("image browser page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("image browser page title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("image browser page title"))
}
@Test
@Test
fun `page is link-excepted`() {
- assertThat(page.isLinkExcepted(URI("")), equalTo(true))
+ assertThat(page.isLinkExcepted(URI("")), equalTo(true))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<ImageBrowserPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<ImageBrowserPage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("ImageBrowser"))
+ assertThat(page.menuName, equalTo("ImageBrowser"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/imageBrowser.html"))
+ assertThat(page.templatePath, equalTo("/templates/imageBrowser.html"))
}
}
/**
* Unit test for [IndexPage].
*/
-class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> IndexPage(webInterface, loaders, templateRenderer, postVisibilityFilter) }) {
+class IndexPageTest : WebPageTest({ webInterface, loaders, templateRenderer -> IndexPage(webInterface, loaders, templateRenderer, postVisibilityFilter) }) {
companion object {
private val postVisibilityFilter = mock<PostVisibilityFilter>()
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("index.html"))
+ assertThat(page.path, equalTo("index.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("index page title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("index page title"))
}
@Before
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<IndexPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<IndexPage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Index"))
+ assertThat(page.menuName, equalTo("Index"))
}
@Test
/**
* Unit test for [KnownSonesPage].
*/
-class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
+class KnownSonesPageTest : WebPageTest(::KnownSonesPage) {
private val sones = listOf(
createSone(1000, 4, 7, 2, "sone2", true, true),
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<KnownSonesPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<KnownSonesPage>(), notNullValue())
}
@Test
fun `page is annotated with the correct menuname`() {
- assertThat(page.menuName, equalTo("KnownSones"))
+ assertThat(page.menuName, equalTo("KnownSones"))
}
@Test
fun `page is annotated with corrrect template path`() {
- assertThat(page.templatePath, equalTo("/templates/knownSones.html"))
+ assertThat(page.templatePath, equalTo("/templates/knownSones.html"))
}
}
/**
* Unit test for [LikePage].
*/
-class LikePageTest: WebPageTest(::LikePage) {
+class LikePageTest : WebPageTest(::LikePage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("like.html"))
+ assertThat(page.path, equalTo("like.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- addTranslation("Page.Like.Title", "like page title")
+ addTranslation("Page.Like.Title", "like page title")
assertThat(page.getPageTitle(soneRequest), equalTo("like page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<LikePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<LikePage>(), notNullValue())
}
}
/**
* Unit test for [LockSonePage].
*/
-class LockSonePageTest: WebPageTest(::LockSonePage) {
+class LockSonePageTest : WebPageTest(::LockSonePage) {
@Test
fun `page returns correct path`() {
@Test
fun `page does not require login`() {
- assertThat(page.requiresLogin(), equalTo(false))
+ assertThat(page.requiresLogin(), equalTo(false))
}
@Test
fun `page returns correct title`() {
- addTranslation("Page.LockSone.Title", "lock Sone page title")
+ addTranslation("Page.LockSone.Title", "lock Sone page title")
assertThat(page.getPageTitle(soneRequest), equalTo("lock Sone page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<LockSonePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<LockSonePage>(), notNullValue())
}
}
/**
* Unit test for [LoginPage].
*/
-class LoginPageTest: WebPageTest(::LoginPage) {
+class LoginPageTest : WebPageTest(::LoginPage) {
private val sones = listOf(createSone("Sone", "Test"), createSone("Test"), createSone("Sone"))
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("login.html"))
+ assertThat(page.path, equalTo("login.html"))
}
@Test
fun `page does not require login`() {
- assertThat(page.requiresLogin(), equalTo(false))
+ assertThat(page.requiresLogin(), equalTo(false))
}
@Test
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<LoginPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<LoginPage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Login"))
+ assertThat(page.menuName, equalTo("Login"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/login.html"))
+ assertThat(page.templatePath, equalTo("/templates/login.html"))
}
}
/**
* Unit test for [LogoutPage].
*/
-class LogoutPageTest: WebPageTest(::LogoutPage) {
+class LogoutPageTest : WebPageTest(::LogoutPage) {
@Test
fun `page returns correct path`() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<LogoutPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<LogoutPage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Logout"))
+ assertThat(page.menuName, equalTo("Logout"))
}
}
/**
* Unit test for [MarkAsKnownPage].
*/
-class MarkAsKnownPageTest: WebPageTest(::MarkAsKnownPage) {
+class MarkAsKnownPageTest : WebPageTest(::MarkAsKnownPage) {
@Test
fun `page returns correct path`() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<MarkAsKnownPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<MarkAsKnownPage>(), notNullValue())
}
}
/**
* Unit test for [NewPage].
*/
-class NewPageTest: WebPageTest(::NewPage) {
+class NewPageTest : WebPageTest(::NewPage) {
@Before
fun setupNumberOfPostsPerPage() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<NewPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<NewPage>(), notNullValue())
}
@Test
fun `page is annotated with the correct menuname`() {
- assertThat(page.menuName, equalTo("New"))
+ assertThat(page.menuName, equalTo("New"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/new.html"))
+ assertThat(page.templatePath, equalTo("/templates/new.html"))
}
}
/**
* Unit test for [OptionsPage].
*/
-class OptionsPageTest: WebPageTest(::OptionsPage) {
+class OptionsPageTest : WebPageTest(::OptionsPage) {
@Before
fun setupPreferences() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<OptionsPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<OptionsPage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Options"))
+ assertThat(page.menuName, equalTo("Options"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/options.html"))
+ assertThat(page.templatePath, equalTo("/templates/options.html"))
}
}
*/
class ReloadingPageTest {
- @Rule @JvmField val tempFolder = TemporaryFolder()
+ @Rule
+ @JvmField
+ val tempFolder = TemporaryFolder()
private val folder by lazy { tempFolder.newFolder()!! }
private val page by lazy { ReloadingPage<FreenetRequest>("/prefix/", folder.path, "text/plain") }
private val webPageTest = WebPageTest()
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<ReloadingPage<*>>(), notNullValue())
+ assertThat(baseInjector.getInstance<ReloadingPage<*>>(), notNullValue())
}
}
/**
* Unit test for [RescuePage].
*/
-class RescuePageTest: WebPageTest(::RescuePage) {
+class RescuePageTest : WebPageTest(::RescuePage) {
private val soneRescuer = mock<SoneRescuer>()
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<RescuePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<RescuePage>(), notNullValue())
}
@Test
fun `page is annotated with correct menuname`() {
- assertThat(page.menuName, equalTo("Rescue"))
+ assertThat(page.menuName, equalTo("Rescue"))
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/rescue.html"))
+ assertThat(page.templatePath, equalTo("/templates/rescue.html"))
}
}
/**
* Unit test for [SearchPage].
*/
-class SearchPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> SearchPage(webInterface, loaders, templateRenderer, ticker) }) {
+class SearchPageTest : WebPageTest({ webInterface, loaders, templateRenderer -> SearchPage(webInterface, loaders, templateRenderer, ticker) }) {
companion object {
val ticker = mock<Ticker>()
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<SearchPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<SearchPage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/search.html"))
+ assertThat(page.templatePath, equalTo("/templates/search.html"))
}
}
@Test
fun `handle request with sone request is called`() {
var called = false
- val page = object : SoneTemplatePage("path.html", webInterface, loaders, templateRenderer) {
- override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
- called = true
- }
- }
+ val page = object : SoneTemplatePage("path.html", webInterface, loaders, templateRenderer) {
+ override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+ called = true
+ }
+ }
page.processTemplate(freenetRequest, templateContext)
assertThat(called, equalTo(true))
}
/**
* Unit test for [TrustPage].
*/
-class TrustPageTest: WebPageTest(::TrustPage) {
+class TrustPageTest : WebPageTest(::TrustPage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("trust.html"))
+ assertThat(page.path, equalTo("trust.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- addTranslation("Page.Trust.Title", "title trust page")
+ addTranslation("Page.Trust.Title", "title trust page")
assertThat(page.getPageTitle(soneRequest), equalTo("title trust page"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<TrustPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<TrustPage>(), notNullValue())
}
}
/**
* Unit test for [UnbookmarkPage].
*/
-class UnbookmarkPageTest: WebPageTest(::UnbookmarkPage) {
+class UnbookmarkPageTest : WebPageTest(::UnbookmarkPage) {
@Test
fun `page returns correct path`() {
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<UnbookmarkPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<UnbookmarkPage>(), notNullValue())
}
}
/**
* Unit test for [UnfollowSonePage].
*/
-class UnfollowSonePageTest: WebPageTest(::UnfollowSonePage) {
+class UnfollowSonePageTest : WebPageTest(::UnfollowSonePage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("unfollowSone.html"))
+ assertThat(page.path, equalTo("unfollowSone.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct page title`() {
- addTranslation("Page.UnfollowSone.Title", "unfollow page title")
+ addTranslation("Page.UnfollowSone.Title", "unfollow page title")
assertThat(page.getPageTitle(soneRequest), equalTo("unfollow page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<UnfollowSonePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<UnfollowSonePage>(), notNullValue())
}
}
/**
* Unit test for [UnlikePage].
*/
-class UnlikePageTest: WebPageTest(::UnlikePage) {
+class UnlikePageTest : WebPageTest(::UnlikePage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("unlike.html"))
+ assertThat(page.path, equalTo("unlike.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
addTranslation("Page.Unlike.Title", "unlike page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("unlike page title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("unlike page title"))
}
@Test
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<UnlikePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<UnlikePage>(), notNullValue())
}
}
/**
* Unit test for [UnlockSonePage].
*/
-class UnlockSonePageTest: WebPageTest(::UnlockSonePage) {
+class UnlockSonePageTest : WebPageTest(::UnlockSonePage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("unlockSone.html"))
+ assertThat(page.path, equalTo("unlockSone.html"))
}
@Test
fun `page does not require login`() {
- assertThat(page.requiresLogin(), equalTo(false))
+ assertThat(page.requiresLogin(), equalTo(false))
}
@Test
fun `page returns correct title`() {
addTranslation("Page.UnlockSone.Title", "unlock page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("unlock page title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("unlock page title"))
}
@Test
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<UnlockSonePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<UnlockSonePage>(), notNullValue())
}
}
/**
* Unit test for [UntrustPage].
*/
-class UntrustPageTest: WebPageTest(::UntrustPage) {
+class UntrustPageTest : WebPageTest(::UntrustPage) {
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("untrust.html"))
+ assertThat(page.path, equalTo("untrust.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
addTranslation("Page.Untrust.Title", "untrust page title")
- assertThat(page.getPageTitle(soneRequest), equalTo("untrust page title"))
+ assertThat(page.getPageTitle(soneRequest), equalTo("untrust page title"))
}
@Test
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<UntrustPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<UntrustPage>(), notNullValue())
}
}
/**
* Unit test for [UploadImagePage].
*/
-class UploadImagePageTest: WebPageTest(::UploadImagePage) {
+class UploadImagePageTest : WebPageTest(::UploadImagePage) {
private val parentAlbum = mock<Album>().apply {
whenever(id).thenReturn("parent-id")
@Test
fun `page returns correct path`() {
- assertThat(page.path, equalTo("uploadImage.html"))
+ assertThat(page.path, equalTo("uploadImage.html"))
}
@Test
fun `page requires login`() {
- assertThat(page.requiresLogin(), equalTo(true))
+ assertThat(page.requiresLogin(), equalTo(true))
}
@Test
fun `page returns correct title`() {
- addTranslation("Page.UploadImage.Title", "upload image page title")
+ addTranslation("Page.UploadImage.Title", "upload image page title")
assertThat(page.getPageTitle(soneRequest), equalTo("upload image page title"))
}
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<UploadImagePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<UploadImagePage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/invalid.html"))
+ assertThat(page.templatePath, equalTo("/templates/invalid.html"))
}
}
/**
* Unit test for [ViewPostPage].
*/
-class ViewPostPageTest: WebPageTest(::ViewPostPage) {
+class ViewPostPageTest : WebPageTest(::ViewPostPage) {
private val post = mock<Post>()
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<ViewPostPage>(), notNullValue())
+ assertThat(baseInjector.getInstance<ViewPostPage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/viewPost.html"))
+ assertThat(page.templatePath, equalTo("/templates/viewPost.html"))
}
}
/**
* Unit test for [ViewSonePage].
*/
-class ViewSonePageTest: WebPageTest(::ViewSonePage) {
+class ViewSonePageTest : WebPageTest(::ViewSonePage) {
init {
whenever(currentSone.id).thenReturn("sone-id")
@Test
fun `page can be created by dependency injection`() {
- assertThat(baseInjector.getInstance<ViewSonePage>(), notNullValue())
+ assertThat(baseInjector.getInstance<ViewSonePage>(), notNullValue())
}
@Test
fun `page is annotated with correct template path`() {
- assertThat(page.templatePath, equalTo("/templates/viewSone.html"))
+ assertThat(page.templatePath, equalTo("/templates/viewSone.html"))
}
}
val httpRequest = mock<HTTPRequest>()
val freenetRequest = mock<FreenetRequest>()
+
init {
whenever(freenetRequest.l10n).thenReturn(l10n)
whenever(freenetRequest.sessionManager).thenReturn(sessionManager)
whenever(freenetRequest.uri).thenReturn(mock())
}
+
val soneRequest by lazy { freenetRequest.toSoneRequest(core, webInterface) }
val templateContext = TemplateContext()
val toadletContext = deepMock<ToadletContext>()
whenever(core.getPostReply(anyString())).then { allPostReplies[it[0]] }
whenever(core.getReplies(anyString())).then { perPostReplies[it[0]].asList() }
whenever(core.getAlbum(anyString())).then { allAlbums[it[0]] }
- whenever(core.getImage(anyString())).then { allImages[it[0]]}
- whenever(core.getImage(anyString(), anyBoolean())).then { allImages[it[0]]}
+ whenever(core.getImage(anyString())).then { allImages[it[0]] }
+ whenever(core.getImage(anyString(), anyBoolean())).then { allImages[it[0]] }
whenever(core.getTemporaryImage(anyString())).thenReturn(null)
}
whenever(httpRequest.getPartAsStringFailsafe(anyString(), anyInt())).then { postRequestParameters[it[0]]?.decode()?.take(it[1]) ?: "" }
whenever(httpRequest.getUploadedFile(anyString())).then {
it.get<String>(0).takeIf { it in uploadedFileNames }
- ?.let { name -> UploadedFile(uploadedFileNames[name]!!, uploadedFileContentTypes[name]!!, uploadedFileResources[name]!!)
- }
+ ?.let { name ->
+ UploadedFile(uploadedFileNames[name]!!, uploadedFileContentTypes[name]!!, uploadedFileResources[name]!!)
+ }
}
}
- private class UploadedFile(private val filename: String, private val contentType: String, private val resourceName: String): HTTPUploadedFile {
+ private class UploadedFile(private val filename: String, private val contentType: String, private val resourceName: String) : HTTPUploadedFile {
override fun getFilename() = filename
override fun getContentType() = contentType
override fun getData() = javaClass.getResourceAsStream(resourceName).readBytes().let(::SimpleReadOnlyArrayBucket)