-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests * Create master javadoc for all subprojects * Generate Javadocs to gh-pages * Provide credentials for Travis to update gh-pages * Only publish docs on merge to master * Better way to exclude checkstyle for generated sources * Throw exception instead of print stacktrace
- Loading branch information
Showing
23 changed files
with
1,678 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
# Generate coverage report | ||
./gradlew jacocoRootReport coveralls | ||
|
||
# Publish Javadoc | ||
if [ "$TRAVIS_JDK_VERSION" == "openjdk7" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then | ||
git checkout --orphan gh-pages | ||
git reset | ||
cp -r build/docs/javadoc/ docs | ||
git clean -fdxe /docs | ||
git add -A | ||
git commit -m "Update Javadoc" | ||
git push -f https://${GITHUB_TOKEN}@github.com/uber-java/tally.git gh-pages | ||
fi |
131 changes: 131 additions & 0 deletions
131
core/src/test/java/com/uber/m3/tally/BucketPairImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package com.uber.m3.tally; | ||
|
||
import com.uber.m3.util.Duration; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertArrayEquals; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class BucketPairImplTest { | ||
@Test | ||
public void bucketPairs() { | ||
BucketPair[] expectedPairs = new BucketPair[]{ | ||
new BucketPairImpl( | ||
-Double.MAX_VALUE, | ||
Double.MAX_VALUE, | ||
Duration.MIN_VALUE, | ||
Duration.MAX_VALUE | ||
) | ||
}; | ||
|
||
assertArrayEquals(expectedPairs, BucketPairImpl.bucketPairs(null)); | ||
|
||
expectedPairs = new BucketPair[]{ | ||
new BucketPairImpl( | ||
-Double.MAX_VALUE, | ||
0, | ||
Duration.MIN_VALUE, | ||
Duration.ZERO | ||
), | ||
new BucketPairImpl( | ||
0, | ||
50, | ||
Duration.ZERO, | ||
Duration.ofSeconds(50) | ||
), | ||
new BucketPairImpl( | ||
50, | ||
100, | ||
Duration.ofSeconds(50), | ||
Duration.ofSeconds(100) | ||
), | ||
new BucketPairImpl( | ||
100, | ||
Double.MAX_VALUE, | ||
Duration.ofSeconds(100), | ||
Duration.MAX_VALUE | ||
), | ||
}; | ||
|
||
assertArrayEquals( | ||
expectedPairs, | ||
BucketPairImpl.bucketPairs(ValueBuckets.linear(0, 50, 3)) | ||
); | ||
} | ||
|
||
@Test | ||
public void addZeroBucket() { | ||
BucketPair[] bucketPairs = BucketPairImpl.bucketPairs( | ||
DurationBuckets.linear(Duration.ofMillis(-30), Duration.ofMillis(20), 3) | ||
); | ||
|
||
assertEquals(5, bucketPairs.length); | ||
|
||
assertEquals(Duration.MIN_VALUE, bucketPairs[0].lowerBoundDuration()); | ||
assertEquals(Duration.ofMillis(-30), bucketPairs[0].upperBoundDuration()); | ||
|
||
assertEquals(Duration.ofMillis(-30), bucketPairs[1].lowerBoundDuration()); | ||
assertEquals(Duration.ofMillis(-10), bucketPairs[1].upperBoundDuration()); | ||
|
||
assertEquals(Duration.ofMillis(-10), bucketPairs[2].lowerBoundDuration()); | ||
assertEquals(Duration.ZERO, bucketPairs[2].upperBoundDuration()); | ||
|
||
assertEquals(Duration.ZERO, bucketPairs[3].lowerBoundDuration()); | ||
assertEquals(Duration.ofMillis(10), bucketPairs[3].upperBoundDuration()); | ||
|
||
assertEquals(Duration.ofMillis(10), bucketPairs[4].lowerBoundDuration()); | ||
assertEquals(Duration.MAX_VALUE, bucketPairs[4].upperBoundDuration()); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
BucketPair[] bucketPairs = BucketPairImpl.bucketPairs( | ||
ValueBuckets.linear(-100, 200, 2) | ||
); | ||
|
||
// Unlike Duration buckets, we don't add a 0 in the buckets | ||
assertEquals(3, bucketPairs.length); | ||
assertEquals("[-2562047h47m16.854775808s, -1m40s]", bucketPairs[0].toString()); | ||
assertEquals("[-1m40s, 1m40s]", bucketPairs[1].toString()); | ||
assertEquals("[1m40s, 2562047h47m16.854775807s]", bucketPairs[2].toString()); | ||
|
||
BucketPair[] emptyBucketPairs = BucketPairImpl.bucketPairs(null); | ||
assertEquals(1, emptyBucketPairs.length); | ||
assertEquals("[-2562047h47m16.854775808s, 2562047h47m16.854775807s]", emptyBucketPairs[0].toString()); | ||
} | ||
|
||
@Test | ||
public void equalsHashCode() { | ||
BucketPair bucketPair = BucketPairImpl.bucketPairs(null)[0]; | ||
BucketPair sameBucketPair = BucketPairImpl.bucketPairs(null)[0]; | ||
|
||
assertTrue(bucketPair.equals(sameBucketPair)); | ||
assertTrue(bucketPair.equals(bucketPair)); | ||
assertEquals(bucketPair.hashCode(), sameBucketPair.hashCode()); | ||
|
||
assertFalse(bucketPair.equals(null)); | ||
assertFalse(bucketPair.equals(9)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package com.uber.m3.tally; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
public class CapableOfTest { | ||
@Test | ||
public void capabilities() throws Exception { | ||
Capabilities capabilities = new CapableOf(false, true); | ||
|
||
assertFalse(capabilities.reporting()); | ||
assertTrue(capabilities.tagging()); | ||
|
||
assertTrue(CapableOf.REPORTING.reporting()); | ||
assertFalse(CapableOf.REPORTING.tagging()); | ||
|
||
assertFalse(CapableOf.NONE.reporting()); | ||
assertFalse(CapableOf.NONE.tagging()); | ||
|
||
assertTrue(CapableOf.REPORTING_TAGGING.reporting()); | ||
assertTrue(CapableOf.REPORTING_TAGGING.tagging()); | ||
} | ||
|
||
@Test | ||
public void equalsHashCode() throws Exception { | ||
assertFalse(CapableOf.NONE.equals(null)); | ||
assertFalse(CapableOf.NONE.equals(9)); | ||
|
||
assertFalse(CapableOf.NONE.equals(CapableOf.REPORTING)); | ||
assertFalse(new CapableOf(true, false).equals(new CapableOf(false, true))); | ||
|
||
assertTrue(CapableOf.REPORTING.equals(CapableOf.REPORTING)); | ||
assertTrue(CapableOf.REPORTING.equals(new CapableOf(true, false))); | ||
assertEquals(CapableOf.REPORTING.hashCode(), new CapableOf(true, false).hashCode()); | ||
assertTrue(new CapableOf(false, false).equals(new CapableOf(false, false))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.