X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FSoneAccessorTest.kt;h=2ddab1530c259649ba43306bb1fb22eb67a646b5;hp=2fe40d40f3d95d617524fbe76899ec92882716a0;hb=HEAD;hpb=fecc40a37c481ea7c8d0aa5d13331834d165de6a diff --git a/src/test/kotlin/net/pterodactylus/sone/template/SoneAccessorTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/SoneAccessorTest.kt index 2fe40d4..2ddab15 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/SoneAccessorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/SoneAccessorTest.kt @@ -10,6 +10,7 @@ import net.pterodactylus.sone.data.Sone.SoneStatus.downloading import net.pterodactylus.sone.data.Sone.SoneStatus.idle import net.pterodactylus.sone.data.Sone.SoneStatus.inserting import net.pterodactylus.sone.data.Sone.SoneStatus.unknown +import net.pterodactylus.sone.data.impl.* import net.pterodactylus.sone.freenet.L10nText import net.pterodactylus.sone.freenet.wot.Identity import net.pterodactylus.sone.freenet.wot.OwnIdentity @@ -128,7 +129,7 @@ class SoneAccessorTest { @Test fun `accessor returns that the sone’s status is not unknown if it is not unknown`() { - whenever(sone.status).thenReturn(mock()) + whenever(sone.status).thenReturn(mock()) assertAccessorReturnValue("unknown", false) } @@ -140,7 +141,7 @@ class SoneAccessorTest { @Test fun `accessor returns that the sone’s status is not idle if it is not idle`() { - whenever(sone.status).thenReturn(mock()) + whenever(sone.status).thenReturn(mock()) assertAccessorReturnValue("idle", false) } @@ -152,7 +153,7 @@ class SoneAccessorTest { @Test fun `accessor returns that the sone’s status is not inserting if it is not inserting`() { - whenever(sone.status).thenReturn(mock()) + whenever(sone.status).thenReturn(mock()) assertAccessorReturnValue("inserting", false) } @@ -164,7 +165,7 @@ class SoneAccessorTest { @Test fun `accessor returns that the sone’s status is not downloading if it is not downloading`() { - whenever(sone.status).thenReturn(mock()) + whenever(sone.status).thenReturn(mock()) assertAccessorReturnValue("downloading", false) } @@ -217,24 +218,24 @@ class SoneAccessorTest { @Test fun `accessor returns all images in the correct order`() { - val images = listOf(mock(), mock(), mock(), mock(), mock()) - val firstAlbum = createAlbum(listOf(), listOf(images[0], images[3])) - val secondAlbum = createAlbum(listOf(), listOf(images[1], images[4], images[2])) - val rootAlbum = createAlbum(listOf(firstAlbum, secondAlbum), listOf()) + val images = (0 until 5).map { ImageImpl().modify().setSone(sone).update() } + val firstAlbum = createAlbum(emptyList(), listOf(images[0], images[3])) + val secondAlbum = createAlbum(emptyList(), listOf(images[1], images[4], images[2])) + val rootAlbum = createAlbum(listOf(firstAlbum, secondAlbum), emptyList()) whenever(sone.rootAlbum).thenReturn(rootAlbum) assertAccessorReturnValueMatches("allImages", contains(images[0], images[3], images[1], images[4], images[2])) } private fun createAlbum(albums: List, images: List) = - mock().apply { - whenever(this.albums).thenReturn(albums) - whenever(this.images).thenReturn(images) + AlbumImpl(sone).also { + albums.forEach(it::addAlbum) + images.forEach(it::addImage) } @Test fun `accessor returns all albums in the correct order`() { - val albums = listOf(mock(), mock(), mock(), mock(), mock()) - val rootAlbum = createAlbum(albums, listOf()) + val albums = (0 until 5).map { AlbumImpl(sone) } + val rootAlbum = createAlbum(albums, emptyList()) whenever(sone.rootAlbum).thenReturn(rootAlbum) assertAccessorReturnValueMatches("albums", contains(*albums.toTypedArray())) }