forked from open-telemetry/opentelemetry-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AttributeAssertionTest.java
27 lines (22 loc) · 1012 Bytes
/
AttributeAssertionTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.sdk.testing.assertj;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
import io.opentelemetry.api.common.AttributeKey;
import java.util.function.Consumer;
import org.assertj.core.api.AbstractAssert;
import org.junit.jupiter.api.Test;
class AttributeAssertionTest {
@Test
void nullAttr_errorMessageContainsAttrName() {
AttributeKey<String> key = AttributeKey.stringKey("flib");
AttributeAssertion attrAssertion = AttributeAssertion.create(key, AbstractAssert::isNotNull);
AbstractAssert<?, ?> anAssert = AttributeAssertion.attributeValueAssertion(key, null);
Consumer<AbstractAssert<?, ?>> a = attrAssertion.getAssertion();
String message = assertThrows(AssertionError.class, () -> a.accept(anAssert)).getMessage();
assertThat(message).isEqualTo("[STRING attribute 'flib'] \nExpecting actual not to be null");
}
}