2 * Sone - AlbumsTest.kt - Copyright © 2019–2020 David ‘Bombe’ Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.data
20 import net.pterodactylus.sone.data.impl.*
21 import org.hamcrest.MatcherAssert.*
22 import org.hamcrest.Matchers.*
26 * Unit test for various helper method in `Albums.kt`.
31 fun `recursive list of all images for album is returned correctly`() {
32 val sone = IdOnlySone("sone")
33 val album = AlbumImpl(sone)
34 val firstNestedAlbum = AlbumImpl(sone)
35 val secondNestedAlbum = AlbumImpl(sone)
36 firstNestedAlbum.addImage(createImage(sone, "image-1"))
37 firstNestedAlbum.addImage(createImage(sone, "image-2"))
38 secondNestedAlbum.addImage(createImage(sone, "image-3"))
39 album.addImage(createImage(sone, "image-4"))
40 album.addAlbum(firstNestedAlbum)
41 album.addAlbum(secondNestedAlbum)
42 val images = album.allImages
43 assertThat(images.map(Image::id), containsInAnyOrder("image-1", "image-2", "image-3", "image-4"))
46 private fun createImage(sone: IdOnlySone, id: String) = ImageImpl(id).modify().setSone(sone).update()