🔀 Merge branch 'release/v82'
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / KnownSonesPageTest.kt
index a816d23..23987b6 100644 (file)
@@ -1,6 +1,7 @@
 package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.*
+import net.pterodactylus.sone.data.impl.*
 import net.pterodactylus.sone.freenet.wot.*
 import net.pterodactylus.sone.test.*
 import net.pterodactylus.sone.utils.*
@@ -13,7 +14,7 @@ import org.junit.*
 /**
  * Unit test for [KnownSonesPage].
  */
-class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
+class KnownSonesPageTest : WebPageTest(::KnownSonesPage) {
 
        private val sones = listOf(
                        createSone(1000, 4, 7, 2, "sone2", true, true),
@@ -37,11 +38,12 @@ class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
                whenever(this.time).thenReturn(time)
                whenever(this.posts).thenReturn((0..(posts - 1)).map { mock<Post>() })
                whenever(this.replies).thenReturn((0..(replies - 1)).map { mock<PostReply>() }.toSet())
-               val album = mock<Album>()
-               whenever(album.images).thenReturn(((0..(images - 1)).map { mock<Image>() }))
-               val rootAlbum = mock<Album>().apply {
-                       whenever(albums).thenReturn(listOf(album))
+               val album = AlbumImpl(this)
+               repeat(images) {
+                       ImageImpl().modify().setSone(this).update()
+                                       .also(album::addImage)
                }
+               val rootAlbum = AlbumImpl(this).also { it.addAlbum(album) }
                whenever(this.rootAlbum).thenReturn(rootAlbum)
                whenever(this.profile).thenReturn(mock())
                whenever(id).thenReturn(name.toLowerCase())
@@ -73,7 +75,7 @@ class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
 
        @Test
        fun `page returns correct title`() {
-               whenever(l10n.getString("Page.KnownSones.Title")).thenReturn("known sones page title")
+               addTranslation("Page.KnownSones.Title", "known sones page title")
                assertThat(page.getPageTitle(soneRequest), equalTo("known sones page title"))
        }
 
@@ -237,17 +239,17 @@ class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
 
        @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"))
        }
 
 }