Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
HaloFour committed May 25, 2022
1 parent efa42e4 commit cc1b94e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
Comparing source compatibility of against
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert assertThat(io.opentelemetry.sdk.trace.data.StatusData)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.testing.assertj.SpanDataAssert (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.SpanDataAssert hasStatusSatisfying(java.util.function.Consumer)
+++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert hasCode(io.opentelemetry.api.trace.StatusCode)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert hasDescription(java.lang.String)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert hasDescriptionMatching(java.util.regex.Pattern)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert hasDescriptionSatisfying(java.util.function.Consumer)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert hasDescriptionMatching(java.lang.String)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert isError()
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.testing.assertj.StatusDataAssert isOk()
*** MODIFIED CLASS: PUBLIC io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader (not serializable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.trace.data.EventData;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -42,11 +41,6 @@ public static SpanDataAssert assertThat(@Nullable SpanData spanData) {
return new SpanDataAssert(spanData);
}

/** Returns an assertion for {@link StatusData}. */
public static StatusDataAssert assertThat(@Nullable StatusData statusData) {
return new StatusDataAssert(statusData);
}

/** Returns an assertion for {@link MetricData}. */
public static MetricAssert assertThat(@Nullable MetricData metricData) {
return new MetricAssert(metricData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.StringAssert;

/** Assertions for the {@link StatusData} of an exported {@link SpanData}. */
public final class StatusDataAssert extends AbstractAssert<StatusDataAssert, StatusData> {
Expand Down Expand Up @@ -47,18 +44,10 @@ public StatusDataAssert hasDescription(String expected) {
return this;
}

/** Asserts that the status has a description matching the given pattern. */
public StatusDataAssert hasDescriptionMatching(Pattern pattern) {
/** Asserts that the status has a description matching the given regular expression. */
public StatusDataAssert hasDescriptionMatching(String regex) {
isNotNull();
assertThat(actual.getDescription()).matches(pattern);
return this;
}

/** Asserts that the status has a description that satisfies the given condition. */
public StatusDataAssert hasDescriptionSatisfying(Consumer<StringAssert> condition) {
isNotNull();
StringAssert stringAssert = new StringAssert(actual.getDescription());
condition.accept(stringAssert);
assertThat(actual.getDescription()).matches(regex);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import org.assertj.core.api.AbstractCharSequenceAssert;
import org.junit.jupiter.api.Test;

@SuppressWarnings("PreferJavaTimeOverload")
Expand Down Expand Up @@ -250,8 +248,7 @@ void passing() {
.isOk()
.hasCode(StatusCode.OK)
.hasDescription("")
.hasDescriptionMatching(Pattern.compile("^$"))
.hasDescriptionSatisfying(AbstractCharSequenceAssert::isBlank))
.hasDescriptionMatching("^$"))
.endsAt(200)
.endsAt(200, TimeUnit.NANOSECONDS)
.endsAt(Instant.ofEpochSecond(0, 200))
Expand Down Expand Up @@ -444,10 +441,7 @@ void failure() {
assertThatThrownBy(
() ->
assertThat(SPAN1)
.hasStatusSatisfying(
status ->
status.hasDescriptionSatisfying(
AbstractCharSequenceAssert::isNotBlank)))
.hasStatusSatisfying(status -> status.hasDescriptionMatching("test")))
.isInstanceOf(AssertionError.class);
assertThatThrownBy(() -> assertThat(SPAN1).endsAt(10)).isInstanceOf(AssertionError.class);
assertThatThrownBy(() -> assertThat(SPAN1).endsAt(10, TimeUnit.NANOSECONDS))
Expand Down

0 comments on commit cc1b94e

Please sign in to comment.