private void officialPriceRequestSample() { final Map<String, OfficialPrice> officialPriceMap = iexTradingClient.executeRequest(new OfficialPriceRequestBuilder() .withSymbol("AAPL") .build()); System.out.println(officialPriceMap); }
@Override public RestRequest<Map<String, OfficialPrice>> build() { return RestRequestBuilder.<Map<String, OfficialPrice>>builder() .withPath("/deep/official-price").get() .withResponse(new GenericType<Map<String, OfficialPrice>>() {}) .addQueryParam(getSymbols()) .addQueryParam(getFilterParams()) .build(); } }
@Test public void officialPriceAcceptanceTest() { final Map<String, OfficialPrice> officialPriceMap = iexTradingClient.executeRequest(new OfficialPriceRequestBuilder() .withSymbol("AAPL") .build()); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<Map<String, OfficialPrice>> request = new OfficialPriceRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/deep/official-price"); assertThat(request.getResponseType()).isEqualTo(new GenericType<Map<String, OfficialPrice>>() {}); assertThat(request.getPathParams()).isEmpty(); assertThat(request.getQueryParams()).contains(entry("symbols", symbol)); }
@Test public void officialPriceServiceTest() { stubFor(get(urlEqualTo("/deep/official-price?symbols=SNAP")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/marketdata/OfficialPriceResponse.json"))); final Map<String, OfficialPrice> opHaltStatusMap = iexTradingClient.executeRequest(new OfficialPriceRequestBuilder() .withSymbol("SNAP") .build()); final OfficialPrice officialPrice = opHaltStatusMap.get("SNAP"); assertThat(officialPrice.getPriceType()).isEqualTo(PriceType.Open); assertThat(officialPrice.getPrice()).isEqualTo(BigDecimal.valueOf(1.05)); assertThat(officialPrice.getTimestamp()).isEqualTo(1494595800005L); } }