Package io.micrometer.observation.tck
Class TestObservationRegistryAssert
java.lang.Object
org.assertj.core.api.AbstractAssert<TestObservationRegistryAssert,TestObservationRegistry>
io.micrometer.observation.tck.ObservationRegistryAssert<TestObservationRegistryAssert,TestObservationRegistry>
io.micrometer.observation.tck.TestObservationRegistryAssert
- All Implemented Interfaces:
org.assertj.core.api.Assert<TestObservationRegistryAssert,,TestObservationRegistry> org.assertj.core.api.Descriptable<TestObservationRegistryAssert>,org.assertj.core.api.ExtensionPoints<TestObservationRegistryAssert,TestObservationRegistry>
public class TestObservationRegistryAssert
extends ObservationRegistryAssert<TestObservationRegistryAssert,TestObservationRegistry>
Assertion methods for
MeterRegistrys.
To create a new instance of this class, invoke
assertThat(TestObservationRegistry) or
then(TestObservationRegistry).
- Since:
- 1.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classProvides assertions forObservationand allows coming back toTestObservationRegistryAssert.static final classProvides assertions forObservationand allows coming back toTestObservationRegistryAssert. -
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionassertThat(TestObservationRegistry actual) Creates the assert object forTestObservationRegistry.voidVerifies that there are no observations registered.forAllObservationsWithNameEqualTo(String name, Consumer<ObservationContextAssert> observationConsumer) Provides verification for all Observations having the given name.forAllObservationsWithNameEqualToIgnoreCase(String name, Consumer<ObservationContextAssert> observationConsumer) Provides verification for all Observations having the given name (ignoring case).hasAnObservation(Consumer<ObservationContextAssert> observationConsumer) Provides verification for all Observations.hasAnObservationWithAKeyName(io.micrometer.common.docs.KeyName key) Verifies that there is an Observation with a key name.Verifies that there is an Observation with a key name.hasAnObservationWithAKeyValue(io.micrometer.common.docs.KeyName key, String value) Verifies that there is an Observation with a key value.hasAnObservationWithAKeyValue(io.micrometer.common.KeyValue keyValue) Verifies that there is an Observation with a key value.hasAnObservationWithAKeyValue(String key, String value) Verifies that there is an Observation with a key value.hasHandledContextsThatSatisfy(org.assertj.core.api.ThrowingConsumer<List<io.micrometer.observation.Observation.Context>> contextConsumer) Verifies that all handled contexts satisfy the provided lambda.hasNumberOfObservationsEqualTo(int expectedNumberOfObservations) Verifies that there is a proper number of Observations.hasNumberOfObservationsWithNameEqualTo(String observationName, int expectedNumberOfObservations) Verifies that there is a proper number of Observations with the given name.hasNumberOfObservationsWithNameEqualToIgnoreCase(String observationName, int expectedNumberOfObservations) Verifies that there is a proper number of Observations with the given name (ignoring case).Verifies that there's only oneObservationwith a given name and continues assertions for it.Verifies that there's at least oneObservationwith a given name (ignoring case) and continues assertions for the first found one.Verifies that there's only oneObservationand continues assertions for it.then(TestObservationRegistry actual) Creates the assert object forTestObservationRegistry.Methods inherited from class io.micrometer.observation.tck.ObservationRegistryAssert
assertThat, doesNotHaveAnyRemainingCurrentObservation, doesNotHaveAnyRemainingCurrentScope, doesNotHaveRemainingCurrentObservationSameAs, doesNotHaveRemainingCurrentScopeSameAs, hasRemainingCurrentObservation, hasRemainingCurrentObservationSameAs, hasRemainingCurrentScope, hasRemainingCurrentScopeSameAs, thenMethods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs
-
Constructor Details
-
TestObservationRegistryAssert
-
-
Method Details
-
assertThat
Creates the assert object forTestObservationRegistry.- Parameters:
actual- mock observation registry to assert against- Returns:
- meter registry assertions
-
then
Creates the assert object forTestObservationRegistry.- Parameters:
actual- mock observation registry to assert against- Returns:
- meter registry assertions
-
hasSingleObservationThat
public TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert hasSingleObservationThat()Verifies that there's only oneObservationand continues assertions for it.- Returns:
- this
- Throws:
AssertionError- if there is none or more than one observation
-
hasObservationWithNameEqualTo
Verifies that there's only oneObservationwith a given name and continues assertions for it.- Returns:
- this
- Throws:
AssertionError- if there is no matching observation
-
hasObservationWithNameEqualToIgnoringCase
Verifies that there's at least oneObservationwith a given name (ignoring case) and continues assertions for the first found one.- Returns:
- this
- Throws:
AssertionError- if there is no matching observation
-
doesNotHaveAnyObservation
public void doesNotHaveAnyObservation()Verifies that there are no observations registered.- Throws:
AssertionError- if there are any registered observations
-
hasHandledContextsThatSatisfy
public TestObservationRegistryAssert hasHandledContextsThatSatisfy(org.assertj.core.api.ThrowingConsumer<List<io.micrometer.observation.Observation.Context>> contextConsumer) Verifies that all handled contexts satisfy the provided lambda.- Parameters:
contextConsumer- lambda to assert all handled contexts- Returns:
- this
-
forAllObservationsWithNameEqualTo
public TestObservationRegistryAssert forAllObservationsWithNameEqualTo(String name, Consumer<ObservationContextAssert> observationConsumer) Provides verification for all Observations having the given name.Examples:
// assertions succeed assertThat(testObservationRegistry).forAllObservationsWithNameEqualTo("foo", observationContextAssert -> observationContextAssert.hasError()); // assertions fail - assuming that there was a foo observation but none had errors assertThat(testObservationRegistry).forAllObservationsWithNameEqualTo("foo", observationContextAssert -> observationContextAssert.hasError());- Parameters:
name- searched Observation nameobservationConsumer- assertion to be executed for each Observation- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with the given nameAssertionError- if there is an Observation with the given name but the additional assertion is not successful
-
forAllObservationsWithNameEqualToIgnoreCase
public TestObservationRegistryAssert forAllObservationsWithNameEqualToIgnoreCase(String name, Consumer<ObservationContextAssert> observationConsumer) Provides verification for all Observations having the given name (ignoring case).Examples:
// assertions succeed assertThat(testObservationRegistry).forAllObservationsWithNameEqualTo("foo", observationContextAssert -> observationContextAssert.hasError()); // assertions fail - assuming that there was a foo observation but none had errors assertThat(testObservationRegistry).forAllObservationsWithNameEqualTo("foo", observationContextAssert -> observationContextAssert.hasError());- Parameters:
name- searched Observation name (ignoring case)observationConsumer- assertion to be executed for each Observation- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with the given name (ignoring case)AssertionError- if there is an Observation with the given name (ignoring case) but the additional assertion is not successful
-
hasNumberOfObservationsEqualTo
public TestObservationRegistryAssert hasNumberOfObservationsEqualTo(int expectedNumberOfObservations) Verifies that there is a proper number of Observations.Examples:
// assertions succeed assertThat(testObservationRegistry).hasNumberOfObservationsEqualTo(1); // assertions fail - assuming that there was only 1 observation assertThat(testObservationRegistry).hasNumberOfObservationsEqualTo(2);- Parameters:
expectedNumberOfObservations- expected number of Observations- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the number of Observations is different from the desired one
-
hasNumberOfObservationsWithNameEqualTo
public TestObservationRegistryAssert hasNumberOfObservationsWithNameEqualTo(String observationName, int expectedNumberOfObservations) Verifies that there is a proper number of Observations with the given name.Examples:
// assertions succeed assertThat(testObservationRegistry).hasNumberOfObservationsWithNameEqualTo("foo", 1); // assertions fail - assuming that there is only 1 observation with that name assertThat(testObservationRegistry).hasNumberOfObservationsWithNameEqualTo("foo", 2);- Parameters:
observationName- Observation nameexpectedNumberOfObservations- expected number of Observations with the given name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the number of properly named Observations is different from the desired one
-
hasNumberOfObservationsWithNameEqualToIgnoreCase
public TestObservationRegistryAssert hasNumberOfObservationsWithNameEqualToIgnoreCase(String observationName, int expectedNumberOfObservations) Verifies that there is a proper number of Observations with the given name (ignoring case).Examples:
// assertions succeed assertThat(testObservationRegistry).hasNumberOfObservationsWithNameEqualToIgnoreCase("foo", 1); // assertions fail - assuming that there's only 1 such observation assertThat(testObservationRegistry).hasNumberOfObservationsWithNameEqualToIgnoreCase("foo", 2);- Parameters:
observationName- Observation nameexpectedNumberOfObservations- expected number of Observations with the given name (ignoring case)- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if the number of properly named Observations is different from the desired one
-
hasAnObservationWithAKeyValue
Verifies that there is an Observation with a key value.Examples:
// assertions succeed assertThat(testObservationRegistry).hasAnObservationWithAKeyValue("foo", "bar"); // assertions fail - assuming that there is no such a key value in any observation assertThat(testObservationRegistry).hasAnObservationWithAKeyValue("foo", "bar");- Parameters:
key- expected key namevalue- expected key value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with given key name and value
-
hasAnObservationWithAKeyValue
public TestObservationRegistryAssert hasAnObservationWithAKeyValue(io.micrometer.common.KeyValue keyValue) Verifies that there is an Observation with a key value.Examples:
// assertions succeed assertThat(testObservationRegistry).hasAnObservationWithAKeyValue(KeyValue.of("foo", "bar")); // assertions fail - assuming that there is no such a key value in any observation assertThat(testObservationRegistry).hasAnObservationWithAKeyValue(KeyValue.of("foo", "bar"));- Parameters:
keyValue- expected key value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with given key name and value- Since:
- 1.12.0
-
hasAnObservationWithAKeyName
Verifies that there is an Observation with a key name.Examples:
// assertions succeed assertThat(testObservationRegistry).hasAnObservationWithAKeyName("foo"); // assertions fail - assuming that there are no observations with such a key name assertThat(testObservationRegistry).hasAnObservationWithAKeyName("foo");- Parameters:
key- expected key name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with given key name
-
hasAnObservationWithAKeyValue
public TestObservationRegistryAssert hasAnObservationWithAKeyValue(io.micrometer.common.docs.KeyName key, String value) Verifies that there is an Observation with a key value.Examples:
// assertions succeed assertThat(testObservationRegistry).hasAnObservationWithAKeyValue(SomeKeyName.FOO, "bar"); // assertions fail - assuming that there are no observations with such a key value assertThat(testObservationRegistry).hasAnObservationWithAKeyValue(SomeKeyName.FOO, "baz");- Parameters:
key- expected key namevalue- expected key value- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with given key name and value
-
hasAnObservationWithAKeyName
public TestObservationRegistryAssert hasAnObservationWithAKeyName(io.micrometer.common.docs.KeyName key) Verifies that there is an Observation with a key name.Examples:
// assertions succeed assertThat(testObservationRegistry).hasAnObservationWithAKeyName(SomeKeyName.FOO); // assertions fail - assuming that there are no observation with such a key name assertThat(testObservationRegistry).hasAnObservationWithAKeyName(SomeKeyName.FOO);- Parameters:
key- expected key name- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation with given key name
-
hasAnObservation
public TestObservationRegistryAssert hasAnObservation(Consumer<ObservationContextAssert> observationConsumer) Provides verification for all Observations.Examples:
// assertions succeed assertThat(testObservationRegistry).hasAnObservation(observationContextAssert -> observationContextAssert.hasNameEqualTo("foo").hasError()); // assertions fail - assuming that there was a foo observation but none had errors assertThat(testObservationRegistry).hasAnObservation(observationContextAssert -> observationContextAssert.hasNameEqualTo("foo").hasError());- Parameters:
observationConsumer- assertion to be executed for each Observation- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value isnull.AssertionError- if there is no Observation that passes the assertion- Since:
- 1.11.0
-