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:
guyben 2019-03-25 08:57:48 -07:00 committed by jianglai
parent c25486ec32
commit 625181ee3d
6 changed files with 50 additions and 70 deletions

View file

@ -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.