Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JavaType


    // Read in the JSON from the example resource
    InputStream is = OpenOrdersJSONTest.class.getResourceAsStream("/trade/open_orders.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    JavaType type = mapper.getTypeFactory().constructParametricType(List.class, VosTradeOrder.class);
    JavaType type2 = mapper.getTypeFactory().constructParametricType(VosResponse.class, type);
    VosResponse<List<VosTradeOrder>> vaultOfSatoshiOrders = mapper.readValue(is, type2);

    assertThat(vaultOfSatoshiOrders.getData().size()).isEqualTo(2);

    // Verify that the example data was unmarshalled correctly
View Full Code Here


    // Read in the JSON from the example resources
    InputStream is = PlaceLimitOrderJSONTest.class.getResourceAsStream("/trade/place_order.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    JavaType type = mapper.getTypeFactory().constructParametricType(VosResponse.class, VosOrderId.class);
    VosResponse<VosOrderId> vaultOfSatoshiPlaceOrder = mapper.readValue(is, type);

    assertThat(vaultOfSatoshiPlaceOrder.getData().getOrder_id()).isEqualTo(2036833);
    assertThat(vaultOfSatoshiPlaceOrder.getStatus()).isEqualTo("success");
  }
View Full Code Here

    // Read in the JSON from the example resources
    InputStream is = PlaceLimitOrderJSONTest.class.getResourceAsStream("/error/error.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    JavaType type = mapper.getTypeFactory().constructParametricType(VosResponse.class, Void.class);
    VosResponse<Void> vaultOfSatoshiError = mapper.readValue(is, type);

    assertThat(vaultOfSatoshiError.getMessage()).isEqualTo("Missing required parameter: payment_currency");
    assertThat(vaultOfSatoshiError.getStatus()).isEqualTo("error");
  }
View Full Code Here

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

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, BTCChinaTrade.class);
    List<BTCChinaTrade> BTCChinaTrades = mapper.readValue(is, type);

    Trades trades = BTCChinaAdapters.adaptTrades(BTCChinaTrades, CurrencyPair.BTC_CNY);
    assertThat(trades.getTrades().size()).isEqualTo(101);
View Full Code Here

  public void testUnmarshallAllTickers() throws JsonParseException, JsonMappingException, IOException {

    final InputStream is = MintPalMarketDataTest.class.getResourceAsStream("/marketdata/tickers.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JavaType tickersType = mapper.getTypeFactory().constructParametricType(MintPalBaseResponse.class, mapper.getTypeFactory().constructCollectionType(List.class, MintPalTicker.class));
    final MintPalBaseResponse<List<MintPalTicker>> tickers = mapper.readValue(is, tickersType);

    assertThat(tickers.getStatus()).isEqualTo("success");
    final List<MintPalTicker> tickerList = tickers.getData();
    assertThat(tickerList).hasSize(1);
View Full Code Here

  public void testUnmarshallOrders() throws JsonParseException, JsonMappingException, IOException {

    final InputStream is = MintPalMarketDataTest.class.getResourceAsStream("/marketdata/orders.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JavaType tickersType = mapper.getTypeFactory().constructParametricType(MintPalBaseResponse.class, mapper.getTypeFactory().constructCollectionType(List.class, MintPalPublicOrders.class));
    final MintPalBaseResponse<List<MintPalPublicOrders>> ordersResponse = mapper.readValue(is, tickersType);

    assertThat(ordersResponse.getStatus()).isEqualTo("success");
    final List<MintPalPublicOrders> orderbook = ordersResponse.getData();
View Full Code Here

  public void testUnmarshallPublicTrades() throws JsonParseException, JsonMappingException, IOException {

    final InputStream is = MintPalMarketDataTest.class.getResourceAsStream("/marketdata/trades.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JavaType tickersType = mapper.getTypeFactory().constructParametricType(MintPalBaseResponse.class, mapper.getTypeFactory().constructCollectionType(List.class, MintPalPublicTrade.class));
    final MintPalBaseResponse<List<MintPalPublicTrade>> tradesResponse = mapper.readValue(is, tickersType);

    final List<MintPalPublicTrade> trades = tradesResponse.getData();
    assertThat(trades).hasSize(2);
View Full Code Here

    final InputStream is = PoloniexMarketDataTest.class.getResourceAsStream("/marketdata/currency-info.json");

    final ObjectMapper mapper = new ObjectMapper();

    final JavaType currencyInfoType = mapper.getTypeFactory().constructMapType(HashMap.class, String.class, PoloniexCurrencyInfo.class);
    final Map<String, PoloniexCurrencyInfo> currencyInfo = mapper.readValue(is, currencyInfoType);

    assertThat(currencyInfo).hasSize(2);

    PoloniexCurrencyInfo abyCurrencyInfo = currencyInfo.get("ABY");
View Full Code Here

  public void testTradeHistoryMultiPair() throws JsonParseException, JsonMappingException, IOException {

    final InputStream is = PoloniexUserTrade.class.getResourceAsStream("/tradedata/trade-history-multi-pair.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JavaType stringType = mapper.getTypeFactory().constructType(String.class, String.class);
    final JavaType tradeArray = mapper.getTypeFactory().constructArrayType(PoloniexUserTrade.class);
    final JavaType multiPairTradeType = mapper.getTypeFactory().constructMapType(HashMap.class, stringType, tradeArray);

    final Map<String, PoloniexUserTrade[]> tradeHistory = mapper.readValue(is, multiPairTradeType);
    assertThat(tradeHistory).hasSize(2);

    assertThat(tradeHistory).containsKey("BTC_LTC");
View Full Code Here

  public void testTradeHistorySinglePair() throws JsonParseException, JsonMappingException, IOException {

    final InputStream is = PoloniexUserTrade.class.getResourceAsStream("/tradedata/trade-history-single-pair.json");

    final ObjectMapper mapper = new ObjectMapper();
    final JavaType tradeArray = mapper.getTypeFactory().constructArrayType(PoloniexUserTrade.class);

    PoloniexUserTrade[] tradeHistory = mapper.readValue(is, tradeArray);
    assertThat(tradeHistory).hasSize(3);

    PoloniexUserTrade trade = tradeHistory[0];
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.JavaType

Copyright © 2018 www.massapicom. 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.