Add a convenient method to DistributionMetricSubject

Currently to assert that a given Metric<Distribution> as a certain distribution for some labels, the caller needs to manually create an ImmutableDistribution and pass it to #hasValueForLabels method. With this change, an ImmutableSet of data points can be passed to #hasDataSetForLabels method.

Also switched to use expectThrow backport from JUnit 4.13.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173544521
This commit is contained in:
jianglai 2017-10-26 09:01:26 -07:00
parent 4a9b8b918a
commit 4a5b9fc288
4 changed files with 135 additions and 38 deletions

View file

@ -107,7 +107,7 @@ abstract class AbstractMetricSubject<T, S extends AbstractMetricSubject<T, S>>
}
if (!metricPoint.value().equals(value)) {
failWithBadResults(
String.format("has a value of %s for labels", value),
String.format("has a value of %s for labels", getMessageRepresentation(value)),
Joiner.on(':').join(labels),
"has a value of",
getMessageRepresentation(metricPoint.value()));