Corrected DepictedItem constructor arguments

This commit is contained in:
savsch 2025-01-15 22:55:21 +05:30
parent 936e50d327
commit 02655f7d18
3 changed files with 10 additions and 8 deletions

View file

@ -29,7 +29,7 @@ const val THUMB_IMAGE_SIZE = "70px"
data class DepictedItem constructor(
override val name: String,
val description: String?,
val primaryImage: String?,
val imageUrl: String?,
val instanceOfs: List<String>,
val commonsCategories: List<CategoryItem>,
var isSelected: Boolean,
@ -51,7 +51,9 @@ data class DepictedItem constructor(
constructor(entity: Entities.Entity, name: String, description: String) : this(
name,
description,
entity[IMAGE].primaryImageValue?.value,
entity[IMAGE].primaryImageValue?.let {
getImageUrl(it.value, THUMB_IMAGE_SIZE)
},
entity[INSTANCE_OF].toIds(),
entity[COMMONS_CATEGORY]?.map {
CategoryItem(
@ -66,8 +68,8 @@ data class DepictedItem constructor(
entity.id(),
)
val imageUrl: String?
get() = primaryImage?.let { getImageUrl(it, THUMB_IMAGE_SIZE) }
val primaryImage: String?
get() = imageUrl?.split('-')?.lastOrNull()
override fun equals(other: Any?) =
when {

View file

@ -18,7 +18,7 @@ import java.util.Date
fun depictedItem(
name: String = "label",
description: String = "desc",
primaryImage: String = "",
imageUrl: String = "",
instanceOfs: List<String> = listOf(),
commonsCategories: List<CategoryItem> = listOf(),
isSelected: Boolean = false,
@ -26,7 +26,7 @@ fun depictedItem(
) = DepictedItem(
name = name,
description = description,
primaryImage = primaryImage,
imageUrl = imageUrl,
instanceOfs = instanceOfs,
commonsCategories = commonsCategories,
isSelected = isSelected,

View file

@ -103,7 +103,7 @@ class CategoriesModelTest {
)
val depictedItemWithoutCategories =
depictedItem(
primaryImage = "P18"
imageUrl = "testUrl"
)
whenever(gpsCategoryModel.categoriesFromLocation)
@ -167,7 +167,7 @@ class CategoriesModelTest {
)
whenever(
categoryClient.getCategoriesOfImage(
"P18",
"testUrl",
25,
),
).thenReturn(