Describe the bug
LongExemplarAssert.hasFilteredAttributesSatisfyingExactly(AttributeAssertion...) does not enforce exact attribute matching. It accepts an exemplar that has extra filtered attributes beyond those asserted, so a test using it can pass when it should fail.
Steps to reproduce
Assert a long exemplar that has multiple filtered attributes, but pass only a subset to hasFilteredAttributesSatisfyingExactly:
OpenTelemetryAssertions.assertThat(longGaugeMetric)
.hasLongGaugeSatisfying(gauge -> gauge.hasPointsSatisfying(point ->
point.hasExemplarsSatisfying(exemplar ->
// exemplar has several filtered attributes; only one is asserted
exemplar.hasFilteredAttributesSatisfyingExactly(equalTo(stringKey("bear"), "mya")))));
What did you expect to see?
An AssertionError, because the exemplar has filtered attributes that were not asserted. DoubleExemplarAssert.hasFilteredAttributesSatisfyingExactly (the sibling) behaves this way.
What did you see instead?
The assertion passes. The varargs overload delegates to hasFilteredAttributesSatisfying (AssertUtil.assertAttributes, a containsAll check) instead of the exact helper (assertAttributesExactly, containsExactlyInAnyOrder). See LongExemplarAssert.java line 128; DoubleExemplarAssert.java line 129 is correct.
What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-testing
Version: main @ 824334c (present since 1.21.0)
Environment
Compiler: Temurin 21
OS: N/A
Additional context
The Iterable overload in the same class is correct; only the varargs overload misroutes.
Describe the bug
LongExemplarAssert.hasFilteredAttributesSatisfyingExactly(AttributeAssertion...)does not enforce exact attribute matching. It accepts an exemplar that has extra filtered attributes beyond those asserted, so a test using it can pass when it should fail.Steps to reproduce
Assert a long exemplar that has multiple filtered attributes, but pass only a subset to
hasFilteredAttributesSatisfyingExactly:What did you expect to see?
An
AssertionError, because the exemplar has filtered attributes that were not asserted.DoubleExemplarAssert.hasFilteredAttributesSatisfyingExactly(the sibling) behaves this way.What did you see instead?
The assertion passes. The varargs overload delegates to
hasFilteredAttributesSatisfying(AssertUtil.assertAttributes, acontainsAllcheck) instead of the exact helper (assertAttributesExactly,containsExactlyInAnyOrder). SeeLongExemplarAssert.javaline 128;DoubleExemplarAssert.javaline 129 is correct.What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-testing
Version: main @ 824334c (present since 1.21.0)
Environment
Compiler: Temurin 21
OS: N/A
Additional context
The
Iterableoverload in the same class is correct; only the varargs overload misroutes.