private void securityEventAsyncRequestBuilder() { final SocketRequest<DeepAsyncResponse<SecurityEvent>> request = new SecurityEventAsyncRequestBuilder() .withSymbol("AAPL") .build(); iexTradingClient.subscribe(request, SECURITY_EVENT_CONSUMER); }
@Test public void securityEventAsyncServiceTest() { stubFor(socket) .withResponseFile("/marketdata/SecurityEventAsyncResponse.json"); final Consumer<DeepAsyncResponse<SecurityEvent>> consumer = spy(Consumer.class); iexTradingClient.subscribe(new SecurityEventAsyncRequestBuilder() .withSymbol("AAPL") .build(), consumer); verify(consumer).accept(dataCaptor.capture()); final DeepAsyncResponse<SecurityEvent> response = dataCaptor.getValue(); assertThat(response.getSymbol()).isEqualTo("AAPL"); assertThat(response.getMessageType()).isEqualTo(DeepMessageType.SECURITY_EVENT); assertThat(response.getSeq()).isEqualTo(2L); final SecurityEvent data = response.getData(); assertThat(data.getSecurityEvent()).isEqualTo(SecurityEventType.MarketClose); assertThat(data.getTimestamp()).isEqualTo(1529611200000L); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final SocketRequest<DeepAsyncResponse<SecurityEvent>> request = new SecurityEventAsyncRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getPath()).isEqualTo("/deep"); final DeepAsyncRequest param = (DeepAsyncRequest) request.getParam(); assertThat(param.getSymbols()).containsExactly(symbol); assertThat(param.getChannels()).containsExactly(DeepChannel.SECURITY_EVENT); }