diff options
author | sebright <sebright@google.com> | 2017-10-26 09:18:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-26 09:18:03 -0700 |
commit | afe29b3142c0dde8e2b5fc5a0f509dd4ba7c529b (patch) | |
tree | bfe7d696b7178cce7cf70e2b5939e5bab86225ea /api/src/test/java/io/opencensus/stats | |
parent | 5caa0a4293454c457642f4258a6581308cba2738 (diff) | |
parent | 60cefdd2301263f16766298f7a3048ba7e9a5853 (diff) | |
download | opencensus-java-afe29b3142c0dde8e2b5fc5a0f509dd4ba7c529b.tar.gz |
Merge pull request #721 from sebright/histogram-buckets
Make DistributionData.create take a List instead of a long[] for bucket counts.
Diffstat (limited to 'api/src/test/java/io/opencensus/stats')
-rw-r--r-- | api/src/test/java/io/opencensus/stats/AggregationDataTest.java | 31 | ||||
-rw-r--r-- | api/src/test/java/io/opencensus/stats/ViewDataTest.java | 4 |
2 files changed, 21 insertions, 14 deletions
diff --git a/api/src/test/java/io/opencensus/stats/AggregationDataTest.java b/api/src/test/java/io/opencensus/stats/AggregationDataTest.java index 3eafd18e..d4403c93 100644 --- a/api/src/test/java/io/opencensus/stats/AggregationDataTest.java +++ b/api/src/test/java/io/opencensus/stats/AggregationDataTest.java @@ -47,7 +47,7 @@ public class AggregationDataTest { @Test public void testCreateDistributionData() { DistributionData distributionData = DistributionData.create( - 7.7, 10, 1.1, 9.9, 32.2, new long[]{4, 1, 5}); + 7.7, 10, 1.1, 9.9, 32.2, Arrays.asList(4L, 1L, 5L)); assertThat(distributionData.getMean()).isWithin(TOLERANCE).of(7.7); assertThat(distributionData.getCount()).isEqualTo(10); assertThat(distributionData.getMin()).isWithin(TOLERANCE).of(1.1); @@ -57,17 +57,24 @@ public class AggregationDataTest { } @Test - public void preventNullBucketCountData() { + public void preventNullBucketCountList() { thrown.expect(NullPointerException.class); thrown.expectMessage("bucket counts should not be null."); DistributionData.create(1, 1, 1, 1, 0, null); } @Test + public void preventNullBucket() { + thrown.expect(NullPointerException.class); + thrown.expectMessage("bucket should not be null."); + DistributionData.create(1, 1, 1, 1, 0, Arrays.asList(0L, 1L, null)); + } + + @Test public void preventMinIsGreaterThanMax() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("max should be greater or equal to min."); - DistributionData.create(1, 1, 10, 1, 0, new long[]{0, 1, 0}); + DistributionData.create(1, 1, 10, 1, 0, Arrays.asList(0L, 1L, 0L)); } @Test @@ -89,20 +96,20 @@ public class AggregationDataTest { CountData.create(80), CountData.create(80)) .addEqualityGroup( - DistributionData.create(10, 10, 1, 1, 0, new long[]{0, 10, 0}), - DistributionData.create(10, 10, 1, 1, 0, new long[]{0, 10, 0})) + DistributionData.create(10, 10, 1, 1, 0, Arrays.asList(0L, 10L, 0L)), + DistributionData.create(10, 10, 1, 1, 0, Arrays.asList(0L, 10L, 0L))) .addEqualityGroup( - DistributionData.create(10, 10, 1, 1, 0, new long[]{0, 10, 100})) + DistributionData.create(10, 10, 1, 1, 0, Arrays.asList(0L, 10L, 100L))) .addEqualityGroup( - DistributionData.create(110, 10, 1, 1, 0, new long[]{0, 10, 0})) + DistributionData.create(110, 10, 1, 1, 0, Arrays.asList(0L, 10L, 0L))) .addEqualityGroup( - DistributionData.create(10, 110, 1, 1, 0, new long[]{0, 10, 0})) + DistributionData.create(10, 110, 1, 1, 0, Arrays.asList(0L, 10L, 0L))) .addEqualityGroup( - DistributionData.create(10, 10, -1, 1, 0, new long[]{0, 10, 0})) + DistributionData.create(10, 10, -1, 1, 0, Arrays.asList(0L, 10L, 0L))) .addEqualityGroup( - DistributionData.create(10, 10, 1, 5, 0, new long[]{0, 10, 0})) + DistributionData.create(10, 10, 1, 5, 0, Arrays.asList(0L, 10L, 0L))) .addEqualityGroup( - DistributionData.create(10, 10, 1, 1, 55.5, new long[]{0, 10, 0})) + DistributionData.create(10, 10, 1, 1, 55.5, Arrays.asList(0L, 10L, 0L))) .addEqualityGroup( MeanData.create(5.0, 1), MeanData.create(5.0, 1)) @@ -119,7 +126,7 @@ public class AggregationDataTest { SumDataLong.create(100000000), CountData.create(40), MeanData.create(5.0, 1), - DistributionData.create(1, 1, 1, 1, 0, new long[]{0, 10, 0})); + DistributionData.create(1, 1, 1, 1, 0, Arrays.asList(0L, 10L, 0L))); final List<Object> actual = new ArrayList<Object>(); for (AggregationData aggregation : aggregations) { diff --git a/api/src/test/java/io/opencensus/stats/ViewDataTest.java b/api/src/test/java/io/opencensus/stats/ViewDataTest.java index 69313295..285921db 100644 --- a/api/src/test/java/io/opencensus/stats/ViewDataTest.java +++ b/api/src/test/java/io/opencensus/stats/ViewDataTest.java @@ -204,9 +204,9 @@ public final class ViewDataTest { private static final ImmutableMap<List<TagValue>, DistributionData> ENTRIES = ImmutableMap.of( Arrays.asList(V1, V2), - DistributionData.create(1, 1, 1, 1, 0, new long[]{0, 1, 0}), + DistributionData.create(1, 1, 1, 1, 0, Arrays.asList(0L, 1L, 0L)), Arrays.asList(V10, V20), - DistributionData.create(-5, 6, -20, 5, 100.1, new long[]{5, 0, 1})); + DistributionData.create(-5, 6, -20, 5, 100.1, Arrays.asList(5L, 0L, 1L))); // name private static final View.Name NAME = View.Name.create("test-view"); |