X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FAlbumsTest.kt;h=1f938a3124a6d84443c12dca1c388488ff5ee8f5;hp=6044fd1fe85b1c17ce0a01c234f47869395c2173;hb=509b81185b3a1e82bb78308640d0d7b6b741d3e0;hpb=2b7b9baa754ba9d4a41b0abfaf946bd9146a10c9 diff --git a/src/test/kotlin/net/pterodactylus/sone/data/AlbumsTest.kt b/src/test/kotlin/net/pterodactylus/sone/data/AlbumsTest.kt index 6044fd1..1f938a3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/data/AlbumsTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/data/AlbumsTest.kt @@ -43,7 +43,7 @@ class AlbumsTest { assertThat(images.map(Image::id), containsInAnyOrder("image-1", "image-2", "image-3", "image-4")) } - private fun createImage(sone: IdOnlySone, id: String) = ImageImpl(id).modify().setSone(sone).update() + private fun createImage(sone: IdOnlySone, id: String, key: String? = null) = ImageImpl(id).modify().setSone(sone).setKey(key).update() @Test fun `allAlbums returns itself and all its subalbums`() { @@ -62,4 +62,56 @@ class AlbumsTest { assertThat(albums.indexOf(albumNestedInFirst), greaterThan(albums.indexOf(firstNestedAlbum))) } + @Test + fun `notEmpty finds album without images is empty`() { + val sone = IdOnlySone("sone") + val album = AlbumImpl(sone) + assertThat(notEmpty(album), equalTo(false)) + } + + @Test + fun `notEmpty finds album with one inserted image is not empty`() { + val sone = IdOnlySone("sone") + val album = AlbumImpl(sone) + album.addImage(createImage(sone, "1", "key")) + assertThat(notEmpty(album), equalTo(true)) + } + + @Test + fun `notEmpty finds album with one not-inserted image is empty`() { + val sone = IdOnlySone("sone") + val album = AlbumImpl(sone) + album.addImage(createImage(sone, "1")) + assertThat(notEmpty(album), equalTo(false)) + } + + @Test + fun `notEmpty finds album with empty subalbums is empty`() { + val sone = IdOnlySone("sone") + val album = AlbumImpl(sone) + val firstNestedAlbum = AlbumImpl(sone) + album.addAlbum(firstNestedAlbum) + assertThat(notEmpty(album), equalTo(false)) + } + + @Test + fun `notEmpty finds album with subalbum with not inserted image is empty`() { + val sone = IdOnlySone("sone") + val album = AlbumImpl(sone) + val firstNestedAlbum = AlbumImpl(sone) + firstNestedAlbum.addImage(createImage(sone, "1")) + album.addAlbum(firstNestedAlbum) + assertThat(notEmpty(album), equalTo(false)) + } + + @Test + fun `notEmpty finds album with subalbum with inserted image is not empty`() { + val sone = IdOnlySone("sone") + val album = AlbumImpl(sone) + val firstNestedAlbum = AlbumImpl(sone) + firstNestedAlbum.addImage(createImage(sone, "1", "key")) + album.addAlbum(firstNestedAlbum) + assertThat(notEmpty(album), equalTo(true)) + } + }