mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
Factor out labelValue length check to abstract base class and small name fix
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131902964
This commit is contained in:
parent
a0f1a8b0bc
commit
c11ac3129f
7 changed files with 80 additions and 42 deletions
|
@ -20,14 +20,18 @@ import static org.junit.Assert.fail;
|
|||
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.mockito.runners.MockitoJUnitRunner;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link Counter}. */
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@RunWith(JUnit4.class)
|
||||
public class CounterTest {
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testGetCardinality_reflectsCurrentCardinality() {
|
||||
Counter counter =
|
||||
|
@ -56,11 +60,11 @@ public class CounterTest {
|
|||
ImmutableSet.of(
|
||||
LabelDescriptor.create("label1", "bar"), LabelDescriptor.create("label2", "bar")));
|
||||
|
||||
try {
|
||||
counter.increment("blah");
|
||||
fail("expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
}
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"The count of labelValues must be equal to the underlying Metric's count of labels.");
|
||||
|
||||
counter.increment("blah");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue