Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dgeorgiev committed Oct 3, 2023
2 parents ed9a56e + d69978b commit 19f7ba6
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.wavesenterprise.sdk.node.client.feign

import com.wavesenterprise.sdk.node.client.http.DataEntryDto
import com.wavesenterprise.sdk.node.client.http.DataEntryDto.Companion.toDomain
import com.wavesenterprise.sdk.node.domain.DataValue
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import java.util.Base64

class TxMapperTest {

@Test
fun `should correct map to BooleanDataValue`() {
DataEntryDto(
key = "bool",
type = "boolean",
value = true,
).toDomain().also {
assertTrue(it.value is DataValue.BooleanDataValue)
}
}

@Test
fun `should correct map to StringDataValue`() {
DataEntryDto(
key = "str",
type = "string",
value = "test",
).toDomain().also {
assertTrue(it.value is DataValue.StringDataValue)
}
}

@Test
fun `should correct map to IntegerDataValue`() {
DataEntryDto(
key = "int",
type = "integer",
value = 1,
).toDomain().also {
assertTrue(it.value is DataValue.IntegerDataValue)
}
}

@Test
fun `should correct map to BinaryDataValue`() {
DataEntryDto(
key = "bin",
type = "binary",
value = Base64.getEncoder().encodeToString("test".toByteArray()),
).toDomain().also {
assertTrue(it.value is DataValue.BinaryDataValue)
}
}

@Test
fun `should throw exception when unknown type`() {
val incorrectBooleanDataEntryDto = DataEntryDto(
key = "bool",
type = "bool",
value = true,
)
assertThrows<IllegalStateException > {
incorrectBooleanDataEntryDto.toDomain()
}.also {
assertEquals(
"Unknown data type ${incorrectBooleanDataEntryDto.type} for key ${incorrectBooleanDataEntryDto.key}",
it.message
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ internal class WeTxApiFeignTest {
assertEquals(250, utxInfo.sizeInBytes)
}

// @Test
// fun `should get utxInfo`() {
// weTxApi.utxTxs()[0].apply {
// assertEquals("", )
// }
// }

@Test
fun `should successfully sign SignRequest`() {
val signedTxResponse: CallContractTxDto = weTxApi.sign(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class DataEntryDto(
) {
companion object {
const val BINARY_TYPE = "binary"
const val BOOLEAN_TYPE = "bool"
const val BOOLEAN_TYPE = "boolean"
const val INTEGER_TYPE = "integer"
const val STRING_TYPE = "string"

Expand Down

0 comments on commit 19f7ba6

Please sign in to comment.