Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>0.37</version>
<version>0.44</version>
</dependency>
<!-- Metrics library -->
<dependency>
Expand All @@ -36,7 +36,7 @@
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-java8-extension</artifactId>
<version>0.37</version>
<version>0.44</version>
<scope>test</scope>
</dependency>
<!-- JUnit backport -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ And<S> andChainer() {
Joiner.on(':').join(metricPoint.labelValues()),
getMessageRepresentation(metricPoint.value()));

private final Metric<T> actual;

protected AbstractMetricSubject(FailureMetadata metadata, Metric<T> actual) {
super(metadata, checkNotNull(actual));
this.actual = actual;
}

/**
Expand All @@ -84,7 +87,7 @@ protected AbstractMetricSubject(FailureMetadata metadata, Metric<T> actual) {
*/
@Override
public String actualCustomStringRepresentation() {
return actual().getMetricSchema().name();
return actual.getMetricSchema().name();
}

/**
Expand All @@ -102,7 +105,7 @@ public And<S> hasValueForLabels(T value, String... labels) {
Joiner.on(':').join(labels),
"has labeled values",
Lists.transform(
Ordering.<MetricPoint<T>>natural().sortedCopy(actual().getTimestampedValues()),
Ordering.<MetricPoint<T>>natural().sortedCopy(actual.getTimestampedValues()),
metricPointConverter));
}
if (!metricPoint.value().equals(value)) {
Expand Down Expand Up @@ -130,7 +133,7 @@ public And<S> hasAnyValueForLabels(String... labels) {
Joiner.on(':').join(labels),
"has labeled values",
Lists.transform(
Ordering.<MetricPoint<T>>natural().sortedCopy(actual().getTimestampedValues()),
Ordering.<MetricPoint<T>>natural().sortedCopy(actual.getTimestampedValues()),
metricPointConverter));
}
if (hasDefaultValue(metricPoint)) {
Expand Down Expand Up @@ -162,15 +165,15 @@ protected And<S> doesNotHaveAnyValueForLabels(String... labels) {
* has already been made.
*/
public And<S> hasNoOtherValues() {
for (MetricPoint<T> metricPoint : actual().getTimestampedValues()) {
for (MetricPoint<T> metricPoint : actual.getTimestampedValues()) {
if (!expectedNondefaultLabelTuples.contains(metricPoint.labelValues())) {
if (!hasDefaultValue(metricPoint)) {
failWithBadResults(
"has",
"no other nondefault values",
"has labeled values",
Lists.transform(
Ordering.<MetricPoint<T>>natural().sortedCopy(actual().getTimestampedValues()),
Ordering.<MetricPoint<T>>natural().sortedCopy(actual.getTimestampedValues()),
metricPointConverter));
}
return andChainer();
Expand All @@ -180,10 +183,10 @@ public And<S> hasNoOtherValues() {
}

private @Nullable MetricPoint<T> findMetricPointForLabels(ImmutableList<String> labels) {
if (actual().getMetricSchema().labels().size() != labels.size()) {
if (actual.getMetricSchema().labels().size() != labels.size()) {
return null;
}
for (MetricPoint<T> metricPoint : actual().getTimestampedValues()) {
for (MetricPoint<T> metricPoint : actual.getTimestampedValues()) {
if (metricPoint.labelValues().equals(labels)) {
return metricPoint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ public static DistributionMetricSubject assertThat(@Nullable Metric<Distribution
return assertAbout(DistributionMetricSubject::new).that(metric);
}

private final Metric<Distribution> actual;

private DistributionMetricSubject(FailureMetadata metadata, Metric<Distribution> actual) {
super(metadata, actual);
this.actual = actual;
}

/**
Expand Down Expand Up @@ -111,7 +114,7 @@ protected String getMessageRepresentation(Distribution distribution) {
*/
public And<DistributionMetricSubject> hasDataSetForLabels(
ImmutableSet<? extends Number> dataSet, String... labels) {
ImmutableList<MetricPoint<Distribution>> metricPoints = actual().getTimestampedValues();
ImmutableList<MetricPoint<Distribution>> metricPoints = actual.getTimestampedValues();
if (metricPoints.isEmpty()) {
failWithBadResults(
"has a distribution for labels", Joiner.on(':').join(labels), "has", "no values");
Expand Down
2 changes: 1 addition & 1 deletion metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>0.37</version>
<version>0.44</version>
<scope>test</scope>
</dependency>
<!-- JUnit backport -->
Expand Down
2 changes: 1 addition & 1 deletion stackdriver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>0.37</version>
<version>0.44</version>
<scope>test</scope>
</dependency>
<!-- JUnit backport -->
Expand Down