File tree Expand file tree Collapse file tree
docs/apidiffs/current_vs_latest
main/java/io/opentelemetry/sdk/testing/assertj
test/java/io/opentelemetry/sdk/testing/assertj Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ ### SDK
6+
7+ #### Testing
8+
9+ * Add ` hasValueSatisfying ` to ` LongPointAssert ` and ` DoublePointAssert ` for fuzzy value matching
10+
511## Version 1.61.0 (2026-04-10)
612
713### API
Original file line number Diff line number Diff line change 11Comparing source compatibility of opentelemetry-sdk-testing-1.62.0-SNAPSHOT.jar against opentelemetry-sdk-testing-1.61.0.jar
2- No changes.
2+ *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.DoublePointAssert (not serializable)
3+ === CLASS FILE FORMAT VERSION: 52.0 <- 52.0
4+ +++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.DoublePointAssert hasValueSatisfying(java.util.function.Consumer<org.assertj.core.api.AbstractDoubleAssert<?>>)
5+ *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.LongPointAssert (not serializable)
6+ === CLASS FILE FORMAT VERSION: 52.0 <- 52.0
7+ +++ 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 1212import java .util .Arrays ;
1313import java .util .function .Consumer ;
1414import javax .annotation .Nullable ;
15+ import org .assertj .core .api .AbstractDoubleAssert ;
1516import org .assertj .core .api .Assertions ;
1617
1718/**
@@ -33,6 +34,13 @@ public DoublePointAssert hasValue(double expected) {
3334 return this ;
3435 }
3536
37+ /** Asserts the point's value satisfies the given assertion. */
38+ public DoublePointAssert hasValueSatisfying (Consumer <AbstractDoubleAssert <?>> valueAssertion ) {
39+ isNotNull ();
40+ valueAssertion .accept (Assertions .assertThat (actual .getValue ()).as ("value" ));
41+ return this ;
42+ }
43+
3644 /** Asserts the point has the specified exemplars, in any order. */
3745 public DoublePointAssert hasExemplars (DoubleExemplarData ... exemplars ) {
3846 isNotNull ();
Original file line number Diff line number Diff line change 1212import java .util .Arrays ;
1313import java .util .function .Consumer ;
1414import javax .annotation .Nullable ;
15+ import org .assertj .core .api .AbstractLongAssert ;
1516
1617/**
1718 * Assertions for an exported {@link LongPointData}.
@@ -31,6 +32,13 @@ public LongPointAssert hasValue(long expected) {
3132 return this ;
3233 }
3334
35+ /** Asserts the point's value satisfies the given assertion. */
36+ public LongPointAssert hasValueSatisfying (Consumer <AbstractLongAssert <?>> valueAssertion ) {
37+ isNotNull ();
38+ valueAssertion .accept (assertThat (actual .getValue ()).as ("value" ));
39+ return this ;
40+ }
41+
3442 /** Asserts the point has the specified exemplars, in any order. */
3543 public LongPointAssert hasExemplars (LongExemplarData ... exemplars ) {
3644 isNotNull ();
Original file line number Diff line number Diff line change @@ -352,6 +352,7 @@ void doubleGauge() {
352352 .hasEpochNanos (4 )
353353 .hasAttributes (Attributes .empty ())
354354 .hasValue (3.0 )
355+ .hasValueSatisfying (val -> val .isEqualTo (3.0 ))
355356 .hasExemplars (DOUBLE_EXEMPLAR2 , DOUBLE_EXEMPLAR1 )
356357 .hasExemplarsSatisfying (
357358 exemplar ->
@@ -857,6 +858,7 @@ void longGauge() {
857858 point ->
858859 point
859860 .hasValue (Long .MAX_VALUE )
861+ .hasValueSatisfying (val -> val .isEqualTo (Long .MAX_VALUE ))
860862 .hasExemplarsSatisfying (
861863 exemplar -> exemplar .hasValue (2 ),
862864 exemplar ->
@@ -903,6 +905,15 @@ void longGaugeFailure() {
903905 gauge .hasPointsSatisfying (
904906 point -> point .hasValue (2 ), point -> point .hasValue (1 ))))
905907 .isInstanceOf (AssertionError .class );
908+ assertThatThrownBy (
909+ () ->
910+ assertThat (LONG_GAUGE_METRIC )
911+ .hasLongGaugeSatisfying (
912+ gauge ->
913+ gauge .hasPointsSatisfying (
914+ point -> point .hasValueSatisfying (val -> val .isNegative ()),
915+ point -> point .hasValueSatisfying (val -> val .isNegative ()))))
916+ .isInstanceOf (AssertionError .class );
906917 assertThatThrownBy (
907918 () ->
908919 assertThat (LONG_GAUGE_METRIC )
You can’t perform that action at this time.
0 commit comments