Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,22 @@ void statusCountbackWindowDecodes() {
}
}
}

@Test
void statusCountbackReturnsExactlyNDaysEndingAtTo() {
// A bare request (no window params) returns a single day — today. countback=5 paired with
// `to` must widen that to exactly 5 calendar days ending at `to`, proving the parameter
// reached the wire rather than being ignored.
LocalDate to = LocalDate.now();

MarketStatusResponse unfiltered = client.markets().status(MarketStatusRequest.of());
MarketStatusResponse countback =
client.markets().status(MarketStatusRequest.builder().to(to).countback(5).build());

assertThat(countback.statusCode()).isIn(200, 203);
assertThat(countback.values()).as("countback=5 returns exactly 5 days ending at `to`").hasSize(5);
assertThat(countback.values().size())
.as("countback widens the result past the unfiltered single-day default")
.isGreaterThan(unfiltered.values().size());
}
}
12 changes: 12 additions & 0 deletions src/test/java/com/marketdata/sdk/MarketsResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,18 @@ void statusRequestRejectsDateWithRange() {
.hasMessageContaining("mutually exclusive");
}

@Test
void statusRequestRejectsCountbackWithDate() {
assertThatThrownBy(
() ->
MarketStatusRequest.builder()
.date(LocalDate.of(2025, Month.JANUARY, 1))
.countback(5)
.build())
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("mutually exclusive");
}

@Test
void statusRequestRejectsCountbackWithFrom() {
assertThatThrownBy(
Expand Down
Loading