diff options
author | Yang Song <songy23@users.noreply.github.com> | 2018-06-20 14:02:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 14:02:32 -0700 |
commit | 9b82dc5a4a717766e245dffaeae9573844605215 (patch) | |
tree | d00b94662fc4e39c15b6e534ba6ad6b34b6b2de3 /api/src/test/java/io | |
parent | d68f786fb0e9dc447bcc6a5eabb9cfcdffaced5d (diff) | |
download | opencensus-java-9b82dc5a4a717766e245dffaeae9573844605215.tar.gz |
Stats: Only include the simple class name in the error message for ViewData.check methods. (#1267)
* Stats: Only include the simple class name in the error message for ViewData.check methods.
* Copy checkArgument and lazily create error message.
* Rename help methods to avoid InconsistentOverloads.
* Improve error messages in the unit tests.
Diffstat (limited to 'api/src/test/java/io')
-rw-r--r-- | api/src/test/java/io/opencensus/stats/ViewDataTest.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/api/src/test/java/io/opencensus/stats/ViewDataTest.java b/api/src/test/java/io/opencensus/stats/ViewDataTest.java index 89009f34..0120ffea 100644 --- a/api/src/test/java/io/opencensus/stats/ViewDataTest.java +++ b/api/src/test/java/io/opencensus/stats/ViewDataTest.java @@ -160,12 +160,19 @@ public final class ViewDataTest { @Test public void preventWindowAndAggregationWindowDataMismatch() { + CumulativeData cumulativeData = + CumulativeData.create(Timestamp.fromMillis(1000), Timestamp.fromMillis(2000)); thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("AggregationWindow and AggregationWindowData types mismatch. "); + thrown.expectMessage( + "AggregationWindow and AggregationWindowData types mismatch. " + + "AggregationWindow: " + + INTERVAL_HOUR.getClass().getSimpleName() + + " AggregationWindowData: " + + cumulativeData.getClass().getSimpleName()); ViewData.create( View.create(NAME, DESCRIPTION, MEASURE_DOUBLE, DISTRIBUTION, TAG_KEYS, INTERVAL_HOUR), ENTRIES, - CumulativeData.create(Timestamp.fromMillis(1000), Timestamp.fromMillis(2000))); + cumulativeData); } @Test @@ -213,12 +220,7 @@ public final class ViewDataTest { @Test public void preventAggregationAndAggregationDataMismatch_Distribution_Count() { aggregationAndAggregationDataMismatch( - createView(DISTRIBUTION), - ImmutableMap.of( - Arrays.asList(V1, V2), - DistributionData.create(1, 1, 1, 1, 0, Arrays.asList(0L, 1L, 0L)), - Arrays.asList(V10, V20), - CountData.create(100))); + createView(DISTRIBUTION), ImmutableMap.of(Arrays.asList(V10, V20), CountData.create(100))); } @Test @@ -249,8 +251,15 @@ public final class ViewDataTest { View view, Map<List<TagValue>, ? extends AggregationData> entries) { CumulativeData cumulativeData = CumulativeData.create(Timestamp.fromMillis(1000), Timestamp.fromMillis(2000)); + Aggregation aggregation = view.getAggregation(); + AggregationData aggregationData = entries.values().iterator().next(); thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("Aggregation and AggregationData types mismatch. "); + thrown.expectMessage( + "Aggregation and AggregationData types mismatch. " + + "Aggregation: " + + aggregation.getClass().getSimpleName() + + " AggregationData: " + + aggregationData.getClass().getSimpleName()); ViewData.create(view, entries, cumulativeData); } |