<commit_before>package com.piticlistudio.playednext.data.entity.mapper.datasources.game

import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.reset
import com.nhaarman.mockito_kotlin.verify
import com.piticlistudio.playednext.data.entity.mapper.datasources.timetobeat.RoomTimeToBeatMapper
import com.piticlistudio.playednext.data.entity.room.RoomGameProxy
import com.piticlistudio.playednext.domain.model.Game
import com.piticlistudio.playednext.test.factory.GameFactory
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import kotlin.test.assertNull

internal class RoomGameMapperTest {

    @Nested
    @DisplayName("Given a RoomGameMapper instance")
    inner class RoomGameServiceMapperInstance {

        private lateinit var mapper: RoomGameMapper
        private val timeToBeatMapper: RoomTimeToBeatMapper = mock()

        @BeforeEach
        internal fun setUp() {
            reset(timeToBeatMapper)
            mapper = RoomGameMapper(timeToBeatMapper)
        }

        @Nested
        @DisplayName("When mapFromEntity is called")
        inner class MapFromEntityCalled {

            val model = GameFactory.makeRoomGame()
            var result: Game? = null

            @BeforeEach
            internal fun setUp() {
                result = mapper.mapFromDataLayer(RoomGameProxy(model))
            }

            @Test
            @DisplayName("Then should map into Game domain model")
            fun shouldMap() {
                assertNotNull(result)
                result?.apply {
                    assertEquals(model.id, id)
                    assertEquals(model.name, name)
                    assertEquals(model.summary, summary)
                    assertEquals(model.storyline, storyline)
                    assertEquals(model.syncedAt, syncedAt)
                    assertEquals(model.rating, rating)
                    assertEquals(model.aggregatedRatingCount, aggregatedRatingCount)
                    assertEquals(model.agregatedRating, aggregatedRating)
                    assertEquals(model.createdAt, createdAt)
                    assertEquals(model.firstReleaseAt, releasedAt)
                    assertEquals(model.ratingCount, ratingCount)
                    assertEquals(model.totalRatingCount, totalRatingCount)
                    assertEquals(model.totalRating, totalRating)
                    assertNotNull(developers)
                    assertNotNull(publishers)
                    assertNotNull(genres)
                    assertNotNull(platforms)
                    assertNotNull(images)
                    assertNull(collection)
                }
            }

            @Test
            @DisplayName("Then should map into Cover")
            fun intoCoverEntity() {
                model.cover?.apply {
                    assertNotNull(result!!.cover)
                    assertEquals(url, result!!.cover?.url)
                    assertEquals(width, result!!.cover?.width)
                    assertEquals(height, result!!.cover?.height)
                }
            }

            @Test
            @DisplayName("Then should map into TimeToBeat")
            fun intoTimeToBeatEntity() {
                model.timeToBeat?.let {
                    verify(timeToBeatMapper).mapFromDataLayer(it)
                }
            }
        }

        @Nested
        @DisplayName("When mapIntoDataLayerModel is called")
        inner class MapIntoDataLayerModelCalled {

            val entity = GameFactory.makeGame()
            var result: RoomGameProxy? = null

            @BeforeEach
            internal fun setUp() {
                result = mapper.mapIntoDataLayerModel(entity)
            }

            @Test
            @DisplayName("Then should map into Dao")
            fun shouldMap() {
                assertNotNull(result)
                result?.apply {
                    assertNotNull(game)
                    game.apply {
                        assertEquals(entity.id, id)
                        assertEquals(entity.name, name)
                        assertEquals(entity.summary, summary)
                        assertEquals(entity.storyline, storyline)
                        assertEquals(entity.collection, collection)
                        assertNull(franchise)
                        assertEquals(entity.rating, rating)
                        assertEquals(entity.aggregatedRatingCount, aggregatedRatingCount)
                        assertEquals(entity.aggregatedRating, agregatedRating)
                        assertEquals(entity.createdAt, createdAt)
                        assertNull(firstReleaseAt)
                        assertNull(hypes)
                        assertNull(popularity)
                        assertEquals(entity.ratingCount, ratingCount)<commit_msg>Fix test<commit_after>package com.piticlistudio.playednext.data.entity.mapper.datasources.game

import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.reset
import com.nhaarman.mockito_kotlin.verify
import com.piticlistudio.playednext.data.entity.mapper.datasources.timetobeat.RoomTimeToBeatMapper
import com.piticlistudio.playednext.data.entity.room.RoomGameProxy
import com.piticlistudio.playednext.domain.model.Game
import com.piticlistudio.playednext.test.factory.GameFactory
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import kotlin.test.assertNull

internal class RoomGameMapperTest {

    @Nested
    @DisplayName("Given a RoomGameMapper instance")
    inner class RoomGameServiceMapperInstance {

        private lateinit var mapper: RoomGameMapper
        private val timeToBeatMapper: RoomTimeToBeatMapper = mock()

        @BeforeEach
        internal fun setUp() {
            reset(timeToBeatMapper)
            mapper = RoomGameMapper(timeToBeatMapper)
        }

        @Nested
        @DisplayName("When mapFromEntity is called")
        inner class MapFromEntityCalled {

            val model = GameFactory.makeRoomGame()
            var result: Game? = null

            @BeforeEach
            internal fun setUp() {
                result = mapper.mapFromDataLayer(RoomGameProxy(model))
            }

            @Test
            @DisplayName("Then should map into Game domain model")
            fun shouldMap() {
                assertNotNull(result)
                result?.apply {
                    assertEquals(model.id, id)
                    assertEquals(model.name, name)
                    assertEquals(model.summary, summary)
                    assertEquals(model.storyline, storyline)
                    assertEquals(model.syncedAt, syncedAt)
                    assertEquals(model.rating, rating)
                    assertEquals(model.aggregatedRatingCount, aggregatedRatingCount)
                    assertEquals(model.agregatedRating, aggregatedRating)
                    assertEquals(model.createdAt, createdAt)
                    assertEquals(model.firstReleaseAt, releasedAt)
                    assertEquals(model.ratingCount, ratingCount)
                    assertEquals(model.totalRatingCount, totalRatingCount)
                    assertEquals(model.totalRating, totalRating)
                    assertNotNull(developers)
                    assertNotNull(publishers)
                    assertNotNull(genres)
                    assertNotNull(platforms)
                    assertNotNull(images)
                    assertNull(collection)
                }
            }

            @Test
            @DisplayName("Then should map into Cover")
            fun intoCoverEntity() {
                model.cover?.apply {
                    assertNotNull(result!!.cover)
                    assertEquals(url, result!!.cover?.url)
                    assertEquals(width, result!!.cover?.width)
                    assertEquals(height, result!!.cover?.height)
                }
            }

            @Test
            @DisplayName("Then should map into TimeToBeat")
            fun intoTimeToBeatEntity() {
                model.timeToBeat?.let {
                    verify(timeToBeatMapper).mapFromDataLayer(it)
                }
            }
        }

        @Nested
        @DisplayName("When mapIntoDataLayerModel is called")
        inner class MapIntoDataLayerModelCalled {

            val entity = GameFactory.makeGame()
            var result: RoomGameProxy? = null

            @BeforeEach
            internal fun setUp() {
                result = mapper.mapIntoDataLayerModel(entity)
            }

            @Test
            @DisplayName("Then should map into Dao")
            fun shouldMap() {
                assertNotNull(result)
                result?.apply {
                    assertNotNull(game)
                    game.apply {
                        assertEquals(entity.id, id)
                        assertEquals(entity.name, name)
                        assertEquals(entity.summary, summary)
                        assertEquals(entity.storyline, storyline)
                        assertEquals(entity.collection?.id, collection)
                        assertNull(franchise)
                        assertEquals(entity.rating, rating)
                        assertEquals(entity.aggregatedRatingCount, aggregatedRatingCount)
                        assertEquals(entity.aggregatedRating, agregatedRating)
                        assertEquals(entity.createdAt, createdAt)
                        assertEquals(entity.releasedAt, firstReleaseAt)
                        assertNull(hypes)
                        assertNull(popularity)
                        assertEquals(entity.ratingCount, ratingCount)
{'fraction_non_alphanumeric': 0.0707453168593065, 'fraction_numerical': 0.0, 'mean_word_length': 1.7416006555585906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5716368', 'n_tokens_mistral': 2473, 'n_tokens_neox': 2266, 'n_words': 413}