-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b962f73
commit c283838
Showing
11 changed files
with
241 additions
and
4 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
common/src/test/kotlin/br/com/stonks/common/formatters/DatePatternTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ks/src/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/AlertUiToModelMapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) | ||
} |
37 changes: 37 additions & 0 deletions
37
...kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertEntityToResponseMapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
) | ||
} |
37 changes: 37 additions & 0 deletions
37
.../kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToResponseMapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
) | ||
} |
47 changes: 47 additions & 0 deletions
47
...c/test/kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertModelToUiMapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) | ||
), | ||
) | ||
} |
35 changes: 35 additions & 0 deletions
35
...kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToEntityMapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
) | ||
} |
41 changes: 41 additions & 0 deletions
41
.../kotlin/br/com/stonks/feature/stocks/domain/mapper/StockAlertResponseToModelMapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters