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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### SDK

#### Testing

* Add `hasValueSatisfying` to `LongPointAssert` and `DoublePointAssert` for fuzzy value matching

## Version 1.61.0 (2026-04-10)

### API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Comparing source compatibility of opentelemetry-sdk-testing-1.62.0-SNAPSHOT.jar against opentelemetry-sdk-testing-1.61.0.jar
No changes.
*** 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.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<?>>)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.assertj.core.api.AbstractDoubleAssert;
import org.assertj.core.api.Assertions;

/**
Expand All @@ -33,6 +34,13 @@ public DoublePointAssert hasValue(double expected) {
return this;
}

/** Asserts the point's value satisfies the given assertion. */
public DoublePointAssert hasValueSatisfying(Consumer<AbstractDoubleAssert<?>> valueAssertion) {
isNotNull();
valueAssertion.accept(Assertions.assertThat(actual.getValue()).as("value"));
return this;
}

/** Asserts the point has the specified exemplars, in any order. */
public DoublePointAssert hasExemplars(DoubleExemplarData... exemplars) {
isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.assertj.core.api.AbstractLongAssert;

/**
* Assertions for an exported {@link LongPointData}.
Expand All @@ -31,6 +32,13 @@ public LongPointAssert hasValue(long expected) {
return this;
}

/** Asserts the point's value satisfies the given assertion. */
public LongPointAssert hasValueSatisfying(Consumer<AbstractLongAssert<?>> valueAssertion) {
isNotNull();
valueAssertion.accept(assertThat(actual.getValue()).as("value"));
return this;
}

/** Asserts the point has the specified exemplars, in any order. */
public LongPointAssert hasExemplars(LongExemplarData... exemplars) {
isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ void doubleGauge() {
.hasEpochNanos(4)
.hasAttributes(Attributes.empty())
.hasValue(3.0)
.hasValueSatisfying(val -> val.isEqualTo(3.0))
.hasExemplars(DOUBLE_EXEMPLAR2, DOUBLE_EXEMPLAR1)
.hasExemplarsSatisfying(
exemplar ->
Expand Down Expand Up @@ -857,6 +858,7 @@ void longGauge() {
point ->
point
.hasValue(Long.MAX_VALUE)
.hasValueSatisfying(val -> val.isEqualTo(Long.MAX_VALUE))
.hasExemplarsSatisfying(
exemplar -> exemplar.hasValue(2),
exemplar ->
Expand Down Expand Up @@ -903,6 +905,15 @@ void longGaugeFailure() {
gauge.hasPointsSatisfying(
point -> point.hasValue(2), point -> point.hasValue(1))))
.isInstanceOf(AssertionError.class);
assertThatThrownBy(
() ->
assertThat(LONG_GAUGE_METRIC)
.hasLongGaugeSatisfying(
gauge ->
gauge.hasPointsSatisfying(
point -> point.hasValueSatisfying(val -> val.isNegative()),
point -> point.hasValueSatisfying(val -> val.isNegative()))))
.isInstanceOf(AssertionError.class);
assertThatThrownBy(
() ->
assertThat(LONG_GAUGE_METRIC)
Expand Down
Loading