diff --git a/java/google/registry/export/ExportConstants.java b/java/google/registry/export/ExportConstants.java index 22fbe430f..f813fffd1 100644 --- a/java/google/registry/export/ExportConstants.java +++ b/java/google/registry/export/ExportConstants.java @@ -18,66 +18,17 @@ import static com.google.common.base.Predicates.not; import static google.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION; import static google.registry.util.TypeUtils.hasAnnotation; -import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Ordering; import google.registry.model.EntityClasses; -import google.registry.model.ImmutableObject; import google.registry.model.annotations.NotBackedUp; +import google.registry.model.annotations.ReportedOn; import google.registry.model.annotations.VirtualEntity; -import google.registry.model.billing.BillingEvent.Cancellation; -import google.registry.model.billing.BillingEvent.Modification; -import google.registry.model.billing.BillingEvent.OneTime; -import google.registry.model.billing.BillingEvent.Recurring; -import google.registry.model.billing.RegistrarCredit; -import google.registry.model.billing.RegistrarCreditBalance; -import google.registry.model.contact.ContactResource; -import google.registry.model.domain.DomainBase; -import google.registry.model.domain.LrpTokenEntity; -import google.registry.model.host.HostResource; -import google.registry.model.index.DomainApplicationIndex; -import google.registry.model.index.EppResourceIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyContactIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyDomainIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex; -import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.RegistrarContact; -import google.registry.model.registry.Registry; -import google.registry.model.registry.label.PremiumList; -import google.registry.model.registry.label.PremiumList.PremiumListEntry; -import google.registry.model.reporting.HistoryEntry; /** Constants related to export code. */ public final class ExportConstants { - /** Set of entity classes to export into BigQuery for reporting purposes. */ - @VisibleForTesting - @SuppressWarnings("unchecked") // varargs - static final ImmutableSet> REPORTING_ENTITY_CLASSES = - ImmutableSet.of( - Cancellation.class, - ContactResource.class, - DomainApplicationIndex.class, - DomainBase.class, - EppResourceIndex.class, - ForeignKeyContactIndex.class, - ForeignKeyDomainIndex.class, - ForeignKeyHostIndex.class, - HistoryEntry.class, - HostResource.class, - LrpTokenEntity.class, - Modification.class, - OneTime.class, - PremiumList.class, - PremiumListEntry.class, - Recurring.class, - Registrar.class, - RegistrarContact.class, - RegistrarCredit.class, - RegistrarCreditBalance.class, - Registry.class); - /** Returns the names of kinds to include in datastore backups. */ public static ImmutableSet getBackupKinds() { // Back up all entity classes that aren't annotated with @VirtualEntity (never even persisted @@ -91,7 +42,9 @@ public final class ExportConstants { /** Returns the names of kinds to import into reporting tools (e.g. BigQuery). */ public static ImmutableSet getReportingKinds() { - return FluentIterable.from(REPORTING_ENTITY_CLASSES) + return FluentIterable.from(EntityClasses.ALL_CLASSES) + .filter(hasAnnotation(ReportedOn.class)) + .filter(not(hasAnnotation(VirtualEntity.class))) .transform(CLASS_TO_KIND_FUNCTION) .toSortedSet(Ordering.natural()); } diff --git a/java/google/registry/model/annotations/ReportedOn.java b/java/google/registry/model/annotations/ReportedOn.java new file mode 100644 index 000000000..379cf5462 --- /dev/null +++ b/java/google/registry/model/annotations/ReportedOn.java @@ -0,0 +1,28 @@ +// Copyright 2016 The Nomulus Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package google.registry.model.annotations; + +import com.googlecode.objectify.annotation.Entity; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation for an Objectify {@link Entity} to indicate that it should be exported to BigQuery. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface ReportedOn {} diff --git a/java/google/registry/model/billing/BillingEvent.java b/java/google/registry/model/billing/BillingEvent.java index cce7463ec..b6fd3dbb2 100644 --- a/java/google/registry/model/billing/BillingEvent.java +++ b/java/google/registry/model/billing/BillingEvent.java @@ -37,6 +37,7 @@ import com.googlecode.objectify.annotation.Parent; import com.googlecode.objectify.condition.IfNull; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; +import google.registry.model.annotations.ReportedOn; import google.registry.model.common.TimeOfYear; import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; @@ -198,6 +199,7 @@ public abstract class BillingEvent extends ImmutableObject } /** A one-time billable event. */ + @ReportedOn @Entity public static class OneTime extends BillingEvent { @@ -328,6 +330,7 @@ public abstract class BillingEvent extends ImmutableObject * recurring event might change and each time we bill for it we need to bill at the current cost, * not the value that was in use at the time the recurrence was created. */ + @ReportedOn @Entity public static class Recurring extends BillingEvent { @@ -400,6 +403,7 @@ public abstract class BillingEvent extends ImmutableObject *

This is implemented as a separate event rather than a bit on BillingEvent in order to * preserve the immutability of billing events. */ + @ReportedOn @Entity public static class Cancellation extends BillingEvent { @@ -510,6 +514,7 @@ public abstract class BillingEvent extends ImmutableObject /** * An event representing a modification of an existing one-time billing event. */ + @ReportedOn @Entity public static class Modification extends BillingEvent { diff --git a/java/google/registry/model/billing/RegistrarCredit.java b/java/google/registry/model/billing/RegistrarCredit.java index c05daf88b..275feabf6 100644 --- a/java/google/registry/model/billing/RegistrarCredit.java +++ b/java/google/registry/model/billing/RegistrarCredit.java @@ -31,12 +31,14 @@ import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Parent; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; +import google.registry.model.annotations.ReportedOn; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; import org.joda.money.CurrencyUnit; import org.joda.time.DateTime; /** A per-registrar billing credit, applied toward future charges for registrar activity. */ +@ReportedOn @Entity public final class RegistrarCredit extends ImmutableObject implements Buildable { diff --git a/java/google/registry/model/billing/RegistrarCreditBalance.java b/java/google/registry/model/billing/RegistrarCreditBalance.java index 50621dd72..2902b243d 100644 --- a/java/google/registry/model/billing/RegistrarCreditBalance.java +++ b/java/google/registry/model/billing/RegistrarCreditBalance.java @@ -32,6 +32,7 @@ import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Parent; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; +import google.registry.model.annotations.ReportedOn; import java.util.HashMap; import java.util.Map; import org.joda.money.CurrencyUnit; @@ -49,6 +50,7 @@ import org.joda.time.DateTime; * taking the balance object with the latest effective time that is before (before or at) T, and * breaking any ties by choosing the mostly recently written among those balances. */ +@ReportedOn @Entity public final class RegistrarCreditBalance extends ImmutableObject implements Buildable { diff --git a/java/google/registry/model/contact/ContactResource.java b/java/google/registry/model/contact/ContactResource.java index 2d73eb8cf..735ffe87e 100644 --- a/java/google/registry/model/contact/ContactResource.java +++ b/java/google/registry/model/contact/ContactResource.java @@ -31,6 +31,7 @@ import google.registry.model.EppResource; import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.annotations.ExternalMessagingName; +import google.registry.model.annotations.ReportedOn; import google.registry.model.contact.PostalInfo.Type; import google.registry.model.transfer.TransferData; import java.util.List; @@ -65,6 +66,7 @@ import org.joda.time.DateTime; "authInfo", "disclose" }) @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) +@ReportedOn @Entity @ExternalMessagingName("contact") public class ContactResource extends EppResource diff --git a/java/google/registry/model/domain/DomainBase.java b/java/google/registry/model/domain/DomainBase.java index fb54c7449..41a54252d 100644 --- a/java/google/registry/model/domain/DomainBase.java +++ b/java/google/registry/model/domain/DomainBase.java @@ -42,6 +42,7 @@ import com.googlecode.objectify.annotation.IgnoreSave; import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.condition.IfNull; import google.registry.model.EppResource; +import google.registry.model.annotations.ReportedOn; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.launch.LaunchNotice; @@ -54,6 +55,7 @@ import javax.xml.bind.annotation.XmlTransient; /** Shared base class for {@link DomainResource} and {@link DomainApplication}. */ @XmlTransient +@ReportedOn @Entity public abstract class DomainBase extends EppResource { diff --git a/java/google/registry/model/domain/LrpTokenEntity.java b/java/google/registry/model/domain/LrpTokenEntity.java index 37a9600ba..a8f5cc3d3 100644 --- a/java/google/registry/model/domain/LrpTokenEntity.java +++ b/java/google/registry/model/domain/LrpTokenEntity.java @@ -24,11 +24,13 @@ import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Index; import google.registry.model.BackupGroupRoot; import google.registry.model.Buildable; +import google.registry.model.annotations.ReportedOn; import google.registry.model.reporting.HistoryEntry; import java.util.Map; import java.util.Set; /** An entity representing a token distributed to eligible LRP registrants. */ +@ReportedOn @Entity public class LrpTokenEntity extends BackupGroupRoot implements Buildable { diff --git a/java/google/registry/model/host/HostResource.java b/java/google/registry/model/host/HostResource.java index 167b0d3de..ffdb964b6 100644 --- a/java/google/registry/model/host/HostResource.java +++ b/java/google/registry/model/host/HostResource.java @@ -32,6 +32,7 @@ import com.googlecode.objectify.condition.IfNull; import google.registry.model.EppResource; import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.annotations.ExternalMessagingName; +import google.registry.model.annotations.ReportedOn; import google.registry.model.domain.DomainResource; import google.registry.model.eppcommon.StatusValue; import google.registry.model.transfer.TransferData; @@ -65,6 +66,7 @@ import org.joda.time.DateTime; "lastEppUpdateTime", "lastTransferTime" }) @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) +@ReportedOn @Entity @ExternalMessagingName("host") public class HostResource extends EppResource implements ForeignKeyedEppResource { diff --git a/java/google/registry/model/index/DomainApplicationIndex.java b/java/google/registry/model/index/DomainApplicationIndex.java index 159962b64..ead93a999 100644 --- a/java/google/registry/model/index/DomainApplicationIndex.java +++ b/java/google/registry/model/index/DomainApplicationIndex.java @@ -27,6 +27,7 @@ import com.googlecode.objectify.annotation.Cache; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; import google.registry.model.BackupGroupRoot; +import google.registry.model.annotations.ReportedOn; import google.registry.model.domain.DomainApplication; import google.registry.util.CollectionUtils; import java.util.Set; @@ -38,6 +39,7 @@ import org.joda.time.DateTime; * resource is always kept up to date as additional domain applications are created, it is never * necessary to query them explicitly from Datastore. */ +@ReportedOn @Entity @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) public class DomainApplicationIndex extends BackupGroupRoot { diff --git a/java/google/registry/model/index/EppResourceIndex.java b/java/google/registry/model/index/EppResourceIndex.java index 2f2771d42..9ed386a8c 100644 --- a/java/google/registry/model/index/EppResourceIndex.java +++ b/java/google/registry/model/index/EppResourceIndex.java @@ -24,8 +24,10 @@ import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.annotation.Parent; import google.registry.model.BackupGroupRoot; import google.registry.model.EppResource; +import google.registry.model.annotations.ReportedOn; /** An index that allows for quick enumeration of all EppResource entities (e.g. via map reduce). */ +@ReportedOn @Entity public class EppResourceIndex extends BackupGroupRoot { diff --git a/java/google/registry/model/index/ForeignKeyIndex.java b/java/google/registry/model/index/ForeignKeyIndex.java index d5c637080..33d03c009 100644 --- a/java/google/registry/model/index/ForeignKeyIndex.java +++ b/java/google/registry/model/index/ForeignKeyIndex.java @@ -29,6 +29,7 @@ import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Index; import google.registry.model.BackupGroupRoot; import google.registry.model.EppResource; +import google.registry.model.annotations.ReportedOn; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainResource; import google.registry.model.host.HostResource; @@ -45,16 +46,19 @@ public abstract class ForeignKeyIndex extends BackupGroup /** The {@link ForeignKeyIndex} type for {@link ContactResource} entities. */ @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) + @ReportedOn @Entity public static class ForeignKeyContactIndex extends ForeignKeyIndex {} /** The {@link ForeignKeyIndex} type for {@link DomainResource} entities. */ @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) + @ReportedOn @Entity public static class ForeignKeyDomainIndex extends ForeignKeyIndex {} /** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */ @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) + @ReportedOn @Entity public static class ForeignKeyHostIndex extends ForeignKeyIndex {} diff --git a/java/google/registry/model/registrar/Registrar.java b/java/google/registry/model/registrar/Registrar.java index b534694d9..f9c446070 100644 --- a/java/google/registry/model/registrar/Registrar.java +++ b/java/google/registry/model/registrar/Registrar.java @@ -59,6 +59,7 @@ import google.registry.model.ImmutableObject; import google.registry.model.JsonMapBuilder; import google.registry.model.Jsonifiable; import google.registry.model.UpdateAutoTimestamp; +import google.registry.model.annotations.ReportedOn; import google.registry.model.common.EntityGroupRoot; import google.registry.util.CidrAddressBlock; import google.registry.util.NonFinalForTesting; @@ -76,6 +77,7 @@ import org.joda.time.DateTime; /** Information about a registrar. */ @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) +@ReportedOn @Entity public class Registrar extends ImmutableObject implements Buildable, Jsonifiable { diff --git a/java/google/registry/model/registrar/RegistrarContact.java b/java/google/registry/model/registrar/RegistrarContact.java index 026e00a0e..82cd7305e 100644 --- a/java/google/registry/model/registrar/RegistrarContact.java +++ b/java/google/registry/model/registrar/RegistrarContact.java @@ -39,6 +39,7 @@ import google.registry.model.Buildable; import google.registry.model.ImmutableObject; import google.registry.model.JsonMapBuilder; import google.registry.model.Jsonifiable; +import google.registry.model.annotations.ReportedOn; import java.util.Arrays; import java.util.Map; import java.util.Set; @@ -52,6 +53,7 @@ import java.util.Set; * set to true. */ @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) +@ReportedOn @Entity public class RegistrarContact extends ImmutableObject implements Jsonifiable { diff --git a/java/google/registry/model/registry/Registry.java b/java/google/registry/model/registry/Registry.java index 88f17bcfa..548deca10 100644 --- a/java/google/registry/model/registry/Registry.java +++ b/java/google/registry/model/registry/Registry.java @@ -53,6 +53,7 @@ import google.registry.config.RegistryEnvironment; import google.registry.model.Buildable; import google.registry.model.CreateAutoTimestamp; import google.registry.model.ImmutableObject; +import google.registry.model.annotations.ReportedOn; import google.registry.model.common.EntityGroupRoot; import google.registry.model.common.TimedTransitionProperty; import google.registry.model.common.TimedTransitionProperty.TimedTransition; @@ -71,6 +72,7 @@ import org.joda.time.Interval; /** Persisted per-TLD configuration data. */ @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) +@ReportedOn @Entity public class Registry extends ImmutableObject implements Buildable { diff --git a/java/google/registry/model/registry/label/PremiumList.java b/java/google/registry/model/registry/label/PremiumList.java index 3fb47bdaa..a3647739c 100644 --- a/java/google/registry/model/registry/label/PremiumList.java +++ b/java/google/registry/model/registry/label/PremiumList.java @@ -51,6 +51,7 @@ import com.googlecode.objectify.cmd.Query; import google.registry.config.RegistryEnvironment; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; +import google.registry.model.annotations.ReportedOn; import google.registry.model.annotations.VirtualEntity; import google.registry.model.registry.Registry; import java.util.List; @@ -64,6 +65,7 @@ import org.joda.time.DateTime; /** * A premium list entity, persisted to Datastore, that is used to check domain label prices. */ +@ReportedOn @Entity @Cache(expirationSeconds = RECOMMENDED_MEMCACHE_EXPIRATION) public final class PremiumList extends BaseDomainLabelList { @@ -192,6 +194,7 @@ public final class PremiumList extends BaseDomainLabelList diff --git a/java/google/registry/model/reporting/HistoryEntry.java b/java/google/registry/model/reporting/HistoryEntry.java index 05dba91f0..6f0b10f5a 100644 --- a/java/google/registry/model/reporting/HistoryEntry.java +++ b/java/google/registry/model/reporting/HistoryEntry.java @@ -24,11 +24,13 @@ import com.googlecode.objectify.condition.IfNull; import google.registry.model.Buildable; import google.registry.model.EppResource; import google.registry.model.ImmutableObject; +import google.registry.model.annotations.ReportedOn; import google.registry.model.domain.Period; import google.registry.model.eppcommon.Trid; import org.joda.time.DateTime; /** A record of an EPP command that mutated a resource. */ +@ReportedOn @Entity public class HistoryEntry extends ImmutableObject implements Buildable { diff --git a/javatests/google/registry/export/BUILD b/javatests/google/registry/export/BUILD index e65774f7a..44fdd168c 100644 --- a/javatests/google/registry/export/BUILD +++ b/javatests/google/registry/export/BUILD @@ -12,6 +12,7 @@ java_library( srcs = glob(["*.java"]), resources = glob([ "backup_kinds.txt", + "reporting_kinds.txt", ]), deps = [ "//apiserving/discoverydata/bigquery:bigqueryv2", diff --git a/javatests/google/registry/export/ExportConstantsTest.java b/javatests/google/registry/export/ExportConstantsTest.java index 1c05c138f..701653e07 100644 --- a/javatests/google/registry/export/ExportConstantsTest.java +++ b/javatests/google/registry/export/ExportConstantsTest.java @@ -17,17 +17,15 @@ package google.registry.export; import static com.google.common.io.Resources.getResource; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import static java.nio.charset.StandardCharsets.UTF_8; +import static google.registry.util.ResourceUtils.readResourceUtf8; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.io.Resources; import com.google.re2j.Pattern; -import com.googlecode.objectify.annotation.Entity; -import google.registry.model.ImmutableObject; import java.net.URL; import java.util.List; import javax.annotation.Nullable; @@ -41,10 +39,12 @@ public class ExportConstantsTest { private static final String GOLDEN_BACKUP_KINDS_FILENAME = "backup_kinds.txt"; + private static final String GOLDEN_REPORTING_KINDS_FILENAME = "reporting_kinds.txt"; + private static final String UPDATE_INSTRUCTIONS_TEMPLATE = Joiner.on('\n').join( "", "---------------------------------------------------------------------------------", - "Your changes affect the list of backed-up kinds in the golden file:", + "Your changes affect the list of %s kinds in the golden file:", " %s", "If these changes are desired, update the golden file with the following contents:", "=================================================================================", @@ -56,38 +56,67 @@ public class ExportConstantsTest { public void testBackupKinds_matchGoldenBackupKindsFile() throws Exception { URL goldenBackupKindsResource = getResource(ExportConstantsTest.class, GOLDEN_BACKUP_KINDS_FILENAME); - final Pattern stripComments = Pattern.compile("\\s*#.*$"); - List goldenKinds = FluentIterable - .from(Splitter.on('\n').split( - Resources.toString(goldenBackupKindsResource, UTF_8).trim())) - .transform( - new Function() { - @Override @Nullable public String apply(@Nullable String line) { - return stripComments.matcher(line).replaceFirst(""); - }}) - .toList(); + List goldenKinds = extractListFromFile(GOLDEN_BACKUP_KINDS_FILENAME); ImmutableSet actualKinds = ExportConstants.getBackupKinds(); - String updateInstructions = String.format( - UPDATE_INSTRUCTIONS_TEMPLATE, - goldenBackupKindsResource.toString(), - Joiner.on('\n').join(actualKinds)); + String updateInstructions = + getUpdateInstructions("backed-up", goldenBackupKindsResource.toString(), actualKinds); assertWithMessage(updateInstructions) .that(actualKinds) .containsExactlyElementsIn(goldenKinds) .inOrder(); } + @Test + public void testReportingKinds_matchGoldenReportingKindsFile() throws Exception { + URL goldenReportingKindsResource = + getResource(ExportConstantsTest.class, GOLDEN_REPORTING_KINDS_FILENAME); + List goldenReportingKinds = extractListFromFile(GOLDEN_REPORTING_KINDS_FILENAME); + ImmutableSet actualKinds = ExportConstants.getReportingKinds(); + String updateInstructions = + getUpdateInstructions("reporting", goldenReportingKindsResource.toString(), actualKinds); + assertWithMessage(updateInstructions) + .that(actualKinds) + .containsExactlyElementsIn(goldenReportingKinds) + .inOrder(); + } + @Test public void testReportingKinds_areSubsetOfBackupKinds() throws Exception { assertThat(ExportConstants.getBackupKinds()).containsAllIn(ExportConstants.getReportingKinds()); } - @Test - public void testReportingEntityClasses_areAllBaseEntityClasses() throws Exception { - for (Class clazz : ExportConstants.REPORTING_ENTITY_CLASSES) { - assertThat(clazz.isAnnotationPresent(Entity.class)) - .named(String.format("class %s is an @Entity", clazz.getSimpleName())) - .isTrue(); - } + /** + * Helper method to get update instructions + * + * @param name - type of entity + * @param resource - Resource file contents + * @param actualKinds - data from ExportConstants + * @return String of update instructions + */ + private static String getUpdateInstructions( + String name, String resource, ImmutableSet actualKinds) { + return String.format( + UPDATE_INSTRUCTIONS_TEMPLATE, name, resource, Joiner.on('\n').join(actualKinds)); + } + + /** + * Helper method to extract list from file + * + * @param filename + * @return ImmutableList + */ + private static ImmutableList extractListFromFile(String filename) { + String fileContents = readResourceUtf8(ExportConstantsTest.class, filename); + final Pattern stripComments = Pattern.compile("\\s*#.*$"); + return FluentIterable.from(Splitter.on('\n').split(fileContents.trim())) + .transform( + new Function() { + @Override + @Nullable + public String apply(@Nullable String line) { + return stripComments.matcher(line).replaceFirst(""); + } + }) + .toList(); } } diff --git a/javatests/google/registry/export/reporting_kinds.txt b/javatests/google/registry/export/reporting_kinds.txt new file mode 100644 index 000000000..354e30de6 --- /dev/null +++ b/javatests/google/registry/export/reporting_kinds.txt @@ -0,0 +1,21 @@ +Cancellation +ContactResource +DomainApplicationIndex +DomainBase +EppResourceIndex +ForeignKeyContactIndex +ForeignKeyDomainIndex +ForeignKeyHostIndex +HistoryEntry +HostResource +LrpTokenEntity +Modification +OneTime +PremiumList +PremiumListEntry +Recurring +Registrar +RegistrarContact +RegistrarCredit +RegistrarCreditBalance +Registry