Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#### Testing

* Add `hasValueSatisfying` to `LongPointAssert` and `DoublePointAssert` for fuzzy value matching
* Add `containsPointsSatisfying` to metric data asserts for "each given assertion must be
satisfied by at least one point, extras allowed" checks on sum, gauge, histogram, exponential
histogram, and summary data

## Version 1.61.0 (2026-04-10)

Expand Down
35 changes: 35 additions & 0 deletions docs/apidiffs/current_vs_latest/opentelemetry-sdk-testing.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
Comparing source compatibility of opentelemetry-sdk-testing-1.62.0-SNAPSHOT.jar against opentelemetry-sdk-testing-1.61.0.jar
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.DoubleGaugeAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.DoubleGaugeAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.DoublePointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.DoubleGaugeAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.DoublePointAssert>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.DoublePointAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.DoublePointAssert hasValueSatisfying(java.util.function.Consumer<org.assertj.core.api.AbstractDoubleAssert<?>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.DoubleSumAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.DoubleSumAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.DoublePointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.DoubleSumAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.DoublePointAssert>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.ExponentialHistogramAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.ExponentialHistogramAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.ExponentialHistogramPointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.ExponentialHistogramAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.ExponentialHistogramPointAssert>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.HistogramAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.HistogramAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.HistogramPointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.HistogramAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.HistogramPointAssert>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.LongGaugeAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.LongGaugeAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.LongPointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.LongGaugeAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.LongPointAssert>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.LongPointAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.LongPointAssert hasValueSatisfying(java.util.function.Consumer<org.assertj.core.api.AbstractLongAssert<?>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.LongSumAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.LongSumAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.LongPointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.LongSumAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.LongPointAssert>>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.SummaryAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.SummaryAssert containsPointsSatisfying(java.util.function.Consumer[]<io.opentelemetry.sdk.testing.assertj.SummaryPointAssert>)
+++ NEW ANNOTATION: java.lang.SafeVarargs
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.SummaryAssert containsPointsSatisfying(java.lang.Iterable<? extends java.util.function.Consumer<? extends io.opentelemetry.sdk.testing.assertj.SummaryPointAssert>>)
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,31 @@ public DoubleGaugeAssert hasPointsSatisfying(
.satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, DoublePointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the gauge satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final DoubleGaugeAssert containsPointsSatisfying(
Consumer<DoublePointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the gauge satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
public DoubleGaugeAssert containsPointsSatisfying(
Iterable<? extends Consumer<DoublePointAssert>> assertions) {
isNotNull();
for (Consumer<DoublePointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new DoublePointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,30 @@ public DoubleSumAssert hasPointsSatisfying(
.satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, DoublePointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the sum satisfies it. Extra points
* that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final DoubleSumAssert containsPointsSatisfying(Consumer<DoublePointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the sum satisfies it. Extra points
* that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
public DoubleSumAssert containsPointsSatisfying(
Iterable<? extends Consumer<DoublePointAssert>> assertions) {
isNotNull();
for (Consumer<DoublePointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new DoublePointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,31 @@ public ExponentialHistogramAssert hasPointsSatisfying(
AssertUtil.toConsumers(assertions, ExponentialHistogramPointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the exponential histogram
* satisfies it. Extra points that match none of the assertions are allowed, and a single point
* may satisfy multiple assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final ExponentialHistogramAssert containsPointsSatisfying(
Consumer<ExponentialHistogramPointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the exponential histogram
* satisfies it. Extra points that match none of the assertions are allowed, and a single point
* may satisfy multiple assertions.
*/
public ExponentialHistogramAssert containsPointsSatisfying(
Iterable<? extends Consumer<ExponentialHistogramPointAssert>> assertions) {
isNotNull();
for (Consumer<ExponentialHistogramPointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new ExponentialHistogramPointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,31 @@ public HistogramAssert hasPointsSatisfying(
.satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, HistogramPointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the histogram satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final HistogramAssert containsPointsSatisfying(
Consumer<HistogramPointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the histogram satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
public HistogramAssert containsPointsSatisfying(
Iterable<? extends Consumer<HistogramPointAssert>> assertions) {
isNotNull();
for (Consumer<HistogramPointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new HistogramPointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,30 @@ public LongGaugeAssert hasPointsSatisfying(
.satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, LongPointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the gauge satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final LongGaugeAssert containsPointsSatisfying(Consumer<LongPointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the gauge satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
public LongGaugeAssert containsPointsSatisfying(
Iterable<? extends Consumer<LongPointAssert>> assertions) {
isNotNull();
for (Consumer<LongPointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new LongPointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,30 @@ public LongSumAssert hasPointsSatisfying(
.satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, LongPointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the sum satisfies it. Extra points
* that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final LongSumAssert containsPointsSatisfying(Consumer<LongPointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the sum satisfies it. Extra points
* that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
public LongSumAssert containsPointsSatisfying(
Iterable<? extends Consumer<LongPointAssert>> assertions) {
isNotNull();
for (Consumer<LongPointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new LongPointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,30 @@ public SummaryAssert hasPointsSatisfying(
.satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, SummaryPointAssert::new));
return this;
}

/**
* Asserts that for each given assertion, at least one point in the summary satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
@SafeVarargs
@SuppressWarnings("varargs")
public final SummaryAssert containsPointsSatisfying(Consumer<SummaryPointAssert>... assertions) {
return containsPointsSatisfying(Arrays.asList(assertions));
}

/**
* Asserts that for each given assertion, at least one point in the summary satisfies it. Extra
* points that match none of the assertions are allowed, and a single point may satisfy multiple
* assertions.
*/
public SummaryAssert containsPointsSatisfying(
Iterable<? extends Consumer<SummaryPointAssert>> assertions) {
isNotNull();
for (Consumer<SummaryPointAssert> assertion : assertions) {
assertThat(actual.getPoints())
.anySatisfy(point -> assertion.accept(new SummaryPointAssert(point)));
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1299,4 +1299,70 @@ void summary_failure() {
point -> point.hasValuesSatisfying(value -> value.hasValue(3.0)))))
.isInstanceOf(AssertionError.class);
}

@Test
void containsPointsSatisfying() {
assertThat(DOUBLE_GAUGE_METRIC)
.hasDoubleGaugeSatisfying(
gauge -> gauge.containsPointsSatisfying(point -> point.hasValue(3.0)));
assertThat(LONG_GAUGE_METRIC)
.hasLongGaugeSatisfying(
gauge ->
gauge.containsPointsSatisfying(
point -> point.hasValue(Long.MAX_VALUE), point -> point.hasValue(1)));
assertThat(DOUBLE_SUM_METRIC)
.hasDoubleSumSatisfying(sum -> sum.containsPointsSatisfying(point -> point.hasValue(3.0)));
assertThat(LONG_SUM_METRIC)
.hasLongSumSatisfying(
sum -> sum.containsPointsSatisfying(point -> point.hasValue(Long.MAX_VALUE)));
assertThat(HISTOGRAM_METRIC)
.hasHistogramSatisfying(
histogram -> histogram.containsPointsSatisfying(point -> point.hasSum(15)));
assertThat(EXPONENTIAL_HISTOGRAM_METRIC)
.hasExponentialHistogramSatisfying(
histogram -> histogram.containsPointsSatisfying(point -> point.hasSum(10.0)));
assertThat(SUMMARY_METRIC)
.hasSummarySatisfying(
summary -> summary.containsPointsSatisfying(point -> point.hasSum(2.0)));
}

@Test
void containsPointsSatisfyingFailure() {
// single assertion that matches no point
assertThatThrownBy(
() ->
assertThat(DOUBLE_GAUGE_METRIC)
.hasDoubleGaugeSatisfying(
gauge -> gauge.containsPointsSatisfying(point -> point.hasValue(42.0))))
.isInstanceOf(AssertionError.class);
// one of multiple assertions unmatched
assertThatThrownBy(
() ->
assertThat(LONG_GAUGE_METRIC)
.hasLongGaugeSatisfying(
gauge ->
gauge.containsPointsSatisfying(
point -> point.hasValue(Long.MAX_VALUE),
point -> point.hasValue(42))))
.isInstanceOf(AssertionError.class);
assertThatThrownBy(
() ->
assertThat(HISTOGRAM_METRIC)
.hasHistogramSatisfying(
histogram -> histogram.containsPointsSatisfying(point -> point.hasSum(42))))
.isInstanceOf(AssertionError.class);
assertThatThrownBy(
() ->
assertThat(EXPONENTIAL_HISTOGRAM_METRIC)
.hasExponentialHistogramSatisfying(
histogram ->
histogram.containsPointsSatisfying(point -> point.hasSum(42.0))))
.isInstanceOf(AssertionError.class);
assertThatThrownBy(
() ->
assertThat(SUMMARY_METRIC)
.hasSummarySatisfying(
summary -> summary.containsPointsSatisfying(point -> point.hasSum(42.0))))
.isInstanceOf(AssertionError.class);
}
}
Loading