private void topsRequestSample() { final List<TOPS> tops = iexTradingClient.executeRequest(new TopsRequestBuilder() .withSymbol("AAPL") .build()); System.out.println(tops); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<List<TOPS>> request = new TopsRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/tops"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<TOPS>>() {}); assertThat(request.getPathParams()).isEmpty(); assertThat(request.getQueryParams()).contains(entry("symbols", symbol)); }
@Test public void topsAcceptanceTest() { final List<TOPS> tops = iexTradingClient.executeRequest(new TopsRequestBuilder() .withSymbol("AAPL") .build()); }
@Test public void topsServiceTest() { stubFor(get(urlEqualTo("/tops?symbols=AAPL")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/marketdata/TopsResponse.json"))); final List<TOPS> topsList = iexTradingClient.executeRequest(new TopsRequestBuilder() .withSymbol("AAPL") .build()); final TOPS tops = topsList.get(0); assertThat(tops.getSymbol()).isEqualTo("AAPL"); assertThat(tops.getMarketPercent()).isEqualTo(BigDecimal.valueOf(0.01341)); assertThat(tops.getBidSize()).isEqualTo(BigDecimal.valueOf(100)); assertThat(tops.getBidPrice()).isEqualTo(BigDecimal.valueOf(166.18)); assertThat(tops.getAskSize()).isEqualTo(BigDecimal.valueOf(315)); assertThat(tops.getAskPrice()).isEqualTo(BigDecimal.valueOf(172)); assertThat(tops.getVolume()).isEqualTo(BigDecimal.valueOf(184260)); assertThat(tops.getLastSalePrice()).isEqualTo(BigDecimal.valueOf(170.435)); assertThat(tops.getLastSaleSize()).isEqualTo(BigDecimal.valueOf(60)); assertThat(tops.getLastSaleTime()).isEqualTo(1510943467901L); assertThat(tops.getLastUpdated()).isEqualTo(1510943543270L); assertThat(tops.getSector()).isEqualTo("technologyhardwareequipmen"); assertThat(tops.getSecurityType()).isEqualTo("commonstock"); }