mirror of
https://github.com/google/nomulus.git
synced 2025-07-20 09:46:03 +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,6 +15,7 @@
|
|||
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.ImmutableRangeMap;
|
||||
|
@ -22,9 +23,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Range;
|
||||
import org.joda.time.Instant;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
|
@ -34,9 +33,6 @@ public class EventMetricTest {
|
|||
|
||||
private final DistributionFitter distributionFitter = CustomFitter.create(ImmutableSet.of(5.0));
|
||||
private EventMetric metric;
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
metric =
|
||||
|
@ -67,11 +63,12 @@ public class EventMetricTest {
|
|||
|
||||
@Test
|
||||
public void testIncrementBy_wrongLabelValueCount_throwsException() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"The count of labelValues must be equal to the underlying Metric's count of labels.");
|
||||
|
||||
metric.record(1.0, "blah", "blah");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> metric.record(1.0, "blah", "blah"));
|
||||
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