Package com.xeiam.xchange.cryptonit.v2.service.marketdata

Source Code of com.xeiam.xchange.cryptonit.v2.service.marketdata.CryptonitTickerJSONTest

package com.xeiam.xchange.cryptonit.v2.service.marketdata;

import static org.fest.assertions.api.Assertions.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;

import org.junit.Test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.xeiam.xchange.cryptonit.v2.dto.marketdata.CryptonitRate;
import com.xeiam.xchange.cryptonit.v2.dto.marketdata.CryptonitTicker;

/**
* Test CryptonitTicker JSON parsing
*/
public class CryptonitTickerJSONTest {

  @Test
  public void testUnmarshal() throws IOException {

    // Read in the JSON from the example resources
    InputStream is = CryptonitTickerJSONTest.class.getResourceAsStream("/marketdata/example-ticker-data.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    CryptonitTicker cryptonitTicker = mapper.readValue(is, CryptonitTicker.class);
    CryptonitRate cryptonitTickerRate = cryptonitTicker.getRate();

    // Verify that the example data was unmarshalled correctly
    assertThat(cryptonitTickerRate.getLast()).isEqualTo(new BigDecimal("605.997"));
    assertThat(cryptonitTickerRate.getHigh()).isEqualTo(new BigDecimal("610.00000000"));
    assertThat(cryptonitTickerRate.getLow()).isEqualTo(new BigDecimal("572.73768613"));
    assertThat(cryptonitTicker.getVolume().getVolume("BTC")).isEqualTo(new BigDecimal("8.28600851"));
    assertThat(cryptonitTickerRate.getAsk()).isEqualTo(new BigDecimal("604.44900000"));
    assertThat(cryptonitTickerRate.getBid()).isEqualTo(new BigDecimal("584.79532163"));

  }

}
TOP

Related Classes of com.xeiam.xchange.cryptonit.v2.service.marketdata.CryptonitTickerJSONTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.