private void batchMarketRequestSample() { final Map<String, BatchStocks> batchStocksMap = iexTradingClient.executeRequest(new BatchMarketStocksRequestBuilder() .withSymbol("AAPL") .addType(BatchStocksType.COMPANY) .addType(BatchStocksType.EARNINGS) .build()); System.out.println(batchStocksMap); }
@Test public void shouldSuccessfullyCreateRequestWithMultipleSymbols() { final String firstSymbol = "IBM"; final String secondSymbol = "MSFT"; final BatchStocksType stocksType = BatchStocksType.BOOK; final RestRequest<Map<String, BatchStocks>> request = new BatchMarketStocksRequestBuilder() .addType(stocksType) .withSymbols(Lists.newArrayList(firstSymbol, secondSymbol)) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/batch"); assertThat(request.getResponseType()).isEqualTo(new GenericType<Map<String, BatchStocks>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", "market")); assertThat(request.getQueryParams()).containsExactly(entry("types", "book"), entry("symbols", "MSFT,IBM")); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final BatchStocksType stocksType = BatchStocksType.BOOK; final RestRequest<Map<String, BatchStocks>> request = new BatchMarketStocksRequestBuilder() .addType(stocksType) .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/batch"); assertThat(request.getResponseType()).isEqualTo(new GenericType<Map<String, BatchStocks>>() { }); assertThat(request.getPathParams()).containsExactly(entry("symbol", "market")); assertThat(request.getQueryParams()).containsExactly(entry("types", "book"), entry("symbols", symbol)); }
@Test public void batchChartRequestAcceptanceTest() { final Map<String, BatchStocks> batchStocks = iexTradingClient.executeRequest(new BatchMarketStocksRequestBuilder() .withSymbols(Lists.newArrayList("AAPL", "MSFT")) .addType(BatchStocksType.CHART) .withChartRange(ChartRange.ONE_MONTH) .build()); }
@Test public void batchBookMarketRequestAcceptanceTest() { final Map<String, BatchStocks> batchStocksMap = iexTradingClient.executeRequest(new BatchMarketStocksRequestBuilder() .withSymbol("AAPL") .addType(BatchStocksType.BOOK) .build()); }
@Test public void batchMarketStocksServiceTest() { stubFor(get(urlEqualTo("/stock/market/batch?types=company&symbols=aapl")) .withHeader("Accept", equalTo("application/json")) .willReturn(aResponse() .withStatus(200) .withHeader("Accept", "application/json") .withHeader("Content-Type", "application/json") .withBodyFile("rest/stock/BatchMarketStocksResponse.json"))); final Map<String, BatchStocks> batchStocksMap = iexTradingClient.executeRequest(new BatchMarketStocksRequestBuilder() .addType(BatchStocksType.COMPANY) .withSymbol("aapl") .build()); final BatchStocks batchStocks = batchStocksMap.get("AAPL"); final Company company = batchStocks.getCompany(); assertThat(company.getSymbol()).isEqualTo("AAPL"); assertThat(company.getCompanyName()).isEqualTo("Apple Inc."); assertThat(company.getExchange()).isEqualTo("Nasdaq Global Select"); assertThat(company.getIndustry()).isEqualTo("Computer Hardware"); assertThat(company.getWebsite()).isEqualTo("http://www.apple.com"); assertThat(company.getCEO()).isEqualTo("Timothy D. Cook"); assertThat(company.getIssueType()).isEqualTo("cs"); assertThat(company.getSector()).isEqualTo("Technology"); assertThat(company.getTags()).containsExactly("Technology", "Consumer Electronics", "Computer Hardware"); }
@Test public void shouldSuccessfullyCreateRequestWithChartRange() { final String symbol = "IBM"; final ChartRange range = ChartRange.ONE_MONTH; final BatchStocksType stocksType = BatchStocksType.CHART; final RestRequest<Map<String, BatchStocks>> request = new BatchMarketStocksRequestBuilder() .addType(stocksType) .withChartRange(range) .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/batch"); assertThat(request.getResponseType()).isEqualTo(new GenericType<Map<String, BatchStocks>>() {}); assertThat(request.getPathParams()).containsExactly(entry("symbol", "market")); assertThat(request.getQueryParams()).contains(entry("types", "chart"), entry("symbols", symbol), entry("range", range.getCode())); }