-
Notifications
You must be signed in to change notification settings - Fork 159
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
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
src/test/java/org/stellar/sdk/responses/AssetDeserializerTest.java
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,29 @@ | ||
package org.stellar.sdk.responses; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Test; | ||
import org.stellar.sdk.Asset; | ||
import org.stellar.sdk.AssetTypeCreditAlphaNum; | ||
|
||
public class AssetDeserializerTest extends TestCase { | ||
@Test | ||
public void testDeserializeNative() { | ||
String json = "{\"asset_type\": \"native\"}"; | ||
Asset asset = GsonSingleton.getInstance().fromJson(json, Asset.class); | ||
assertEquals(asset.getType(), "native"); | ||
} | ||
|
||
@Test | ||
public void testDeserializeCredit() { | ||
String json = "{\n" + | ||
" \"asset_type\": \"credit_alphanum4\",\n" + | ||
" \"asset_code\": \"CNY\",\n" + | ||
" \"asset_issuer\": \"GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX\"\n" + | ||
"}"; | ||
Asset asset = GsonSingleton.getInstance().fromJson(json, Asset.class); | ||
assertEquals(asset.getType(), "credit_alphanum4"); | ||
AssetTypeCreditAlphaNum creditAsset = (AssetTypeCreditAlphaNum) asset; | ||
assertEquals(creditAsset.getCode(), "CNY"); | ||
assertEquals(creditAsset.getIssuer().getAccountId(), "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX"); | ||
} | ||
} |