mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Refactor ICANN reporting and billing into common package
This moves the default yearMonth logic into a common ReportingModule, rather than the coarse-scoped BackendModule, which may not want the default parameter extraction logic, as well as moving the 'yearMonth' parameter constant to the common package it's used in. This also provides a basis for future consolidation of the ReportingEmailUtils and BillingEmailUtils classes, which have modest overlap. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183130311
This commit is contained in:
parent
9d532cb507
commit
74ced1e907
71 changed files with 233 additions and 142 deletions
|
@ -9,8 +9,8 @@ java_library(
|
|||
srcs = glob(["*.java"]),
|
||||
resources = glob(["sql/*"]),
|
||||
deps = [
|
||||
"//java/google/registry/billing",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/reporting/billing",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_apis_google_api_services_bigquery",
|
||||
"@com_google_auto_value",
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.google.auto.value.AutoValue;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.billing.BillingModule;
|
||||
import google.registry.reporting.billing.BillingModule;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
|
@ -16,8 +16,9 @@ package google.registry.beam;
|
|||
|
||||
import google.registry.beam.BillingEvent.InvoiceGroupingKey;
|
||||
import google.registry.beam.BillingEvent.InvoiceGroupingKey.InvoiceGroupingKeyCoder;
|
||||
import google.registry.billing.BillingModule;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.reporting.billing.BillingModule;
|
||||
import google.registry.reporting.billing.GenerateInvoicesAction;
|
||||
import java.io.Serializable;
|
||||
import javax.inject.Inject;
|
||||
import org.apache.beam.runners.dataflow.DataflowRunner;
|
||||
|
@ -47,8 +48,7 @@ import org.apache.beam.sdk.values.TypeDescriptors;
|
|||
* google.registry.tools.DeployInvoicingPipelineCommand} Nomulus command.
|
||||
*
|
||||
* <p>Then, you can run the staged template via the API client library, gCloud or a raw REST call.
|
||||
* For an example using the API client library, see {@link
|
||||
* google.registry.billing.GenerateInvoicesAction}.
|
||||
* For an example using the API client library, see {@link GenerateInvoicesAction}.
|
||||
*
|
||||
* @see <a href="https://cloud.google.com/dataflow/docs/templates/overview">Dataflow Templates</a>
|
||||
*/
|
||||
|
|
|
@ -470,7 +470,7 @@ public final class RegistryConfig {
|
|||
/**
|
||||
* Returns the name of the GCS bucket for storing Beam templates and results.
|
||||
*
|
||||
* @see google.registry.billing.GenerateInvoicesAction
|
||||
* @see google.registry.reporting.billing.GenerateInvoicesAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("apacheBeamBucket")
|
||||
|
@ -481,7 +481,7 @@ public final class RegistryConfig {
|
|||
/**
|
||||
* Returns the URL of the GCS location for storing Apache Beam related objects.
|
||||
*
|
||||
* @see google.registry.billing.GenerateInvoicesAction
|
||||
* @see google.registry.reporting.billing.GenerateInvoicesAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("apacheBeamBucketUrl")
|
||||
|
@ -492,7 +492,7 @@ public final class RegistryConfig {
|
|||
/**
|
||||
* Returns the URL of the GCS location for storing the monthly invoicing Beam template.
|
||||
*
|
||||
* @see google.registry.billing.GenerateInvoicesAction
|
||||
* @see google.registry.reporting.billing.GenerateInvoicesAction
|
||||
* @see google.registry.beam.InvoicingPipeline
|
||||
*/
|
||||
@Provides
|
||||
|
@ -518,7 +518,7 @@ public final class RegistryConfig {
|
|||
* Returns the Google Cloud Storage bucket for ICANN transaction and activity reports to
|
||||
* be uploaded.
|
||||
*
|
||||
* @see google.registry.reporting.IcannReportingUploadAction
|
||||
* @see google.registry.reporting.icann.IcannReportingUploadAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("icannReportingBucket")
|
||||
|
@ -529,7 +529,7 @@ public final class RegistryConfig {
|
|||
/**
|
||||
* Returns the URL we send HTTP PUT requests for ICANN monthly transactions reports.
|
||||
*
|
||||
* @see google.registry.reporting.IcannHttpReporter
|
||||
* @see google.registry.reporting.icann.IcannHttpReporter
|
||||
*/
|
||||
@Provides
|
||||
@Config("icannTransactionsReportingUploadUrl")
|
||||
|
@ -540,7 +540,7 @@ public final class RegistryConfig {
|
|||
/**
|
||||
* Returns the URL we send HTTP PUT requests for ICANN monthly activity reports.
|
||||
*
|
||||
* @see google.registry.reporting.IcannHttpReporter
|
||||
* @see google.registry.reporting.icann.IcannHttpReporter
|
||||
*/
|
||||
@Provides
|
||||
@Config("icannActivityReportingUploadUrl")
|
||||
|
@ -768,7 +768,7 @@ public final class RegistryConfig {
|
|||
* <p>This allows us to easily verify the success or failure of periodic tasks by passively
|
||||
* checking e-mail.
|
||||
*
|
||||
* @see google.registry.reporting.ReportingEmailUtils
|
||||
* @see google.registry.reporting.icann.ReportingEmailUtils
|
||||
* @see google.registry.billing.BillingEmailUtils
|
||||
*/
|
||||
@Provides
|
||||
|
@ -780,7 +780,7 @@ public final class RegistryConfig {
|
|||
/**
|
||||
* Returns the email address we send emails from.
|
||||
*
|
||||
* @see google.registry.reporting.ReportingEmailUtils
|
||||
* @see google.registry.reporting.icann.ReportingEmailUtils
|
||||
* @see google.registry.billing.BillingEmailUtils
|
||||
*/
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ import javax.inject.Inject;
|
|||
* Publish a single registrar detail report from GCS to Drive.
|
||||
*
|
||||
* <p>This is now DEPRECATED, and will be removed upon completion of the billing migration. If you
|
||||
* wish to use the functionality, use {@link google.registry.billing.CopyDetailReportsAction}
|
||||
* instead.
|
||||
* wish to use the functionality, use {@link
|
||||
* google.registry.reporting.billing.CopyDetailReportsAction} instead.
|
||||
*/
|
||||
@Action(
|
||||
path = PublishDetailReportAction.PATH,
|
||||
|
|
|
@ -11,7 +11,6 @@ java_library(
|
|||
"//java/google/registry/backup",
|
||||
"//java/google/registry/batch",
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/billing",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/cron",
|
||||
"//java/google/registry/dns",
|
||||
|
@ -31,6 +30,8 @@ java_library(
|
|||
"//java/google/registry/rde",
|
||||
"//java/google/registry/rde/imports",
|
||||
"//java/google/registry/reporting",
|
||||
"//java/google/registry/reporting/billing",
|
||||
"//java/google/registry/reporting/icann",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request:modules",
|
||||
"//java/google/registry/request/auth",
|
||||
|
|
|
@ -16,9 +16,7 @@ package google.registry.module.backend;
|
|||
|
||||
import static google.registry.model.registry.Registries.assertTldExists;
|
||||
import static google.registry.model.registry.Registries.assertTldsExist;
|
||||
import static google.registry.request.RequestParameters.PARAM_YEAR_MONTH;
|
||||
import static google.registry.request.RequestParameters.extractOptionalDatetimeParameter;
|
||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||
import static google.registry.request.RequestParameters.extractSetOfParameters;
|
||||
|
||||
|
@ -26,16 +24,11 @@ import com.google.common.collect.ImmutableSet;
|
|||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.batch.ExpandRecurringBillingEventsAction;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.RequestParameters;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.Optional;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.YearMonth;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Dagger module for injecting common settings for all Backend tasks.
|
||||
|
@ -63,30 +56,4 @@ public class BackendModule {
|
|||
return extractOptionalDatetimeParameter(
|
||||
req, ExpandRecurringBillingEventsAction.PARAM_CURSOR_TIME);
|
||||
}
|
||||
|
||||
/** Extracts an optional YearMonth in yyyy-MM format from the request. */
|
||||
@Provides
|
||||
@Parameter(PARAM_YEAR_MONTH)
|
||||
static Optional<YearMonth> provideYearMonthOptional(HttpServletRequest req) {
|
||||
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
|
||||
Optional<String> optionalYearMonthStr = extractOptionalParameter(req, PARAM_YEAR_MONTH);
|
||||
try {
|
||||
return optionalYearMonthStr.map(s -> YearMonth.parse(s, formatter));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException(
|
||||
String.format(
|
||||
"yearMonth must be in yyyy-MM format, got %s instead",
|
||||
optionalYearMonthStr.orElse("UNSPECIFIED YEARMONTH")));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the yearMonth in yyyy-MM format, if not specified in the request, defaults to one
|
||||
* month prior to run time.
|
||||
*/
|
||||
@Provides
|
||||
static YearMonth provideYearMonth(
|
||||
@Parameter(PARAM_YEAR_MONTH) Optional<YearMonth> yearMonthOptional, Clock clock) {
|
||||
return yearMonthOptional.orElseGet(() -> new YearMonth(clock.nowUtc().minusMonths(1)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,6 @@ import google.registry.batch.MapreduceEntityCleanupAction;
|
|||
import google.registry.batch.RefreshDnsOnHostRenameAction;
|
||||
import google.registry.batch.ResaveAllEppResourcesAction;
|
||||
import google.registry.batch.VerifyEntityIntegrityAction;
|
||||
import google.registry.billing.BillingModule;
|
||||
import google.registry.billing.CopyDetailReportsAction;
|
||||
import google.registry.billing.GenerateInvoicesAction;
|
||||
import google.registry.billing.PublishInvoicesAction;
|
||||
import google.registry.cron.CommitLogFanoutAction;
|
||||
import google.registry.cron.CronModule;
|
||||
import google.registry.cron.TldFanoutAction;
|
||||
|
@ -69,9 +65,14 @@ import google.registry.rde.imports.RdeDomainImportAction;
|
|||
import google.registry.rde.imports.RdeHostImportAction;
|
||||
import google.registry.rde.imports.RdeHostLinkAction;
|
||||
import google.registry.rde.imports.RdeImportsModule;
|
||||
import google.registry.reporting.IcannReportingModule;
|
||||
import google.registry.reporting.IcannReportingStagingAction;
|
||||
import google.registry.reporting.IcannReportingUploadAction;
|
||||
import google.registry.reporting.ReportingModule;
|
||||
import google.registry.reporting.billing.BillingModule;
|
||||
import google.registry.reporting.billing.CopyDetailReportsAction;
|
||||
import google.registry.reporting.billing.GenerateInvoicesAction;
|
||||
import google.registry.reporting.billing.PublishInvoicesAction;
|
||||
import google.registry.reporting.icann.IcannReportingModule;
|
||||
import google.registry.reporting.icann.IcannReportingStagingAction;
|
||||
import google.registry.reporting.icann.IcannReportingUploadAction;
|
||||
import google.registry.request.RequestComponentBuilder;
|
||||
import google.registry.request.RequestModule;
|
||||
import google.registry.request.RequestScope;
|
||||
|
@ -101,6 +102,7 @@ import google.registry.tmch.TmchSmdrlAction;
|
|||
MapreduceModule.class,
|
||||
RdeModule.class,
|
||||
RdeImportsModule.class,
|
||||
ReportingModule.class,
|
||||
RequestModule.class,
|
||||
SheetModule.class,
|
||||
TmchModule.class,
|
||||
|
|
|
@ -7,27 +7,11 @@ licenses(["notice"]) # Apache 2.0
|
|||
java_library(
|
||||
name = "reporting",
|
||||
srcs = glob(["*.java"]),
|
||||
resources = glob(["sql/*"]),
|
||||
deps = [
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/gcs",
|
||||
"//java/google/registry/keyring/api",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
"//java/google/registry/util",
|
||||
"//java/google/registry/xjc",
|
||||
"//java/google/registry/xml",
|
||||
"@com_google_api_client",
|
||||
"@com_google_apis_google_api_services_bigquery",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_appengine_tools_appengine_gcs_client",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_google_http_client_jackson2",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
],
|
||||
|
|
67
java/google/registry/reporting/ReportingModule.java
Normal file
67
java/google/registry/reporting/ReportingModule.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Copyright 2017 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.reporting;
|
||||
|
||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.util.Clock;
|
||||
import java.util.Optional;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.joda.time.YearMonth;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Dagger module for injecting common settings for all Backend tasks.
|
||||
*/
|
||||
@Module
|
||||
public class ReportingModule {
|
||||
|
||||
/**
|
||||
* The request parameter name used by reporting actions that takes a year/month parameter, which
|
||||
* defaults to the last month.
|
||||
*/
|
||||
public static final String PARAM_YEAR_MONTH = "yearMonth";
|
||||
|
||||
/** Extracts an optional YearMonth in yyyy-MM format from the request. */
|
||||
@Provides
|
||||
@Parameter(PARAM_YEAR_MONTH)
|
||||
static Optional<YearMonth> provideYearMonthOptional(HttpServletRequest req) {
|
||||
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM");
|
||||
Optional<String> optionalYearMonthStr = extractOptionalParameter(req, PARAM_YEAR_MONTH);
|
||||
try {
|
||||
return optionalYearMonthStr.map(s -> YearMonth.parse(s, formatter));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException(
|
||||
String.format(
|
||||
"yearMonth must be in yyyy-MM format, got %s instead",
|
||||
optionalYearMonthStr.orElse("UNSPECIFIED YEARMONTH")));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the yearMonth in yyyy-MM format, if not specified in the request, defaults to one
|
||||
* month prior to run time.
|
||||
*/
|
||||
@Provides
|
||||
static YearMonth provideYearMonth(
|
||||
@Parameter(PARAM_YEAR_MONTH) Optional<YearMonth> yearMonthOptional, Clock clock) {
|
||||
return yearMonthOptional.orElseGet(() -> new YearMonth(clock.nowUtc().minusMonths(1)));
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ java_library(
|
|||
"//java/google/registry/config",
|
||||
"//java/google/registry/gcs",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/reporting",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
"//java/google/registry/storage/drive",
|
|
@ -12,16 +12,16 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.io.CharStreams;
|
||||
import google.registry.billing.BillingModule.InvoiceDirectoryPrefix;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.reporting.billing.BillingModule.InvoiceDirectoryPrefix;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import google.registry.util.Retrier;
|
||||
import google.registry.util.SendEmailService;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
|
@ -22,10 +22,10 @@ import com.google.appengine.tools.cloudstorage.GcsFilename;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.billing.BillingModule.InvoiceDirectoryPrefix;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.reporting.billing.BillingModule.InvoiceDirectoryPrefix;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
|
@ -12,10 +12,10 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static google.registry.reporting.ReportingModule.PARAM_YEAR_MONTH;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static google.registry.request.RequestParameters.PARAM_YEAR_MONTH;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static google.registry.reporting.ReportingModule.PARAM_YEAR_MONTH;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static google.registry.request.RequestParameters.PARAM_YEAR_MONTH;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_MODIFIED;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
|
|
@ -12,10 +12,10 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static google.registry.reporting.IcannReportingModule.DATASTORE_EXPORT_DATA_SET;
|
||||
import static google.registry.reporting.IcannReportingModule.ICANN_REPORTING_DATA_SET;
|
||||
import static google.registry.reporting.icann.IcannReportingModule.DATASTORE_EXPORT_DATA_SET;
|
||||
import static google.registry.reporting.icann.IcannReportingModule.ICANN_REPORTING_DATA_SET;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.Resources;
|
34
java/google/registry/reporting/icann/BUILD
Normal file
34
java/google/registry/reporting/icann/BUILD
Normal file
|
@ -0,0 +1,34 @@
|
|||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
java_library(
|
||||
name = "icann",
|
||||
srcs = glob(["*.java"]),
|
||||
resources = glob(["sql/*"]),
|
||||
deps = [
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/gcs",
|
||||
"//java/google/registry/keyring/api",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
"//java/google/registry/util",
|
||||
"//java/google/registry/xjc",
|
||||
"//java/google/registry/xml",
|
||||
"@com_google_api_client",
|
||||
"@com_google_apis_google_api_services_bigquery",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_appengine_tools_appengine_gcs_client",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_google_http_client_jackson2",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
],
|
||||
)
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.net.MediaType.CSV_UTF_8;
|
||||
|
@ -30,7 +30,7 @@ import com.google.common.base.Splitter;
|
|||
import com.google.common.io.ByteStreams;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.keyring.api.KeyModule.Key;
|
||||
import google.registry.reporting.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import google.registry.xjc.XjcXmlTransformer;
|
||||
import google.registry.xjc.iirdea.XjcIirdeaResponseElement;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static google.registry.request.RequestParameters.extractOptionalEnumParameter;
|
||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
|
@ -12,12 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static google.registry.reporting.IcannReportingModule.MANIFEST_FILE_NAME;
|
||||
import static google.registry.reporting.icann.IcannReportingModule.MANIFEST_FILE_NAME;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.api.services.bigquery.model.TableFieldSchema;
|
||||
|
@ -34,8 +34,8 @@ import google.registry.bigquery.BigqueryConnection;
|
|||
import google.registry.bigquery.BigqueryUtils.TableType;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.reporting.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.IcannReportingModule.ReportingSubdir;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportingSubdir;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
|
@ -25,8 +25,8 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.bigquery.BigqueryJobFailureException;
|
||||
import google.registry.reporting.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.IcannReportingModule.ReportingSubdir;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportingSubdir;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
|
@ -12,11 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||
import static google.registry.reporting.IcannReportingModule.MANIFEST_FILE_NAME;
|
||||
import static google.registry.reporting.icann.IcannReportingModule.MANIFEST_FILE_NAME;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||
|
@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.io.ByteStreams;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.reporting.IcannReportingModule.ReportingSubdir;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportingSubdir;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.io.IOException;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.util.FormattingLogger;
|
|
@ -12,10 +12,10 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static google.registry.reporting.IcannReportingModule.DATASTORE_EXPORT_DATA_SET;
|
||||
import static google.registry.reporting.IcannReportingModule.ICANN_REPORTING_DATA_SET;
|
||||
import static google.registry.reporting.icann.IcannReportingModule.DATASTORE_EXPORT_DATA_SET;
|
||||
import static google.registry.reporting.icann.IcannReportingModule.ICANN_REPORTING_DATA_SET;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.Resources;
|
|
@ -32,11 +32,6 @@ public final class RequestParameters {
|
|||
/** The standardized request parameter name used by any action that takes a tld parameter. */
|
||||
public static final String PARAM_TLD = "tld";
|
||||
|
||||
/**
|
||||
* The standardized request parameter name used by any action that takes a year/month parameter.
|
||||
*/
|
||||
public static final String PARAM_YEAR_MONTH = "yearMonth";
|
||||
|
||||
/**
|
||||
* Returns first GET or POST parameter associated with {@code name}.
|
||||
*
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.module.backend;
|
||||
package google.registry.reporting;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
@ -31,9 +31,9 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link BackendModule}. */
|
||||
/** Unit tests for {@link ReportingModule}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class BackendModuleTest {
|
||||
public class ReportingModuleTest {
|
||||
|
||||
private HttpServletRequest req = mock(HttpServletRequest.class);
|
||||
private Clock clock;
|
||||
|
@ -45,7 +45,7 @@ public class BackendModuleTest {
|
|||
@Test
|
||||
public void testEmptyYearMonthParameter_returnsEmptyYearMonthOptional() {
|
||||
when(req.getParameter("yearMonth")).thenReturn("");
|
||||
assertThat(BackendModule.provideYearMonthOptional(req)).isEqualTo(Optional.empty());
|
||||
assertThat(ReportingModule.provideYearMonthOptional(req)).isEqualTo(Optional.empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,7 +53,7 @@ public class BackendModuleTest {
|
|||
when(req.getParameter("yearMonth")).thenReturn("201705");
|
||||
BadRequestException thrown =
|
||||
expectThrows(
|
||||
BadRequestException.class, () -> BackendModule.provideYearMonthOptional(req));
|
||||
BadRequestException.class, () -> ReportingModule.provideYearMonthOptional(req));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("yearMonth must be in yyyy-MM format, got 201705 instead");
|
||||
|
@ -61,13 +61,13 @@ public class BackendModuleTest {
|
|||
|
||||
@Test
|
||||
public void testEmptyYearMonth_returnsLastMonth() {
|
||||
assertThat(BackendModule.provideYearMonth(Optional.empty(), clock))
|
||||
assertThat(ReportingModule.provideYearMonth(Optional.empty(), clock))
|
||||
.isEqualTo(new YearMonth(2017, 6));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGivenYearMonth_returnsThatMonth() {
|
||||
assertThat(BackendModule.provideYearMonth(Optional.of(new YearMonth(2017, 5)), clock))
|
||||
assertThat(ReportingModule.provideYearMonth(Optional.of(new YearMonth(2017, 5)), clock))
|
||||
.isEqualTo(new YearMonth(2017, 5));
|
||||
}
|
||||
|
|
@ -11,8 +11,8 @@ java_library(
|
|||
name = "billing",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/google/registry/billing",
|
||||
"//java/google/registry/gcs",
|
||||
"//java/google/registry/reporting/billing",
|
||||
"//java/google/registry/storage/drive",
|
||||
"//java/google/registry/util",
|
||||
"//javatests/google/registry/testing",
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
@ -50,7 +50,7 @@ import org.mockito.ArgumentCaptor;
|
|||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
/** Unit tests for {@link BillingEmailUtils}. */
|
||||
/** Unit tests for {@link google.registry.reporting.billing.BillingEmailUtils}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class BillingEmailUtilsTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
|
@ -47,7 +47,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link CopyDetailReportsAction}. */
|
||||
/** Unit tests for {@link google.registry.reporting.billing.CopyDetailReportsAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class CopyDetailReportsActionTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
|
@ -41,7 +41,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link GenerateInvoicesAction}. */
|
||||
/** Unit tests for {@link google.registry.reporting.billing.GenerateInvoicesAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class GenerateInvoicesActionTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.billing;
|
||||
package google.registry.reporting.billing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
42
javatests/google/registry/reporting/icann/BUILD
Normal file
42
javatests/google/registry/reporting/icann/BUILD
Normal file
|
@ -0,0 +1,42 @@
|
|||
package(
|
||||
default_testonly = 1,
|
||||
default_visibility = ["//java/google/registry:registry_project"],
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
load("//java/com/google/testing/builddefs:GenTestRules.bzl", "GenTestRules")
|
||||
|
||||
java_library(
|
||||
name = "icann",
|
||||
srcs = glob(["*.java"]),
|
||||
resources = glob(["testdata/*"]),
|
||||
deps = [
|
||||
"//java/google/registry/bigquery",
|
||||
"//java/google/registry/gcs",
|
||||
"//java/google/registry/reporting/icann",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/util",
|
||||
"//javatests/google/registry/testing",
|
||||
"@com_google_apis_google_api_services_bigquery",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_appengine_tools_appengine_gcs_client",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_guava",
|
||||
"@com_google_http_client",
|
||||
"@com_google_truth",
|
||||
"@com_google_truth_extensions_truth_java8_extension",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
"@junit",
|
||||
"@org_mockito_all",
|
||||
],
|
||||
)
|
||||
|
||||
GenTestRules(
|
||||
name = "GeneratedTestRules",
|
||||
default_test_size = "small",
|
||||
test_files = glob(["*Test.java"]),
|
||||
deps = [":icann"],
|
||||
)
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.net.MediaType.CSV_UTF_8;
|
||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||
|
@ -40,7 +40,7 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.JUnit4;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link google.registry.reporting.IcannHttpReporter}.
|
||||
* Unit tests for {@link IcannHttpReporter}.
|
||||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class IcannHttpReporterTest {
|
|
@ -12,12 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import google.registry.reporting.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.YearMonth;
|
||||
|
@ -25,7 +25,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link google.registry.reporting.IcannReportingModule}. */
|
||||
/** Unit tests for {@link google.registry.reporting.icann.IcannReportingModule}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class IcannReportingModuleTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.GcsTestingUtils.readGcsFile;
|
||||
|
@ -32,7 +32,7 @@ import google.registry.bigquery.BigqueryConnection;
|
|||
import google.registry.bigquery.BigqueryConnection.DestinationTable;
|
||||
import google.registry.bigquery.BigqueryUtils.TableType;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.reporting.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -45,7 +45,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link google.registry.reporting.IcannReportingStager}. */
|
||||
/** Unit tests for {@link google.registry.reporting.icann.IcannReportingStager}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class IcannReportingStagerTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
@ -25,7 +25,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.bigquery.BigqueryJobFailureException;
|
||||
import google.registry.reporting.IcannReportingModule.ReportType;
|
||||
import google.registry.reporting.icann.IcannReportingModule.ReportType;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
|
@ -39,9 +39,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link google.registry.reporting.IcannReportingStagingAction}.
|
||||
*/
|
||||
/** Unit tests for {@link google.registry.reporting.icann.IcannReportingStagingAction}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class IcannReportingStagingActionTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.GcsTestingUtils.writeGcsFile;
|
||||
|
@ -40,7 +40,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link google.registry.reporting.IcannReportingUploadAction} */
|
||||
/** Unit tests for {@link google.registry.reporting.icann.IcannReportingUploadAction} */
|
||||
@RunWith(JUnit4.class)
|
||||
public class IcannReportingUploadActionTest {
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -30,7 +30,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link ReportingEmailUtils}. */
|
||||
/** Unit tests for {@link google.registry.reporting.icann.ReportingEmailUtils}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ReportingEmailUtilsTest {
|
||||
private Message msg;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import com.google.common.io.ByteSource;
|
||||
import google.registry.testing.TestDataHelper;
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.reporting;
|
||||
package google.registry.reporting.icann;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue