feat: append volume to series name

closes #343, closes #132
This commit is contained in:
Gauthier Roebroeck 2020-10-22 18:02:07 +08:00
parent eb10a12013
commit 25677967db
2 changed files with 21 additions and 2 deletions

View file

@ -76,10 +76,13 @@ class ComicInfoProvider(
}
val genres = comicInfo.genre?.split(',')?.mapNotNull { it.trim().ifBlank { null } }
val series = comicInfo.series?.ifBlank { null }?.let { series ->
series + (comicInfo.volume?.let { " ($it)" } ?: "")
}
return SeriesMetadataPatch(
title = comicInfo.series?.ifBlank { null },
titleSort = comicInfo.series?.ifBlank { null },
title = series,
titleSort = series,
status = null,
summary = null,
readingDirection = readingDirection,

View file

@ -213,6 +213,22 @@ class ComicInfoProviderTest {
}
}
@Test
fun `given comicInfo with volume when getting series metadata then metadata patch is valid`() {
val comicInfo = ComicInfo().apply {
series = "series"
volume = 2020
}
every { mockMapper.readValue(any<ByteArray>(), ComicInfo::class.java) } returns comicInfo
val patch = comicInfoProvider.getSeriesMetadataFromBook(book, media)!!
with(patch) {
assertThat(title).isEqualTo("series (2020)")
}
}
@Test
fun `given comicInfo with incorrect values when getting series metadata then metadata patch is valid`() {
val comicInfo = ComicInfo().apply {