public ThresholdSecuritiesRequestBuilder withMarket() { return withSymbol("market"); }
@Test public void shouldSuccessfullyCreateRequest() { final LocalDate date = LocalDate.of(2017, 5, 5); final RestRequest<List<ThresholdSecurities>> request = new ThresholdSecuritiesRequestBuilder() .withDate(date) .withSymbol("aapl") .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/threshold-securities/{date}"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<ThresholdSecurities>>() {}); assertThat(request.getPathParams()).contains(entry("date", "20170505"), entry("symbol", "aapl")); assertThat(request.getQueryParams()).isEmpty(); }
@Test public void thresholdSecuritiesServiceTest() { stubFor(get(urlEqualTo("/stock/aapl/threshold-securities/")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/stock/ThresholdSecuritiesResponse.json"))); final List<ThresholdSecurities> thresholdSecuritiesList = iexTradingClient.executeRequest(new ThresholdSecuritiesRequestBuilder() .withSymbol("aapl") .build()); assertThat(thresholdSecuritiesList).hasSize(1); final ThresholdSecurities thresholdSecurities = thresholdSecuritiesList.get(0); assertThat(thresholdSecurities.getTradeDate()).isEqualTo(LocalDate.of(2017, 10, 13)); assertThat(thresholdSecurities.getSymbolInINETSymbology()).isEqualTo("ZIEXT"); assertThat(thresholdSecurities.getSymbolInCQSSymbology()).isEqualTo("ZIEXT"); assertThat(thresholdSecurities.getSymbolInCMSSymbology()).isEqualTo("ZIEXT"); assertThat(thresholdSecurities.getCusip()).isEqualTo("0ZIEXT886"); assertThat(thresholdSecurities.getSecurityName()).isEqualTo("ZIEXT Common Stock"); } }