diff --git a/Backend/mapping-kotlin/build.gradle.kts b/Backend/mapping-kotlin/build.gradle.kts index f81c811..942fca7 100644 --- a/Backend/mapping-kotlin/build.gradle.kts +++ b/Backend/mapping-kotlin/build.gradle.kts @@ -6,6 +6,7 @@ plugins { kotlin("plugin.spring") version kotlinVersion id("org.springframework.boot") version "2.4.0" id("io.spring.dependency-management") version "1.0.10.RELEASE" + kotlin("kapt") version kotlinVersion } group = "com.staffinghub.coding.challenges" @@ -13,11 +14,24 @@ version = "0.0.1-SNAPSHOT" repositories { mavenCentral() + maven { + url = uri("https://maven.pkg.github.com/liodali/KotlinMapster") + credentials { + username = "{USER_NAME}" + password = "{TOKEN}" + } + } } dependencies { implementation("org.springframework.boot:spring-boot-starter-web") testImplementation("org.springframework.boot:spring-boot-starter-test") + implementation ("com.hamza.dali:mapster-ktx:0.4.0") + implementation("org.mapstruct:mapstruct:1.5.3.Final") + testImplementation ("io.kotest:kotest-property:4.0.3") + testImplementation ("org.mockito:mockito-core:3.+") + testImplementation ("org.mockito:mockito-inline:3.11.2") + kapt("org.mapstruct:mapstruct-processor:1.5.3.Final") } tasks { diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/controllers/ArticleController.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/controllers/ArticleController.kt index e110bb6..1ac9de6 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/controllers/ArticleController.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/controllers/ArticleController.kt @@ -2,6 +2,7 @@ package com.staffinghub.coding.challenges.mapping.controllers import com.staffinghub.coding.challenges.mapping.models.dto.ArticleDto import com.staffinghub.coding.challenges.mapping.services.ArticleService +import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.* @RestController @@ -12,6 +13,7 @@ class ArticleController( @GetMapping fun list(): List = articleService.list() + @ResponseStatus(HttpStatus.NOT_FOUND) @GetMapping("/{id}") fun details(@PathVariable id: Long): ArticleDto = articleService.articleForId(id) diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleBlockDtoFactory.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleBlockDtoFactory.kt new file mode 100644 index 0000000..ca45989 --- /dev/null +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleBlockDtoFactory.kt @@ -0,0 +1,55 @@ +package com.staffinghub.coding.challenges.mapping.models.dto.blocks + +import com.staffinghub.coding.challenges.mapping.models.db.Image +import com.staffinghub.coding.challenges.mapping.models.db.ImageSize +import com.staffinghub.coding.challenges.mapping.models.db.blocks.ArticleBlock +import org.mapstruct.ObjectFactory +import org.springframework.stereotype.Component +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.TextBlock as TextBlockDto +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.VideoBlock as VideoBlockDto +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.ImageBlock as ImageBlockDto +import com.staffinghub.coding.challenges.mapping.models.db.blocks.* +import com.staffinghub.coding.challenges.mapping.models.dto.ImageDto + +@Component +class ArticleBlockDtoFactory { + @ObjectFactory + fun createArticleBlockDto(articleBlock: ArticleBlock): ArticleBlockDto { + return when (articleBlock) { + is TextBlock -> TextBlockDto( + text = articleBlock.text, + sortIndex = articleBlock.sortIndex + ) + + is ImageBlock -> { + ImageBlockDto( + image = articleBlock.image?.let { mapToImageDto(it) } ?: ImageDto(-1, "", ImageSize.SMALL), + sortIndex = articleBlock.sortIndex + ) + } + + is VideoBlock -> VideoBlockDto( + url = articleBlock.url, + type = articleBlock.type, + sortIndex = articleBlock.sortIndex + ) + + is GalleryBlock -> GalleryBlockDto( + images = articleBlock.images.mapNotNull { mapToImageDto(it) } ?: emptyList(), + sortIndex = articleBlock.sortIndex + ) + + else -> throw IllegalArgumentException("Unknown ArticleBlock type") + } + } + + private fun mapToImageDto(image: Image?): ImageDto? { + return image?.let { + ImageDto( + id = it.id, + url = it.url, + imageSize = it.imageSize + ) + } + } +} diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapper.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapper.kt index 3d0bcf2..4cd0cba 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapper.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapper.kt @@ -2,14 +2,23 @@ package com.staffinghub.coding.challenges.mapping.mappers import com.staffinghub.coding.challenges.mapping.models.db.Article import com.staffinghub.coding.challenges.mapping.models.dto.ArticleDto +import mapper.adaptTo +import org.mapstruct.factory.Mappers import org.springframework.stereotype.Component import java.util.* @Component class ArticleMapper { - fun map(article: Article?): ArticleDto { - //TODO - return ArticleDto(0, "", "", "", emptyList()) + var mapperStruct: ArticleMapperMapstruct = Mappers.getMapper(ArticleMapperMapstruct::class.java) + fun map(article: Article): ArticleDto { + return article.adaptTo(ArticleDto::class) + } + + /** + * Object mapper using Mapstruct as alternative to Mapster Dependency + */ + fun mapStructMap(article: Article): ArticleDto { + return mapperStruct.mapToArticleDto(article) } // Not part of the challenge / Nicht Teil dieser Challenge. diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapperMapstruct.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapperMapstruct.kt new file mode 100644 index 0000000..bd8278a --- /dev/null +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/mappers/ArticleMapperMapstruct.kt @@ -0,0 +1,51 @@ +package com.staffinghub.coding.challenges.mapping.mappers + +import com.staffinghub.coding.challenges.mapping.models.db.Article +import com.staffinghub.coding.challenges.mapping.models.db.blocks.* +import com.staffinghub.coding.challenges.mapping.models.dto.ArticleDto +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.ArticleBlockDto +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.ArticleBlockDtoFactory +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.GalleryBlockDto +import org.mapstruct.* +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.TextBlock as TextBlockDto +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.VideoBlock as VideoBlockDto +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.ImageBlock as ImageBlockDto +import org.springframework.stereotype.Component + +@Component +@Mapper(uses = [ArticleBlockDtoFactory::class]) +interface ArticleMapperMapstruct { + + fun mapToGalleryBlockDto(gallery: GalleryBlock): GalleryBlockDto + + fun mapToTextBlockDto(textBlock: TextBlock): TextBlockDto + + fun mapToImageBlockDto(imageBlock: ImageBlock): ImageBlockDto + + fun mapToVideoBlockDto(videoBlock: VideoBlock): VideoBlockDto + + fun mapToArticleDto(article: Article): ArticleDto { + return ArticleDto( + id = article.id, + title = article.title, + description = article.description.toString(), + author = article.author.toString(), + blocks = mapBlocksToDto(article.blocks) + ) + } + + @IterableMapping(elementTargetType = ArticleBlockDto::class) + fun mapBlocksToDto(blocks: Collection): Collection { + return blocks.map { mapToArticleBlockDto(it) } + } + + fun mapToArticleBlockDto(articleBlock: ArticleBlock): ArticleBlockDto { + return when (articleBlock) { + is TextBlock -> mapToTextBlockDto(articleBlock) + is ImageBlock -> mapToImageBlockDto(articleBlock) + is VideoBlock -> mapToVideoBlockDto(articleBlock) + is GalleryBlock -> mapToGalleryBlockDto(articleBlock) + else -> throw IllegalArgumentException("Unknown ArticleBlock type") + } + } +} \ No newline at end of file diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ArticleBlockDto.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ArticleBlockDto.kt index b643bc8..a9fff5c 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ArticleBlockDto.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ArticleBlockDto.kt @@ -1,5 +1,8 @@ package com.staffinghub.coding.challenges.mapping.models.dto.blocks -interface ArticleBlockDto { +interface ArticleBlockDto : Comparable { val sortIndex: Int + override fun compareTo(other: ArticleBlockDto): Int { + return compareValuesBy(this, other) { it.sortIndex } + } } diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/GalleryBlockDto.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/GalleryBlockDto.kt index a940018..d134918 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/GalleryBlockDto.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/GalleryBlockDto.kt @@ -5,4 +5,8 @@ import com.staffinghub.coding.challenges.mapping.models.dto.ImageDto data class GalleryBlockDto( var images: List, override val sortIndex: Int, -) : ArticleBlockDto +) : ArticleBlockDto, Comparable { + override fun compareTo(other: ArticleBlockDto): Int { + return compareValuesBy(this, other) { it.sortIndex } + } +} \ No newline at end of file diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ImageBlock.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ImageBlock.kt index 1bd7075..76ac998 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ImageBlock.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/ImageBlock.kt @@ -5,4 +5,8 @@ import com.staffinghub.coding.challenges.mapping.models.dto.ImageDto data class ImageBlock( var image: ImageDto, override val sortIndex: Int, -) : ArticleBlockDto +) : ArticleBlockDto, Comparable { + override fun compareTo(other: ArticleBlockDto): Int { + return compareValuesBy(this, other) { it.sortIndex } + } +} \ No newline at end of file diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/TextBlock.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/TextBlock.kt index 29f40f8..7136292 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/TextBlock.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/TextBlock.kt @@ -3,4 +3,8 @@ package com.staffinghub.coding.challenges.mapping.models.dto.blocks data class TextBlock( var text: String, override val sortIndex: Int, -) : ArticleBlockDto +) : ArticleBlockDto, Comparable { + override fun compareTo(other: ArticleBlockDto): Int { + return compareValuesBy(this, other) { it.sortIndex } + } +} \ No newline at end of file diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/VideoBlock.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/VideoBlock.kt index 16b056e..829c110 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/VideoBlock.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/models/dto/blocks/VideoBlock.kt @@ -6,4 +6,8 @@ data class VideoBlock( var url: String, var type: VideoBlockType, override val sortIndex: Int, -) : ArticleBlockDto +) : ArticleBlockDto, Comparable { + override fun compareTo(other: ArticleBlockDto): Int { + return compareValuesBy(this, other) { it.sortIndex } + } +} \ No newline at end of file diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/repositories/ArticleRepository.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/repositories/ArticleRepository.kt index 2a927b4..91baae3 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/repositories/ArticleRepository.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/repositories/ArticleRepository.kt @@ -23,7 +23,7 @@ object ArticleRepository { title = "Article Nr.: $this", description = "Article Description $this", author = "Max Mustermann", - blocks = dummyArticleBlocks, + blocks = dummyArticleBlocks.sortedWith(compareBy { it.sortIndex }).toSet(), ) private val Long.dummyArticleBlocks: Set by lazy { diff --git a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/services/ArticleService.kt b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/services/ArticleService.kt index 0f02d7c..c26e731 100644 --- a/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/services/ArticleService.kt +++ b/Backend/mapping-kotlin/src/main/kotlin/com/staffinghub/coding/challenges/mapping/services/ArticleService.kt @@ -1,24 +1,35 @@ package com.staffinghub.coding.challenges.mapping.services -import com.staffinghub.coding.challenges.mapping.repositories.ArticleRepository import com.staffinghub.coding.challenges.mapping.mappers.ArticleMapper import com.staffinghub.coding.challenges.mapping.models.dto.ArticleDto +import com.staffinghub.coding.challenges.mapping.repositories.ArticleRepository +import mapper.adaptListTo +import org.springframework.http.HttpStatus import org.springframework.stereotype.Service +import org.springframework.web.server.ResponseStatusException @Service class ArticleService( private val mapper: ArticleMapper, ) { + /** + *@return List of AriticleDto that have been mapped to the data opject with internal Blocks sorted by sortIndex + */ fun list(): List { val articles = ArticleRepository.all() - //TODO - return emptyList() + return articles.adaptListTo(ArticleDto::class).toList() } + /** + *@return Single Instance of AriticleDto that have been mapped to the data opject with internal Blocks sorted by sortIndex + */ fun articleForId(id: Long): ArticleDto { val article = ArticleRepository.findBy(id) - //TODO - return ArticleDto(0, "", "", "", emptyList()) + + if (article == null) + throw ResponseStatusException(HttpStatus.NOT_FOUND, "No Article with suplied ID found") + + return mapper.mapStructMap(article) } fun create(articleDto: ArticleDto): ArticleDto { diff --git a/Backend/mapping-kotlin/src/test/kotlin/com/staffinghub/coding/challenges/mapping/ApplicationTests.kt b/Backend/mapping-kotlin/src/test/kotlin/com/staffinghub/coding/challenges/mapping/ApplicationTests.kt index 38a7add..4546929 100644 --- a/Backend/mapping-kotlin/src/test/kotlin/com/staffinghub/coding/challenges/mapping/ApplicationTests.kt +++ b/Backend/mapping-kotlin/src/test/kotlin/com/staffinghub/coding/challenges/mapping/ApplicationTests.kt @@ -1,14 +1,212 @@ package com.staffinghub.coding.challenges.mapping + +import com.staffinghub.coding.challenges.mapping.controllers.ArticleController +import com.staffinghub.coding.challenges.mapping.mappers.ArticleMapper +import com.staffinghub.coding.challenges.mapping.models.db.Article +import com.staffinghub.coding.challenges.mapping.models.db.Image +import com.staffinghub.coding.challenges.mapping.models.db.ImageSize +import com.staffinghub.coding.challenges.mapping.models.db.blocks.VideoBlockType +import com.staffinghub.coding.challenges.mapping.models.dto.ArticleDto +import com.staffinghub.coding.challenges.mapping.models.dto.ImageDto +import com.staffinghub.coding.challenges.mapping.repositories.ArticleRepository +import com.staffinghub.coding.challenges.mapping.services.ArticleService +import io.kotest.matchers.shouldBe +import mapper.adaptTo import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.Mockito.`when` +import org.mockito.junit.jupiter.MockitoExtension +import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest +import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.test.context.junit.jupiter.SpringExtension +import java.util.* +import com.staffinghub.coding.challenges.mapping.models.db.blocks.GalleryBlock as GaleryBlockDb +import com.staffinghub.coding.challenges.mapping.models.db.blocks.ImageBlock as ImageBlockDB +import com.staffinghub.coding.challenges.mapping.models.db.blocks.TextBlock as TextBlockDB +import com.staffinghub.coding.challenges.mapping.models.db.blocks.VideoBlock as VideoBlockDB +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.GalleryBlockDto as GaleryBlockDTO +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.ImageBlock as ImageBlockDTO +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.TextBlock as TextBlockDTO +import com.staffinghub.coding.challenges.mapping.models.dto.blocks.VideoBlock as VideoBlockDTO -@ExtendWith(SpringExtension::class) +@ExtendWith(SpringExtension::class, MockitoExtension::class) @SpringBootTest class ApplicationTests { + + private lateinit var articleController: ArticleController + + private lateinit var articleService: ArticleService + + @MockBean + private lateinit var articleRepository: ArticleRepository + + @Autowired + private lateinit var mapper: ArticleMapper + @Test fun contextLoads() { + + } + + @Test + fun ArticleServiceTest() { + + val articleId = 1001L + + val article = Article( + id = articleId, + title = "Test Article", + description = "This is a test article", + author = "Test Author", + lastModified = Date(), + blocks = listOf( + TextBlockDB("Test text 1", 1), + CreateImageBlockDB(articleId), + TextBlockDB("Test text 2", 3) + ).toSet() + ) + + val articleDto = ArticleDto( + id = articleId, + title = "Test Article", + description = "This is a test article", + author = "Test Author", + blocks = listOf( + TextBlockDTO("Test text 1", 1), + CreateImageBlockDTO(articleId), + TextBlockDTO("Test text 2", 3) + ) + ) + + articleService = ArticleService(mapper) + articleController = ArticleController(articleService) + + `when`(articleRepository.findBy(articleId)).thenReturn(article) + + val result = mapper.mapStructMap(article) + + result shouldBe articleDto + + val testArticleSort = articleRepository.findBy(articleId) + + assert(testArticleSort.blocks.elementAt(0).sortIndex <= testArticleSort.blocks.elementAt(1).sortIndex) + } + + /** + * Creates instances of both the TextBlock Database and TextBlockDto Data classes with the same values + * To acertain that after the Database class has been mapped that the classes are equal + */ + @Test + fun CheckTextBlockMap() { + val textBlockDb = TextBlockDB( + text = "Some Text for $this", + sortIndex = 0 + ) + + val textBlockDto = TextBlockDTO( + text = "Some Text for $this", + sortIndex = 0 + ) + + assert(textBlockDto == textBlockDb.adaptTo(TextBlockDTO::class)) + } + + /** + * Creates instances of both the VideoBlock Database and VideoBlockDto Data classes with the same values + * To acertain that after the VideoBlock Database class has been mapped that the classes are equal + */ + @Test + fun CheckVideoBlockMap() { + val videoBlockDB = VideoBlockDB( + type = VideoBlockType.YOUTUBE, + url = "https://youtu.be/myvideo", + sortIndex = 4 + ) + + val videoBlockDTO = VideoBlockDTO( + type = VideoBlockType.YOUTUBE, + url = "https://youtu.be/myvideo", + sortIndex = 4 + ) + + assert(videoBlockDTO == videoBlockDB.adaptTo(VideoBlockDTO::class)) + } + + /** + * Creates instances of both the ImageBlock Database and ImageBlockDto Data classes with the same values + * To acertain that after the ImageBlock Database class has been mapped that the classes are equal + */ + @Test + fun CheckImageBlockMap() { + val imageBlockDB = CreateImageBlockDB(1L) + + val imageBlockDTO = CreateImageBlockDTO(1L) + + assert(imageBlockDTO == imageBlockDB.adaptTo(imageBlockDTO::class)) + } + + /** + * Creates instances of both the GalleryBlock Database and GalleryBlockDto Data classes with the same values + * To acertain that after the GalleryBlock Database class has been mapped that the classes are equal + */ + @Test + fun CheckGalleryBlockMap() { + val galleryBlockDB = GaleryBlockDb( + sortIndex = 3, + images = listOf( + CreateImageBlockDB(1L).image, + CreateImageBlockDB(2L).image + ) + ) + + val galleryBlockDTO = GaleryBlockDTO( + sortIndex = 3, + images = listOf( + CreateImageBlockDTO(1L).image, + CreateImageBlockDTO(2L).image + ) + ) + + assert(galleryBlockDTO == galleryBlockDB.adaptTo(GaleryBlockDTO::class)) + } + + /** + * Creates an instance of the ImageBlock Database object + * + * @param imageId the Id of the image which is a long + * + * @return ImageBlock database object + */ + fun CreateImageBlockDB(imageId: Long): ImageBlockDB { + return ImageBlockDB( + image = Image( + url = "https://someurl.com/image/$imageId", + id = imageId, + imageSize = ImageSize.LARGE, + lastModified = Date(), + lastModifiedBy = "John Doe" + ), + sortIndex = 1 + ) + } + + /** + * Creates an instance of the ImageBlock DTO object + * + * @param imageId the Id of the image which is a long + * + * @return ImageBlock DTO object + */ + fun CreateImageBlockDTO(imageId: Long): ImageBlockDTO { + return ImageBlockDTO( + image = ImageDto( + url = "https://someurl.com/image/$imageId", + id = imageId, + imageSize = ImageSize.LARGE + ), + sortIndex = 1 + ) } -} +} \ No newline at end of file