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,35 +15,31 @@
|
|||
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.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Tests for {@link CustomFitter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class CustomFitterTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testCreateCustomFitter_emptyBounds_throwsException() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("boundaries must not be empty");
|
||||
|
||||
CustomFitter.create(ImmutableSet.<Double>of());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class, () -> CustomFitter.create(ImmutableSet.<Double>of()));
|
||||
assertThat(thrown).hasMessageThat().contains("boundaries must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCustomFitter_outOfOrderBounds_throwsException() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("boundaries must be sorted");
|
||||
|
||||
CustomFitter.create(ImmutableSet.of(2.0, 0.0));
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class, () -> CustomFitter.create(ImmutableSet.of(2.0, 0.0)));
|
||||
assertThat(thrown).hasMessageThat().contains("boundaries must be sorted");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue