Skip to content

Commit e602b6b

Browse files
committed
State Wallet Create test fix
1 parent 75434ec commit e602b6b

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

src/main/kotlin/io/openfuture/api/component/state/DefaultStateApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class DefaultStateApi(private val stateRestTemplate: RestTemplate) : StateApi {
1919
listOf(KeyWalletDto(address, blockchain.getValue())),
2020
WalletMetaData(
2121
"0",
22-
getRandomNumber(1000, 9999).toString(),
23-
getOrderKey("op_"),
22+
"1000",
23+
"op_UxQr1LLdREboF",
2424
"USD",
2525
"open",
2626
false

src/test/kotlin/io/openfuture/api/component/state/DefaultStateApiTests.kt

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package io.openfuture.api.component.state
22

33
import io.openfuture.api.config.UnitTest
4-
import io.openfuture.api.domain.state.CreateStateWalletRequest
5-
import io.openfuture.api.domain.state.StateWalletDto
4+
import io.openfuture.api.domain.key.KeyWalletDto
5+
import io.openfuture.api.domain.state.*
66
import io.openfuture.api.entity.state.Blockchain
7+
import io.openfuture.api.util.getOrderKey
8+
import io.openfuture.api.util.getRandomNumber
79
import org.assertj.core.api.Assertions
810
import org.junit.Before
911
import org.junit.Test
@@ -12,6 +14,7 @@ import org.mockito.Mock
1214
import org.springframework.http.HttpStatus
1315
import org.springframework.http.ResponseEntity
1416
import org.springframework.web.client.RestTemplate
17+
import java.math.BigDecimal
1518
import java.time.LocalDateTime
1619

1720
class DefaultStateApiTests : UnitTest() {
@@ -28,11 +31,27 @@ class DefaultStateApiTests : UnitTest() {
2831

2932
@Test
3033
fun createWalletTest() {
31-
val request = CreateStateWalletRequest("address", "webhook", Blockchain.Ethereum)
32-
val response = StateWalletDto("id", "address", "webhook", Blockchain.Ethereum, LocalDateTime.now())
33-
34-
given(restTemplate.postForEntity("/wallets", request, StateWalletDto::class.java))
35-
.willReturn(ResponseEntity(response, HttpStatus.OK))
34+
val request = CreateStateWalletRequestMetadata(
35+
"webhook",
36+
listOf(KeyWalletDto("address", Blockchain.Ethereum.getValue())),
37+
WalletMetaData(
38+
"0",
39+
"1000",
40+
"op_UxQr1LLdREboF",
41+
"USD",
42+
"open",
43+
false
44+
)
45+
)
46+
val response = CreateStateWalletResponse(
47+
"webhook",
48+
"100",
49+
"op_UxQr1LLdREboF",
50+
BigDecimal.ZERO,
51+
listOf(WalletCreateResponse(Blockchain.Ethereum.getValue(),"address", BigDecimal.ZERO))
52+
)
53+
54+
given(restTemplate.postForEntity("/wallets", request, CreateStateWalletResponse::class.java)).willReturn(ResponseEntity(response, HttpStatus.OK))
3655

3756
val result = stateApi.createWallet("address", "webhook", Blockchain.Ethereum)
3857

0 commit comments

Comments
 (0)