mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 20:18:34 +02:00
Use backported JUnit exceptThrows and assertThrows in metrics library
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=176584707
This commit is contained in:
parent
6eb0d8689d
commit
a92cdbe8c3
17 changed files with 325 additions and 226 deletions
|
@ -15,13 +15,12 @@
|
|||
package google.registry.monitoring.metrics;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.monitoring.metrics.JUnitBackports.expectThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.joda.time.Instant;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
|
@ -29,9 +28,6 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class StoredMetricTest {
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testGetCardinality_reflectsCurrentCardinality() {
|
||||
StoredMetric<Boolean> smallMetric =
|
||||
|
@ -68,11 +64,12 @@ public class StoredMetricTest {
|
|||
LabelDescriptor.create("label1", "bar"), LabelDescriptor.create("label2", "bar")),
|
||||
Boolean.class);
|
||||
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"The count of labelValues must be equal to the underlying Metric's count of labels.");
|
||||
|
||||
dimensionalMetric.set(true, "foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> dimensionalMetric.set(true, "foo"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"The count of labelValues must be equal to the underlying Metric's count of labels.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue