forked from awslabs/aws-embedded-metrics-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'awslabs:master' into fix-awslabs#99
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ allprojects { | |
targetCompatibility = '1.8' | ||
} | ||
|
||
version = '2.0.0-beta-1' | ||
version = '3.0.0' | ||
} | ||
|
||
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
33 changes: 33 additions & 0 deletions
33
...main/java/software/amazon/cloudwatchlogs/emf/exception/DimensionSetExceededException.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,33 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package software.amazon.cloudwatchlogs.emf.exception; | ||
|
||
import software.amazon.cloudwatchlogs.emf.Constants; | ||
|
||
public class DimensionSetExceededException extends RuntimeException { | ||
|
||
public DimensionSetExceededException() { | ||
super( | ||
"Maximum number of dimensions allowed are " | ||
+ Constants.MAX_DIMENSION_SET_SIZE | ||
+ ". Account for default dimensions if not using setDimensions."); | ||
} | ||
|
||
public DimensionSetExceededException(String message) { | ||
super(message); | ||
} | ||
} |
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
77 changes: 77 additions & 0 deletions
77
src/test/java/software/amazon/cloudwatchlogs/emf/model/DimensionSetTest.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,77 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package software.amazon.cloudwatchlogs.emf.model; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
import software.amazon.cloudwatchlogs.emf.exception.DimensionSetExceededException; | ||
|
||
public class DimensionSetTest { | ||
@Test | ||
public void testAddDimension() { | ||
int dimensionsToBeAdded = 30; | ||
DimensionSet dimensionSet = generateDimensionSet(dimensionsToBeAdded); | ||
|
||
assertEquals(dimensionsToBeAdded, dimensionSet.getDimensionKeys().size()); | ||
} | ||
|
||
@Test | ||
public void testAddDimensionLimitExceeded() { | ||
Exception exception = | ||
assertThrows( | ||
DimensionSetExceededException.class, | ||
() -> { | ||
int dimensionSetSize = 33; | ||
generateDimensionSet(dimensionSetSize); | ||
}); | ||
|
||
String expectedMessage = "Maximum number of dimensions"; | ||
String actualMessage = exception.getMessage(); | ||
|
||
assertTrue(actualMessage.contains(expectedMessage)); | ||
} | ||
|
||
@Test | ||
public void testMergeDimensionSets() { | ||
Exception exception = | ||
assertThrows( | ||
DimensionSetExceededException.class, | ||
() -> { | ||
int dimensionSetSize = 28; | ||
int otherDimensionSetSize = 5; | ||
DimensionSet dimensionSet = generateDimensionSet(dimensionSetSize); | ||
DimensionSet otherDimensionSet = | ||
generateDimensionSet(otherDimensionSetSize); | ||
dimensionSet.add(otherDimensionSet); | ||
}); | ||
String expectedMessage = "Maximum number of dimensions"; | ||
String actualMessage = exception.getMessage(); | ||
|
||
assertTrue(actualMessage.contains(expectedMessage)); | ||
} | ||
|
||
private DimensionSet generateDimensionSet(int numOfDimensions) { | ||
DimensionSet dimensionSet = new DimensionSet(); | ||
|
||
for (int i = 0; i < numOfDimensions; i++) { | ||
dimensionSet.addDimension("Dimension" + i, "value" + i); | ||
} | ||
|
||
return dimensionSet; | ||
} | ||
} |