mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 02:36:03 +02:00
Don't allow duplicates in premium/reserved lists
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148458642
This commit is contained in:
parent
ea3a8dfa9d
commit
dd400f30f5
6 changed files with 52 additions and 14 deletions
|
@ -273,6 +273,18 @@ public class PremiumListTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_cannotIncludeDuplicateLabels() {
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
"List 'tld' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
|
||||
PremiumList.get("tld")
|
||||
.get()
|
||||
.parse(
|
||||
ImmutableList.of(
|
||||
"lol,USD 100", "rofl,USD 90", "paper,USD 80", "wood,USD 70", "lol,USD 200"));
|
||||
}
|
||||
|
||||
/** Persists a premium list with a specified number of nonsense entries. */
|
||||
private PremiumList persistHumongousPremiumList(String name, int size) {
|
||||
String[] entries = new String[size];
|
||||
|
|
|
@ -291,6 +291,21 @@ public class ReservedListTest {
|
|||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParse_cannotIncludeDuplicateLabels() {
|
||||
ReservedList rl = new ReservedList.Builder().setName("blah").build();
|
||||
thrown.expect(
|
||||
IllegalStateException.class,
|
||||
"List 'blah' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
|
||||
rl.parse(
|
||||
ImmutableList.of(
|
||||
"lol,FULLY_BLOCKED",
|
||||
"rofl,FULLY_BLOCKED",
|
||||
"paper,FULLY_BLOCKED",
|
||||
"wood,FULLY_BLOCKED",
|
||||
"lol,FULLY_BLOCKED"));
|
||||
}
|
||||
|
||||
/** Gets the name of a reserved list. */
|
||||
public static final Function<Key<ReservedList>, String> GET_NAME_FUNCTION =
|
||||
new Function<Key<ReservedList>, String>() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue