Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attribute assertions should always contain the attr key (#5027)
* improve attribute assertions to alwyas contain the attr key * spotless * change assertion * Update sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/AttributeAssertionTest.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com> * fix build Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
- Loading branch information
1 parent
ea50096
commit 79a601d
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/AttributeAssertionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.testing.assertj; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import org.assertj.core.api.AbstractAssert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AttributeAssertionTest { | ||
|
||
@Test | ||
void nullAttr_errorMessageContainsAttrName() { | ||
AttributeKey<String> key = AttributeKey.stringKey("flib"); | ||
|
||
assertThatThrownBy( | ||
() -> | ||
AttributeAssertion.create(key, AbstractAssert::isNotNull) | ||
.getAssertion() | ||
.accept(AttributeAssertion.attributeValueAssertion(key, null))) | ||
.isInstanceOf(AssertionError.class) | ||
.hasMessage("[STRING attribute 'flib'] \nExpecting actual not to be null"); | ||
} | ||
} |