This repository was archived by the owner on Oct 30, 2023. It is now read-only.
forked from joaopsilva/binance-java-api
-
Notifications
You must be signed in to change notification settings - Fork 599
Expand file tree
/
Copy pathWithdrawHistoryDeserializerTest.java
More file actions
executable file
·42 lines (37 loc) · 1.66 KB
/
WithdrawHistoryDeserializerTest.java
File metadata and controls
executable file
·42 lines (37 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.binance.api.domain.account;
import com.binance.api.client.domain.account.Withdraw;
import com.binance.api.client.domain.account.WithdrawHistory;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import static junit.framework.TestCase.*;
/**
* Test deserialization of a withdraw/deposit history.
*/
public class WithdrawHistoryDeserializerTest {
@Test
public void testWithdrawHistoryDeserialziation() {
String withdrawHistoryJson = "{\"withdrawList\":\n" +
"[{\"amount\":0.1,\"address\":\"0x456\",\"successTime\":\"2017-10-13 21:20:09\",\n" +
"\"txId\":\"0x123\",\"id\":\"1\",\"asset\":\"ETH\",\"applyTime\":\"2017-10-13 20:59:38\",\"userId\":\"1\",\"status\":6}],\n" +
"\"success\":true}";
ObjectMapper mapper = new ObjectMapper();
try {
WithdrawHistory withdrawHistory = mapper.readValue(withdrawHistoryJson, WithdrawHistory.class);
assertTrue(withdrawHistory.isSuccess());
List<Withdraw> withdrawList = withdrawHistory.getWithdrawList();
assertEquals(withdrawHistory.getWithdrawList().size(), 1);
Withdraw withdraw = withdrawList.get(0);
assertEquals(withdraw.getAmount(), "0.1");
assertEquals(withdraw.getAddress(), "0x456");
assertEquals(withdraw.getAsset(), "ETH");
assertEquals(withdraw.getApplyTime(), "2017-10-13 20:59:38");
assertEquals(withdraw.getSuccessTime(), "2017-10-13 21:20:09");
assertEquals(withdraw.getTxId(), "0x123");
assertEquals(withdraw.getId(), "1");
} catch (IOException e) {
fail(e.getMessage());
}
}
}