Skip to content

Commit

Permalink
Proposed fix for #96 (#97)
Browse files Browse the repository at this point in the history
* Proposed fix for #96

* Added unit test

Co-authored-by: Lucas Baizer <[email protected]>
  • Loading branch information
lucasbaizer2 and LucasBaizer authored Aug 27, 2020
1 parent 45a6a83 commit 940e217
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@
public class QuoteSseRequestBuilder extends AbstractSymbolSseRequestBuilder<List<Quote>, QuoteSseRequestBuilder> {

private QuoteInterval quoteInterval;
private boolean noUTP;

public QuoteSseRequestBuilder withQuoteInterval(final QuoteInterval quoteInterval) {
this.quoteInterval = quoteInterval;
return this;
}

public QuoteSseRequestBuilder withNoUTP() {
this.noUTP = true;
return this;
}

@Override
public SseRequest<List<Quote>> build() {
return SseRequestBuilder.<List<Quote>>builder()
.withPath("/stocksUS{interval}")
.withPath(noUTP ? "/stocksUSNoUTP{interval}" : "/stocksUS{interval}")
.addPathParam("interval", quoteInterval.getName())
.withResponse(new GenericType<List<Quote>>() {})
.addQueryParam(SYMBOL_PARAM, getSymbol())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,21 @@ public void shouldSuccessfullyCreateRequest() {
assertThat(request.getQueryParams()).contains(entry("nosnapshot", "false"), entry("symbols", symbol));
}

@Test
public void shouldSuccessfullyCreateRequestNoUTP() {
final String symbol = "IBM";

final SseRequest<List<Quote>> request = new QuoteSseRequestBuilder()
.withQuoteInterval(QuoteInterval.REALTIME)
.withSymbol(symbol)
.withNoUTP()
.build();

assertThat(request.getPath()).isEqualTo("/stocksUSNoUTP{interval}");
assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Quote>>() {
});
assertThat(request.getPathParams()).contains(entry("interval", ""));
assertThat(request.getQueryParams()).contains(entry("nosnapshot", "false"), entry("symbols", symbol));
}

}

0 comments on commit 940e217

Please sign in to comment.