🎨 Use Kotlin arrow type instead of Predicate
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / IndexPageTest.kt
index ba0f216..29f4a9c 100644 (file)
@@ -16,7 +16,7 @@ import org.mockito.*
 /**
  * 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>()
@@ -24,23 +24,23 @@ class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> In
 
        @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"))
+               addTranslation("Page.Index.Title", "index page title")
+               assertThat(page.getPageTitle(soneRequest), equalTo("index page title"))
        }
 
        @Before
        fun setupPostVisibilityFilter() {
-               whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn(Predicate<Post> { true })
+               whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn { true }
        }
 
        @Before
@@ -107,7 +107,7 @@ class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> In
                val followedPosts = listOf(createPost(2500, true), createPost(1500))
                whenever(followedSone.posts).thenReturn(followedPosts)
                whenever(currentSone.friends).thenReturn(listOf("followed1", "followed2"))
-               whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn(Predicate<Post> { (it?.time ?: 10000) < 2500 })
+               whenever(postVisibilityFilter.isVisible(ArgumentMatchers.eq(currentSone))).thenReturn { (it?.time ?: 10000) < 2500 }
                addSone("followed1", followedSone)
                page.processTemplate(freenetRequest, templateContext)
                @Suppress("UNCHECKED_CAST")
@@ -150,12 +150,12 @@ class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> In
 
        @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