mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
Consolidate the domain_renew_fee xml test files
Moving some of the info into the java test file itself makes it more easily readable. Maybe. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=240148747
This commit is contained in:
parent
c25486ec32
commit
625181ee3d
6 changed files with 50 additions and 70 deletions
|
@ -14,6 +14,9 @@
|
|||
|
||||
package google.registry.testing;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Maps.newHashMap;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.ResourceUtils.readResourceBytes;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
|
@ -51,6 +54,24 @@ public final class TestDataHelper {
|
|||
private static final Map<FileKey, String> fileCache = new ConcurrentHashMap<>();
|
||||
private static final Map<FileKey, ByteSource> byteCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Returns a copy of the given substitution map, updated with the new keys and values.
|
||||
*
|
||||
* <p>If an existing key is given, its value will be overridden with the new value.
|
||||
*/
|
||||
public static ImmutableMap<String, String> updateSubstitutions(
|
||||
@Nullable Map<String, String> baseSubstitutions, String... keysAndValues) {
|
||||
checkArgument(
|
||||
keysAndValues.length % 2 == 0,
|
||||
"keysAndValues must have even number of parameters, but has %s",
|
||||
keysAndValues.length);
|
||||
Map<String, String> newSubstitutions = newHashMap(nullToEmpty(baseSubstitutions));
|
||||
for (int i = 0; i < keysAndValues.length; i += 2) {
|
||||
newSubstitutions.put(checkNotNull(keysAndValues[i]), checkNotNull(keysAndValues[i + 1]));
|
||||
}
|
||||
return ImmutableMap.copyOf(newSubstitutions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a text file from the "testdata" directory relative to the location of the specified
|
||||
* context class.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue