Package com.xeiam.xchange.anx.v2.marketdata.polling

Source Code of com.xeiam.xchange.anx.v2.marketdata.polling.TickerJSONTest

package com.xeiam.xchange.anx.v2.marketdata.polling;

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

import org.junit.Assert;
import org.junit.Test;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xeiam.xchange.anx.v2.dto.marketdata.ANXTicker;

/**
* Test ANXTicker JSON parsing
*/
public class TickerJSONTest {

  @Test
  public void testUnmarshal() throws IOException {

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

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    ANXTicker anxTicker = mapper.readValue(is, ANXTicker.class);
    //
    System.out.println(anxTicker.toString());

    // Verify that the example data was unmarshalled correctly
    Assert.assertEquals(new BigDecimal("725.38123"), anxTicker.getHigh().getValue());
    Assert.assertEquals(new BigDecimal("380.00000"), anxTicker.getLow().getValue());
    Assert.assertEquals(new BigDecimal("429.34018"), anxTicker.getAvg().getValue());
    Assert.assertEquals(new BigDecimal("429.34018"), anxTicker.getVwap().getValue());
    Assert.assertEquals(new BigDecimal("7.00000000"), anxTicker.getVol().getValue());
    Assert.assertEquals(new BigDecimal("725.38123"), anxTicker.getLast().getValue());
    Assert.assertEquals(new BigDecimal("38.85148"), anxTicker.getBuy().getValue());
    Assert.assertEquals(new BigDecimal("897.25596"), anxTicker.getSell().getValue());
    Assert.assertEquals(1393388594814000L, anxTicker.getNow());

  }
}
TOP

Related Classes of com.xeiam.xchange.anx.v2.marketdata.polling.TickerJSONTest

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.