diff --git a/common/src/test/kotlin/br/com/stonks/common/formatters/DatePatternTest.kt b/common/src/test/kotlin/br/com/stonks/common/formatters/DatePatternTest.kt index 1702754..6049ac8 100644 --- a/common/src/test/kotlin/br/com/stonks/common/formatters/DatePatternTest.kt +++ b/common/src/test/kotlin/br/com/stonks/common/formatters/DatePatternTest.kt @@ -1,7 +1,7 @@ package br.com.stonks.common.formatters +import org.junit.Assert.assertEquals import org.junit.Test -import kotlin.test.assertEquals class DatePatternTest { diff --git a/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/DailyTransactionResponseToModelMapperTest.kt b/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/DailyTransactionResponseToModelMapperTest.kt index 8f32c39..8a70dda 100644 --- a/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/DailyTransactionResponseToModelMapperTest.kt +++ b/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/DailyTransactionResponseToModelMapperTest.kt @@ -5,9 +5,9 @@ import br.com.stonks.feature.home.domain.model.TransactionModel import br.com.stonks.feature.home.domain.types.TransactionType import br.com.stonks.feature.home.repository.remote.response.DailyTransactionResponse import br.com.stonks.feature.home.repository.remote.response.TransactionResponse +import org.junit.Assert.assertEquals import org.junit.Test import java.util.Date -import kotlin.test.assertEquals class DailyTransactionResponseToModelMapperTest { diff --git a/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/WalletResponseToModelMapperTest.kt b/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/WalletResponseToModelMapperTest.kt index 7c90653..40edd1e 100644 --- a/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/WalletResponseToModelMapperTest.kt +++ b/feature/home/src/test/kotlin/br/com/stonks/feature/home/domain/mapper/WalletResponseToModelMapperTest.kt @@ -5,8 +5,8 @@ import br.com.stonks.feature.home.domain.model.WalletModel import br.com.stonks.feature.home.domain.types.PortfolioType import br.com.stonks.feature.home.repository.remote.response.PortfolioResponse import br.com.stonks.feature.home.repository.remote.response.WalletResponse +import org.junit.Assert.assertEquals import org.junit.Test -import kotlin.test.assertEquals class WalletResponseToModelMapperTest { diff --git a/feature/stocks/build.gradle.kts b/feature/stocks/build.gradle.kts index d39ad2e..1fe4b6b 100644 --- a/feature/stocks/build.gradle.kts +++ b/feature/stocks/build.gradle.kts @@ -13,9 +13,10 @@ dependencies { implementation(projects.designSystem) implementation(projects.infrastructure.network) + implementation(libs.retrofit.core) implementation(libs.androidx.room.core) implementation(libs.androidx.room.runtime) ksp(libs.androidx.room.compiler) - implementation(libs.retrofit.core) + testImplementation(libs.bundles.test.jvm) } diff --git a/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/AlertUiToModelMapperTest.kt b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/AlertUiToModelMapperTest.kt new file mode 100644 index 0000000..2d75a70 --- /dev/null +++ b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/AlertUiToModelMapperTest.kt @@ -0,0 +1,37 @@ +package br.com.stonks.feature.stocks.domain.mapper + +import br.com.stonks.feature.stocks.domain.model.StockAlertModel +import br.com.stonks.feature.stocks.domain.types.StockAlertType +import br.com.stonks.feature.stocks.domain.types.StockStatusType +import br.com.stonks.feature.stocks.ui.model.AlertUiModel +import org.junit.Assert.assertEquals +import org.junit.Test + +class AlertUiToModelMapperTest { + + private val sut = AlertUiToModelMapper() + + @Test + fun `given ui data when call mapper then convert to model`() { + val expected = createExpectedData() + val result = sut.mapper(createInputData()) + + assertEquals(expected, result) + } + + private fun createInputData() = AlertUiModel( + id = 1L, + ticket = "lorem", + alertValue = 5.0, + status = StockStatusType.AVAILABLE, + alert = StockAlertType.LOW_PRICE, + ) + + private fun createExpectedData() = StockAlertModel( + id = 1L, + ticket = "lorem", + alertValue = 5.0, + status = StockStatusType.AVAILABLE, + notificationTrigger = StockAlertType.LOW_PRICE, + ) +} diff --git a/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertEntityToResponseMapperTest.kt b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertEntityToResponseMapperTest.kt new file mode 100644 index 0000000..4eed942 --- /dev/null +++ b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertEntityToResponseMapperTest.kt @@ -0,0 +1,37 @@ +package br.com.stonks.feature.stocks.domain.mapper + +import br.com.stonks.feature.stocks.domain.types.StockAlertType +import br.com.stonks.feature.stocks.domain.types.StockStatusType +import br.com.stonks.feature.stocks.repository.local.StockAlertEntity +import br.com.stonks.feature.stocks.repository.remote.response.StockAlertResponse +import org.junit.Assert.assertEquals +import org.junit.Test + +class StockAlertEntityToResponseMapperTest { + + private val sut = StockAlertEntityToResponseMapper() + + @Test + fun `given entity data when call mapper then convert to response`() { + val expected = createExpectedData() + val result = sut.mapper(createInputData()) + + assertEquals(expected, result) + } + + private fun createInputData() = StockAlertEntity( + id = 1L, + ticket = "lorem", + alertValue = 1.5, + status = StockStatusType.AVAILABLE.status, + notificationTrigger = StockAlertType.LOW_PRICE.status, + ) + + private fun createExpectedData() = StockAlertResponse( + id = 1L, + stockTicket = "lorem", + alertValue = 1.5, + status = "available", + notificationTrigger = "low", + ) +} diff --git a/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToResponseMapperTest.kt b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToResponseMapperTest.kt new file mode 100644 index 0000000..a75076e --- /dev/null +++ b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToResponseMapperTest.kt @@ -0,0 +1,37 @@ +package br.com.stonks.feature.stocks.domain.mapper + +import br.com.stonks.feature.stocks.domain.model.StockAlertModel +import br.com.stonks.feature.stocks.domain.types.StockAlertType +import br.com.stonks.feature.stocks.domain.types.StockStatusType +import br.com.stonks.feature.stocks.repository.remote.response.StockAlertResponse +import org.junit.Assert.assertEquals +import org.junit.Test + +class StockAlertModelToResponseMapperTest { + + private val sut = StockAlertModelToResponseMapper() + + @Test + fun `given model when call mapper then convert to response`() { + val expected = createExpectedData() + val result = sut.mapper(createInputData()) + + assertEquals(expected, result) + } + + private fun createInputData() = StockAlertModel( + id = 1L, + ticket = "lorem", + alertValue = 5.0, + status = StockStatusType.AVAILABLE, + notificationTrigger = StockAlertType.LOW_PRICE, + ) + + private fun createExpectedData() = StockAlertResponse( + id = 1L, + stockTicket = "lorem", + alertValue = 5.0, + status = "available", + notificationTrigger = "low", + ) +} diff --git a/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToUiMapperTest.kt b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToUiMapperTest.kt new file mode 100644 index 0000000..01899ee --- /dev/null +++ b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToUiMapperTest.kt @@ -0,0 +1,47 @@ +package br.com.stonks.feature.stocks.domain.mapper + +import br.com.stonks.designsystem.tokens.ColorToken +import br.com.stonks.feature.stocks.domain.model.StockAlertModel +import br.com.stonks.feature.stocks.domain.types.StockAlertType +import br.com.stonks.feature.stocks.domain.types.StockStatusType +import br.com.stonks.feature.stocks.ui.model.AlertUiModel +import br.com.stonks.feature.stocks.ui.model.StockAlertUiModel +import org.junit.Assert.assertEquals +import org.junit.Test + +class StockAlertModelToUiMapperTest { + + private val sut = StockAlertModelToUiMapper() + + @Test + fun `given model when call mapper then convert to ui model`() { + val expected = createResultData() + val result = sut.mapper(createInputData()) + + assertEquals(expected, result) + } + + private fun createInputData() = listOf( + StockAlertModel( + id = 1L, + ticket = "lorem", + alertValue = 1.5, + status = StockStatusType.AVAILABLE, + notificationTrigger = StockAlertType.HIGH_PRICE, + ) + ) + + private fun createResultData() = StockAlertUiModel( + totalAssets = 1.5, + stockAlerts = listOf( + AlertUiModel( + id = 1L, + ticket = "lorem", + alertValue = 1.5, + status = StockStatusType.AVAILABLE, + alert = StockAlertType.HIGH_PRICE, + tagColor = ColorToken.HighlightGreen, + ) + ), + ) +} diff --git a/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToEntityMapperTest.kt b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToEntityMapperTest.kt new file mode 100644 index 0000000..0579a26 --- /dev/null +++ b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToEntityMapperTest.kt @@ -0,0 +1,35 @@ +package br.com.stonks.feature.stocks.domain.mapper + +import br.com.stonks.feature.stocks.repository.local.StockAlertEntity +import br.com.stonks.feature.stocks.repository.remote.response.StockAlertResponse +import org.junit.Assert.assertEquals +import org.junit.Test + +class StockAlertResponseToEntityMapperTest { + + private val sut = StockAlertResponseToEntityMapper() + + @Test + fun `given response data when call mapper then convert to entity`() { + val expected = createExpectedData() + val result = sut.mapper(createInputData()) + + assertEquals(expected, result) + } + + private fun createInputData() = StockAlertResponse( + id = 1L, + stockTicket = "lorem", + alertValue = 8.0, + status = "available", + notificationTrigger = "high", + ) + + private fun createExpectedData() = StockAlertEntity( + id = 1L, + ticket = "lorem", + alertValue = 8.0, + status = "available", + notificationTrigger = "high", + ) +} diff --git a/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToModelMapperTest.kt b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToModelMapperTest.kt new file mode 100644 index 0000000..5cfec09 --- /dev/null +++ b/feature/stocks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToModelMapperTest.kt @@ -0,0 +1,41 @@ +package br.com.stonks.feature.stocks.domain.mapper + +import br.com.stonks.feature.stocks.domain.model.StockAlertModel +import br.com.stonks.feature.stocks.domain.types.StockAlertType +import br.com.stonks.feature.stocks.domain.types.StockStatusType +import br.com.stonks.feature.stocks.repository.remote.response.StockAlertResponse +import org.junit.Assert.assertEquals +import org.junit.Test + +class StockAlertResponseToModelMapperTest { + + private val sut = StockAlertResponseToModelMapper() + + @Test + fun `given response data when call mapper then convert to model`() { + val expected = createExpectedData() + val result = sut.mapper(createInputData()) + + assertEquals(expected, result) + } + + private fun createInputData() = listOf( + StockAlertResponse( + id = 1L, + stockTicket = "lorem", + alertValue = 5.0, + status = "available", + notificationTrigger = "low", + ) + ) + + private fun createExpectedData() = listOf( + StockAlertModel( + id = 1L, + ticket = "lorem", + alertValue = 5.0, + status = StockStatusType.AVAILABLE, + notificationTrigger = StockAlertType.LOW_PRICE, + ) + ) +} diff --git a/infrastructure/network/build.gradle.kts b/infrastructure/network/build.gradle.kts index 1f84c1a..274b8dd 100644 --- a/infrastructure/network/build.gradle.kts +++ b/infrastructure/network/build.gradle.kts @@ -24,4 +24,6 @@ dependencies { implementation(libs.okhttp.logging) implementation(libs.retrofit.core) implementation(libs.retrofit.converter) + + testImplementation(libs.bundles.test.jvm) }