From 1dcbc9e0cb4bfbe05a7dc32f1ceccc3df02a6c4a Mon Sep 17 00:00:00 2001 From: sarahcaseybot Date: Tue, 22 Aug 2023 16:39:24 -0400 Subject: [PATCH] Change PackagePromotion to BulkPricingPackage (#2096) * Change PackagePromotion to BulkPricingPackage * More name changes * Fix some test names * Change token type "BULK" to "BULK_PRICING" * Fix missed token_type reference * Add todo to remove package type --- .../batch/CheckBulkComplianceAction.java | 246 ++++++++++++++++++ .../batch/CheckPackagesComplianceAction.java | 226 ---------------- .../registry/config/RegistryConfig.java | 58 +++-- .../config/RegistryConfigSettings.java | 18 +- .../registry/config/files/default-config.yaml | 50 ++-- .../flows/domain/DomainCreateFlow.java | 18 +- .../registry/flows/domain/DomainInfoFlow.java | 10 +- .../flows/domain/DomainRenewFlow.java | 14 +- .../domain/DomainTransferApproveFlow.java | 14 +- .../domain/DomainTransferRequestFlow.java | 5 +- .../flows/domain/DomainTransferUtils.java | 2 +- .../token/AllocationTokenFlowUtils.java | 32 +-- .../google/registry/model/domain/Domain.java | 2 +- .../registry/model/domain/DomainBase.java | 31 ++- .../model/domain/token/AllocationToken.java | 24 +- ...Promotion.java => BulkPricingPackage.java} | 68 ++--- ...a => CreateBulkPricingPackageCommand.java} | 16 +- ...ateOrUpdateBulkPricingPackageCommand.java} | 49 ++-- .../GenerateAllocationTokensCommand.java | 15 +- ...java => GetBulkPricingPackageCommand.java} | 18 +- .../google/registry/tools/RegistryTool.java | 6 +- .../registry/tools/RegistryToolComponent.java | 2 +- .../tools/UpdateAllocationTokensCommand.java | 14 +- ...a => UpdateBulkPricingPackageCommand.java} | 20 +- .../main/resources/META-INF/persistence.xml | 2 +- ...ava => CheckBulkComplianceActionTest.java} | 244 +++++++++-------- .../flows/domain/DomainCreateFlowTest.java | 20 +- .../flows/domain/DomainInfoFlowTest.java | 12 +- .../flows/domain/DomainRenewFlowTest.java | 50 ++-- .../domain/DomainTransferApproveFlowTest.java | 18 +- .../domain/DomainTransferRequestFlowTest.java | 20 +- .../registry/model/domain/DomainSqlTest.java | 8 +- .../registry/model/domain/DomainTest.java | 46 ++-- .../domain/token/AllocationTokenTest.java | 20 +- ...nTest.java => BulkPricingPackageTest.java} | 28 +- .../integration/SqlIntegrationTestSuite.java | 4 +- ... CreateBulkPricingPackageCommandTest.java} | 93 +++---- .../GenerateAllocationTokensCommandTest.java | 12 +- ... => GetBulkPricingPackageCommandTest.java} | 35 +-- .../UpdateAllocationTokensCommandTest.java | 16 +- ... UpdateBulkPricingPackageCommandTest.java} | 119 ++++----- .../sql/schema/db-schema.sql.generated | 4 +- docs/flows.md | 6 +- 43 files changed, 879 insertions(+), 836 deletions(-) create mode 100644 core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java delete mode 100644 core/src/main/java/google/registry/batch/CheckPackagesComplianceAction.java rename core/src/main/java/google/registry/model/domain/token/{PackagePromotion.java => BulkPricingPackage.java} (68%) rename core/src/main/java/google/registry/tools/{CreatePackagePromotionCommand.java => CreateBulkPricingPackageCommand.java} (61%) rename core/src/main/java/google/registry/tools/{CreateOrUpdatePackagePromotionCommand.java => CreateOrUpdateBulkPricingPackageCommand.java} (65%) rename core/src/main/java/google/registry/tools/{GetPackagePromotionCommand.java => GetBulkPricingPackageCommand.java} (65%) rename core/src/main/java/google/registry/tools/{UpdatePackagePromotionCommand.java => UpdateBulkPricingPackageCommand.java} (64%) rename core/src/test/java/google/registry/batch/{CheckPackagesComplianceActionTest.java => CheckBulkComplianceActionTest.java} (68%) rename core/src/test/java/google/registry/model/domain/token/{PackagePromotionTest.java => BulkPricingPackageTest.java} (81%) rename core/src/test/java/google/registry/tools/{CreatePackagePromotionCommandTest.java => CreateBulkPricingPackageCommandTest.java} (68%) rename core/src/test/java/google/registry/tools/{GetPackagePromotionCommandTest.java => GetBulkPricingPackageCommandTest.java} (80%) rename core/src/test/java/google/registry/tools/{UpdatePackagePromotionCommandTest.java => UpdateBulkPricingPackageCommandTest.java} (53%) diff --git a/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java b/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java new file mode 100644 index 000000000..16beb6ef7 --- /dev/null +++ b/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java @@ -0,0 +1,246 @@ +// Copyright 2022 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.batch; + +import static google.registry.persistence.transaction.TransactionManagerFactory.tm; +import static google.registry.util.DateTimeUtils.END_OF_TIME; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.flogger.FluentLogger; +import com.google.common.primitives.Ints; +import google.registry.config.RegistryConfig.Config; +import google.registry.model.domain.token.AllocationToken; +import google.registry.model.domain.token.BulkPricingPackage; +import google.registry.model.registrar.Registrar; +import google.registry.request.Action; +import google.registry.request.Action.Service; +import google.registry.request.auth.Auth; +import google.registry.ui.server.SendEmailUtils; +import google.registry.util.Clock; +import java.util.Optional; +import javax.inject.Inject; +import org.joda.time.Days; + +/** + * An action that checks all {@link BulkPricingPackage} objects for compliance with their max create + * limit. + */ +@Action( + service = Service.BACKEND, + path = CheckBulkComplianceAction.PATH, + auth = Auth.AUTH_API_ADMIN) +public class CheckBulkComplianceAction implements Runnable { + + public static final String PATH = "/_dr/task/checkBulkCompliance"; + private static final FluentLogger logger = FluentLogger.forEnclosingClass(); + private final SendEmailUtils sendEmailUtils; + private final Clock clock; + private final String bulkPricingPackageCreateLimitEmailSubject; + private final String bulkPricingPackageDomainLimitWarningEmailSubject; + private final String bulkPricingPackageDomainLimitUpgradeEmailSubject; + private final String bulkPricingPackageCreateLimitEmailBody; + private final String bulkPricingPackageDomainLimitWarningEmailBody; + private final String bulkPricingPackageDomainLimitUpgradeEmailBody; + private final String registrySupportEmail; + private static final int THIRTY_DAYS = 30; + private static final int FORTY_DAYS = 40; + + @Inject + public CheckBulkComplianceAction( + SendEmailUtils sendEmailUtils, + Clock clock, + @Config("bulkPricingPackageCreateLimitEmailSubject") + String bulkPricingPackageCreateLimitEmailSubject, + @Config("bulkPricingPackageDomainLimitWarningEmailSubject") + String bulkPricingPackageDomainLimitWarningEmailSubject, + @Config("bulkPricingPackageDomainLimitUpgradeEmailSubject") + String bulkPricingPackageDomainLimitUpgradeEmailSubject, + @Config("bulkPricingPackageCreateLimitEmailBody") + String bulkPricingPackageCreateLimitEmailBody, + @Config("bulkPricingPackageDomainLimitWarningEmailBody") + String bulkPricingPackageDomainLimitWarningEmailBody, + @Config("bulkPricingPackageDomainLimitUpgradeEmailBody") + String bulkPricingPackageDomainLimitUpgradeEmailBody, + @Config("registrySupportEmail") String registrySupportEmail) { + this.sendEmailUtils = sendEmailUtils; + this.clock = clock; + this.bulkPricingPackageCreateLimitEmailSubject = bulkPricingPackageCreateLimitEmailSubject; + this.bulkPricingPackageDomainLimitWarningEmailSubject = + bulkPricingPackageDomainLimitWarningEmailSubject; + this.bulkPricingPackageDomainLimitUpgradeEmailSubject = + bulkPricingPackageDomainLimitUpgradeEmailSubject; + this.bulkPricingPackageCreateLimitEmailBody = bulkPricingPackageCreateLimitEmailBody; + this.bulkPricingPackageDomainLimitWarningEmailBody = + bulkPricingPackageDomainLimitWarningEmailBody; + this.bulkPricingPackageDomainLimitUpgradeEmailBody = + bulkPricingPackageDomainLimitUpgradeEmailBody; + this.registrySupportEmail = registrySupportEmail; + } + + @Override + public void run() { + tm().transact(this::checkBulkPackages); + } + + private void checkBulkPackages() { + ImmutableList bulkPricingPackages = + tm().loadAllOf(BulkPricingPackage.class); + ImmutableMap.Builder bulkPricingPackagesOverCreateLimitBuilder = + new ImmutableMap.Builder<>(); + ImmutableMap.Builder + bulkPricingPackagesOverActiveDomainsLimitBuilder = new ImmutableMap.Builder<>(); + for (BulkPricingPackage bulkPricingPackage : bulkPricingPackages) { + Long creates = + (Long) + tm().query( + "SELECT COUNT(*) FROM DomainHistory WHERE current_package_token =" + + " :token AND modificationTime >= :lastBilling AND type =" + + " 'DOMAIN_CREATE'") + .setParameter("token", bulkPricingPackage.getToken().getKey().toString()) + .setParameter( + "lastBilling", bulkPricingPackage.getNextBillingDate().minusYears(1)) + .getSingleResult(); + if (creates > bulkPricingPackage.getMaxCreates()) { + long overage = creates - bulkPricingPackage.getMaxCreates(); + logger.atInfo().log( + "Bulk pricing package with bulk token %s has exceeded their max domain creation limit" + + " by %d name(s).", + bulkPricingPackage.getToken().getKey(), overage); + bulkPricingPackagesOverCreateLimitBuilder.put(bulkPricingPackage, creates); + } + + Long activeDomains = + tm().query( + "SELECT COUNT(*) FROM Domain WHERE currentBulkToken = :token" + + " AND deletionTime = :endOfTime", + Long.class) + .setParameter("token", bulkPricingPackage.getToken()) + .setParameter("endOfTime", END_OF_TIME) + .getSingleResult(); + if (activeDomains > bulkPricingPackage.getMaxDomains()) { + int overage = Ints.saturatedCast(activeDomains) - bulkPricingPackage.getMaxDomains(); + logger.atInfo().log( + "Bulk pricing package with bulk token %s has exceed their max active domains limit by" + + " %d name(s).", + bulkPricingPackage.getToken().getKey(), overage); + bulkPricingPackagesOverActiveDomainsLimitBuilder.put(bulkPricingPackage, activeDomains); + } + } + handleBulkPricingPackageCreationOverage(bulkPricingPackagesOverCreateLimitBuilder.build()); + handleActiveDomainOverage(bulkPricingPackagesOverActiveDomainsLimitBuilder.build()); + } + + private void handleBulkPricingPackageCreationOverage( + ImmutableMap overageList) { + if (overageList.isEmpty()) { + logger.atInfo().log("Found no bulk pricing packages over their create limit."); + return; + } + logger.atInfo().log( + "Found %d bulk pricing packages over their create limit.", overageList.size()); + for (BulkPricingPackage bulkPricingPackage : overageList.keySet()) { + AllocationToken bulkToken = tm().loadByKey(bulkPricingPackage.getToken()); + Optional registrar = + Registrar.loadByRegistrarIdCached( + Iterables.getOnlyElement(bulkToken.getAllowedRegistrarIds())); + if (registrar.isPresent()) { + String body = + String.format( + bulkPricingPackageCreateLimitEmailBody, + bulkPricingPackage.getId(), + bulkToken.getToken(), + registrar.get().getRegistrarName(), + bulkPricingPackage.getMaxCreates(), + overageList.get(bulkPricingPackage)); + sendNotification( + bulkToken, bulkPricingPackageCreateLimitEmailSubject, body, registrar.get()); + } else { + throw new IllegalStateException( + String.format("Could not find registrar for bulk token %s", bulkToken)); + } + } + } + + private void handleActiveDomainOverage(ImmutableMap overageList) { + if (overageList.isEmpty()) { + logger.atInfo().log("Found no bulk pricing packages over their active domains limit."); + return; + } + logger.atInfo().log( + "Found %d bulk pricing packages over their active domains limit.", overageList.size()); + for (BulkPricingPackage bulkPricingPackage : overageList.keySet()) { + int daysSinceLastNotification = + bulkPricingPackage + .getLastNotificationSent() + .map(sentDate -> Days.daysBetween(sentDate, clock.nowUtc()).getDays()) + .orElse(Integer.MAX_VALUE); + if (daysSinceLastNotification < THIRTY_DAYS) { + // Don't send an email if notification was already sent within the last 30 + // days + continue; + } else if (daysSinceLastNotification < FORTY_DAYS) { + // Send an upgrade email if last email was between 30 and 40 days ago + sendActiveDomainOverageEmail( + /* warning= */ false, bulkPricingPackage, overageList.get(bulkPricingPackage)); + } else { + // Send a warning email + sendActiveDomainOverageEmail( + /* warning= */ true, bulkPricingPackage, overageList.get(bulkPricingPackage)); + } + } + } + + private void sendActiveDomainOverageEmail( + boolean warning, BulkPricingPackage bulkPricingPackage, long activeDomains) { + String emailSubject = + warning + ? bulkPricingPackageDomainLimitWarningEmailSubject + : bulkPricingPackageDomainLimitUpgradeEmailSubject; + String emailTemplate = + warning + ? bulkPricingPackageDomainLimitWarningEmailBody + : bulkPricingPackageDomainLimitUpgradeEmailBody; + AllocationToken bulkToken = tm().loadByKey(bulkPricingPackage.getToken()); + Optional registrar = + Registrar.loadByRegistrarIdCached( + Iterables.getOnlyElement(bulkToken.getAllowedRegistrarIds())); + if (registrar.isPresent()) { + String body = + String.format( + emailTemplate, + bulkPricingPackage.getId(), + bulkToken.getToken(), + registrar.get().getRegistrarName(), + bulkPricingPackage.getMaxDomains(), + activeDomains); + sendNotification(bulkToken, emailSubject, body, registrar.get()); + tm().put(bulkPricingPackage.asBuilder().setLastNotificationSent(clock.nowUtc()).build()); + } else { + throw new IllegalStateException( + String.format("Could not find registrar for bulk token %s", bulkToken)); + } + } + + private void sendNotification( + AllocationToken bulkToken, String subject, String body, Registrar registrar) { + logger.atInfo().log( + String.format( + "Compliance email sent to support regarding the %s registrar and the bulk pricing" + + " package with token %s.", + registrar.getRegistrarName(), bulkToken.getToken())); + sendEmailUtils.sendEmail(subject, body, ImmutableList.of(registrySupportEmail)); + } +} diff --git a/core/src/main/java/google/registry/batch/CheckPackagesComplianceAction.java b/core/src/main/java/google/registry/batch/CheckPackagesComplianceAction.java deleted file mode 100644 index 43b0a0100..000000000 --- a/core/src/main/java/google/registry/batch/CheckPackagesComplianceAction.java +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2022 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.batch; - -import static google.registry.persistence.transaction.TransactionManagerFactory.tm; -import static google.registry.util.DateTimeUtils.END_OF_TIME; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; -import com.google.common.flogger.FluentLogger; -import com.google.common.primitives.Ints; -import google.registry.config.RegistryConfig.Config; -import google.registry.model.domain.token.AllocationToken; -import google.registry.model.domain.token.PackagePromotion; -import google.registry.model.registrar.Registrar; -import google.registry.request.Action; -import google.registry.request.Action.Service; -import google.registry.request.auth.Auth; -import google.registry.ui.server.SendEmailUtils; -import google.registry.util.Clock; -import java.util.Optional; -import javax.inject.Inject; -import org.joda.time.Days; - -/** - * An action that checks all {@link PackagePromotion} objects for compliance with their max create - * limit. - */ -@Action( - service = Service.BACKEND, - path = CheckPackagesComplianceAction.PATH, - auth = Auth.AUTH_API_ADMIN) -public class CheckPackagesComplianceAction implements Runnable { - - public static final String PATH = "/_dr/task/checkPackagesCompliance"; - private static final FluentLogger logger = FluentLogger.forEnclosingClass(); - private final SendEmailUtils sendEmailUtils; - private final Clock clock; - private final String packageCreateLimitEmailSubject; - private final String packageDomainLimitWarningEmailSubject; - private final String packageDomainLimitUpgradeEmailSubject; - private final String packageCreateLimitEmailBody; - private final String packageDomainLimitWarningEmailBody; - private final String packageDomainLimitUpgradeEmailBody; - private final String registrySupportEmail; - private static final int THIRTY_DAYS = 30; - private static final int FORTY_DAYS = 40; - - @Inject - public CheckPackagesComplianceAction( - SendEmailUtils sendEmailUtils, - Clock clock, - @Config("packageCreateLimitEmailSubject") String packageCreateLimitEmailSubject, - @Config("packageDomainLimitWarningEmailSubject") String packageDomainLimitWarningEmailSubject, - @Config("packageDomainLimitUpgradeEmailSubject") String packageDomainLimitUpgradeEmailSubject, - @Config("packageCreateLimitEmailBody") String packageCreateLimitEmailBody, - @Config("packageDomainLimitWarningEmailBody") String packageDomainLimitWarningEmailBody, - @Config("packageDomainLimitUpgradeEmailBody") String packageDomainLimitUpgradeEmailBody, - @Config("registrySupportEmail") String registrySupportEmail) { - this.sendEmailUtils = sendEmailUtils; - this.clock = clock; - this.packageCreateLimitEmailSubject = packageCreateLimitEmailSubject; - this.packageDomainLimitWarningEmailSubject = packageDomainLimitWarningEmailSubject; - this.packageDomainLimitUpgradeEmailSubject = packageDomainLimitUpgradeEmailSubject; - this.packageCreateLimitEmailBody = packageCreateLimitEmailBody; - this.packageDomainLimitWarningEmailBody = packageDomainLimitWarningEmailBody; - this.packageDomainLimitUpgradeEmailBody = packageDomainLimitUpgradeEmailBody; - this.registrySupportEmail = registrySupportEmail; - } - - @Override - public void run() { - tm().transact(this::checkPackages); - } - - private void checkPackages() { - ImmutableList packages = tm().loadAllOf(PackagePromotion.class); - ImmutableMap.Builder packagesOverCreateLimitBuilder = - new ImmutableMap.Builder<>(); - ImmutableMap.Builder packagesOverActiveDomainsLimitBuilder = - new ImmutableMap.Builder<>(); - for (PackagePromotion packagePromo : packages) { - Long creates = - (Long) - tm().query( - "SELECT COUNT(*) FROM DomainHistory WHERE current_package_token =" - + " :token AND modificationTime >= :lastBilling AND type =" - + " 'DOMAIN_CREATE'") - .setParameter("token", packagePromo.getToken().getKey().toString()) - .setParameter("lastBilling", packagePromo.getNextBillingDate().minusYears(1)) - .getSingleResult(); - if (creates > packagePromo.getMaxCreates()) { - long overage = creates - packagePromo.getMaxCreates(); - logger.atInfo().log( - "Package with package token %s has exceeded their max domain creation limit" - + " by %d name(s).", - packagePromo.getToken().getKey(), overage); - packagesOverCreateLimitBuilder.put(packagePromo, creates); - } - - Long activeDomains = - tm().query( - "SELECT COUNT(*) FROM Domain WHERE currentPackageToken = :token" - + " AND deletionTime = :endOfTime", - Long.class) - .setParameter("token", packagePromo.getToken()) - .setParameter("endOfTime", END_OF_TIME) - .getSingleResult(); - if (activeDomains > packagePromo.getMaxDomains()) { - int overage = Ints.saturatedCast(activeDomains) - packagePromo.getMaxDomains(); - logger.atInfo().log( - "Package with package token %s has exceed their max active domains limit by" - + " %d name(s).", - packagePromo.getToken().getKey(), overage); - packagesOverActiveDomainsLimitBuilder.put(packagePromo, activeDomains); - } - } - handlePackageCreationOverage(packagesOverCreateLimitBuilder.build()); - handleActiveDomainOverage(packagesOverActiveDomainsLimitBuilder.build()); - } - - private void handlePackageCreationOverage(ImmutableMap overageList) { - if (overageList.isEmpty()) { - logger.atInfo().log("Found no packages over their create limit."); - return; - } - logger.atInfo().log("Found %d packages over their create limit.", overageList.size()); - for (PackagePromotion packagePromotion : overageList.keySet()) { - AllocationToken packageToken = tm().loadByKey(packagePromotion.getToken()); - Optional registrar = - Registrar.loadByRegistrarIdCached( - Iterables.getOnlyElement(packageToken.getAllowedRegistrarIds())); - if (registrar.isPresent()) { - String body = - String.format( - packageCreateLimitEmailBody, - packagePromotion.getId(), - packageToken.getToken(), - registrar.get().getRegistrarName(), - packagePromotion.getMaxCreates(), - overageList.get(packagePromotion)); - sendNotification(packageToken, packageCreateLimitEmailSubject, body, registrar.get()); - } else { - throw new IllegalStateException( - String.format("Could not find registrar for package token %s", packageToken)); - } - } - } - - private void handleActiveDomainOverage(ImmutableMap overageList) { - if (overageList.isEmpty()) { - logger.atInfo().log("Found no packages over their active domains limit."); - return; - } - logger.atInfo().log("Found %d packages over their active domains limit.", overageList.size()); - for (PackagePromotion packagePromotion : overageList.keySet()) { - int daysSinceLastNotification = - packagePromotion - .getLastNotificationSent() - .map(sentDate -> Days.daysBetween(sentDate, clock.nowUtc()).getDays()) - .orElse(Integer.MAX_VALUE); - if (daysSinceLastNotification < THIRTY_DAYS) { - // Don't send an email if notification was already sent within the last 30 - // days - continue; - } else if (daysSinceLastNotification < FORTY_DAYS) { - // Send an upgrade email if last email was between 30 and 40 days ago - sendActiveDomainOverageEmail( - /* warning= */ false, packagePromotion, overageList.get(packagePromotion)); - } else { - // Send a warning email - sendActiveDomainOverageEmail( - /* warning= */ true, packagePromotion, overageList.get(packagePromotion)); - } - } - } - - private void sendActiveDomainOverageEmail( - boolean warning, PackagePromotion packagePromotion, long activeDomains) { - String emailSubject = - warning ? packageDomainLimitWarningEmailSubject : packageDomainLimitUpgradeEmailSubject; - String emailTemplate = - warning ? packageDomainLimitWarningEmailBody : packageDomainLimitUpgradeEmailBody; - AllocationToken packageToken = tm().loadByKey(packagePromotion.getToken()); - Optional registrar = - Registrar.loadByRegistrarIdCached( - Iterables.getOnlyElement(packageToken.getAllowedRegistrarIds())); - if (registrar.isPresent()) { - String body = - String.format( - emailTemplate, - packagePromotion.getId(), - packageToken.getToken(), - registrar.get().getRegistrarName(), - packagePromotion.getMaxDomains(), - activeDomains); - sendNotification(packageToken, emailSubject, body, registrar.get()); - tm().put(packagePromotion.asBuilder().setLastNotificationSent(clock.nowUtc()).build()); - } else { - throw new IllegalStateException( - String.format("Could not find registrar for package token %s", packageToken)); - } - } - - private void sendNotification( - AllocationToken packageToken, String subject, String body, Registrar registrar) { - logger.atInfo().log( - String.format( - "Compliance email sent to support regarding the %s registrar and the package with token" - + " %s.", - registrar.getRegistrarName(), packageToken.getToken())); - sendEmailUtils.sendEmail(subject, body, ImmutableList.of(registrySupportEmail)); - } -} diff --git a/core/src/main/java/google/registry/config/RegistryConfig.java b/core/src/main/java/google/registry/config/RegistryConfig.java index 8b2ab574f..9f40c866b 100644 --- a/core/src/main/java/google/registry/config/RegistryConfig.java +++ b/core/src/main/java/google/registry/config/RegistryConfig.java @@ -1371,41 +1371,45 @@ public final class RegistryConfig { } @Provides - @Config("packageCreateLimitEmailSubject") - public static String providePackageCreateLimitEmailSubject(RegistryConfigSettings config) { - return config.packageMonitoring.packageCreateLimitEmailSubject; - } - - @Provides - @Config("packageCreateLimitEmailBody") - public static String providePackageCreateLimitEmailBody(RegistryConfigSettings config) { - return config.packageMonitoring.packageCreateLimitEmailBody; - } - - @Provides - @Config("packageDomainLimitWarningEmailSubject") - public static String providePackageDomainLimitWarningEmailSubject( + @Config("bulkPricingPackageCreateLimitEmailSubject") + public static String provideBulkPricingPackageCreateLimitEmailSubject( RegistryConfigSettings config) { - return config.packageMonitoring.packageDomainLimitWarningEmailSubject; + return config.bulkPricingPackageMonitoring.bulkPricingPackageCreateLimitEmailSubject; } @Provides - @Config("packageDomainLimitWarningEmailBody") - public static String providePackageDomainLimitWarningEmailBody(RegistryConfigSettings config) { - return config.packageMonitoring.packageDomainLimitWarningEmailBody; - } - - @Provides - @Config("packageDomainLimitUpgradeEmailSubject") - public static String providePackageDomainLimitUpgradeEmailSubject( + @Config("bulkPricingPackageCreateLimitEmailBody") + public static String provideBulkPricingPackageCreateLimitEmailBody( RegistryConfigSettings config) { - return config.packageMonitoring.packageDomainLimitUpgradeEmailSubject; + return config.bulkPricingPackageMonitoring.bulkPricingPackageCreateLimitEmailBody; } @Provides - @Config("packageDomainLimitUpgradeEmailBody") - public static String providePackageDomainLimitUpgradeEmailBody(RegistryConfigSettings config) { - return config.packageMonitoring.packageDomainLimitUpgradeEmailBody; + @Config("bulkPricingPackageDomainLimitWarningEmailSubject") + public static String provideBulkPricingPackageDomainLimitWarningEmailSubject( + RegistryConfigSettings config) { + return config.bulkPricingPackageMonitoring.bulkPricingPackageDomainLimitWarningEmailSubject; + } + + @Provides + @Config("bulkPricingPackageDomainLimitWarningEmailBody") + public static String provideBulkPricingPackageDomainLimitWarningEmailBody( + RegistryConfigSettings config) { + return config.bulkPricingPackageMonitoring.bulkPricingPackageDomainLimitWarningEmailBody; + } + + @Provides + @Config("bulkPricingPackageDomainLimitUpgradeEmailSubject") + public static String provideBulkPricingPackageDomainLimitUpgradeEmailSubject( + RegistryConfigSettings config) { + return config.bulkPricingPackageMonitoring.bulkPricingPackageDomainLimitUpgradeEmailSubject; + } + + @Provides + @Config("bulkPricingPackageDomainLimitUpgradeEmailBody") + public static String provideBulkPricingPackageDomainLimitUpgradeEmailBody( + RegistryConfigSettings config) { + return config.bulkPricingPackageMonitoring.bulkPricingPackageDomainLimitUpgradeEmailBody; } private static String formatComments(String text) { diff --git a/core/src/main/java/google/registry/config/RegistryConfigSettings.java b/core/src/main/java/google/registry/config/RegistryConfigSettings.java index 1c09af932..5cb630cdd 100644 --- a/core/src/main/java/google/registry/config/RegistryConfigSettings.java +++ b/core/src/main/java/google/registry/config/RegistryConfigSettings.java @@ -42,7 +42,7 @@ public class RegistryConfigSettings { public SslCertificateValidation sslCertificateValidation; public ContactHistory contactHistory; public DnsUpdate dnsUpdate; - public PackageMonitoring packageMonitoring; + public BulkPricingPackageMonitoring bulkPricingPackageMonitoring; /** Configuration options that apply to the entire GCP project. */ public static class GcpProject { @@ -253,13 +253,13 @@ public class RegistryConfigSettings { public String registryCcEmail; } - /** Configuration for package compliance monitoring. */ - public static class PackageMonitoring { - public String packageCreateLimitEmailSubject; - public String packageCreateLimitEmailBody; - public String packageDomainLimitWarningEmailSubject; - public String packageDomainLimitWarningEmailBody; - public String packageDomainLimitUpgradeEmailSubject; - public String packageDomainLimitUpgradeEmailBody; + /** Configuration for bulk pricing package compliance monitoring. */ + public static class BulkPricingPackageMonitoring { + public String bulkPricingPackageCreateLimitEmailSubject; + public String bulkPricingPackageCreateLimitEmailBody; + public String bulkPricingPackageDomainLimitWarningEmailSubject; + public String bulkPricingPackageDomainLimitWarningEmailBody; + public String bulkPricingPackageDomainLimitUpgradeEmailSubject; + public String bulkPricingPackageDomainLimitUpgradeEmailBody; } } diff --git a/core/src/main/java/google/registry/config/files/default-config.yaml b/core/src/main/java/google/registry/config/files/default-config.yaml index 165dd83af..35842416f 100644 --- a/core/src/main/java/google/registry/config/files/default-config.yaml +++ b/core/src/main/java/google/registry/config/files/default-config.yaml @@ -559,55 +559,55 @@ sslCertificateValidation: - secp256r1 - secp384r1 -# Configuration options for the package compliance monitoring -packageMonitoring: - # Email subject text to notify tech support that a package has exceeded the limit for domain creates - packageCreateLimitEmailSubject: "ACTION REQUIRED: Package needs to be upgraded" - # Email body text template notify support that a package has exceeded the limit for domain creates - packageCreateLimitEmailBody: > +# Configuration options for the bulk pricing package compliance monitoring +bulkPricingPackageMonitoring: + # Email subject text to notify tech support that a bulk pricing package has exceeded the limit for domain creates + bulkPricingPackageCreateLimitEmailSubject: "ACTION REQUIRED: Bulk pricing package needs to be upgraded" + # Email body text template notify support that a bulk pricing package has exceeded the limit for domain creates + bulkPricingPackageCreateLimitEmailBody: > Dear Support, - A package has exceeded its max create limit and needs to be upgraded to the + A bulk pricing package has exceeded its max create limit and needs to be upgraded to the next tier. - Package ID: %1$s - Package Token: %2$s + Bulk Pricing ID: %1$s + Bulk Token: %2$s Registrar: %3$s Current Max Create Limit: %4$s Creates Completed: %5$s - # Email subject text to notify support that a package has exceeded the limit + # Email subject text to notify support that a bulk pricing package has exceeded the limit # for current active domains and a warning needs to be sent - packageDomainLimitWarningEmailSubject: "ACTION REQUIRED: Package has exceeded the domain limit - send warning" - # Email body text template to inform support that a package has exceeded the - # limit for active domains and a warning needs to be sent that the package + bulkPricingPackageDomainLimitWarningEmailSubject: "ACTION REQUIRED: Bulk pricing package has exceeded the domain limit - send warning" + # Email body text template to inform support that a bulk pricing package has exceeded the + # limit for active domains and a warning needs to be sent that the bulk pricing package # will be upgraded in 30 days - packageDomainLimitWarningEmailBody: > + bulkPricingPackageDomainLimitWarningEmailBody: > Dear Support, - A package has exceeded its max domain limit. Please send a warning to the - registrar that their package will be upgraded to the next tier in 30 days if + A bulk pricing package has exceeded its max domain limit. Please send a warning to the + registrar that their bulk pricing package will be upgraded to the next tier in 30 days if the number of active domains does not return below the limit. - Package ID: %1$s - Package Token: %2$s + Bulk Pricing ID: %1$s + Bulk Token: %2$s Registrar: %3$s Active Domain Limit: %4$s Current Active Domains: %5$s - # Email subject text to notify support that a package has exceeded the limit + # Email subject text to notify support that a bulk pricing package has exceeded the limit # for current active domains for more than 30 days and needs to be upgraded - packageDomainLimitUpgradeEmailSubject: "ACTION REQUIRED: Package has exceeded the domain limit - upgrade package" - # Email body text template to inform support that a package has exceeded the + bulkPricingPackageDomainLimitUpgradeEmailSubject: "ACTION REQUIRED: Bulk pricing package has exceeded the domain limit - upgrade package" + # Email body text template to inform support that a bulk pricing package has exceeded the # limit for active domains for more than 30 days and needs to be upgraded - packageDomainLimitUpgradeEmailBody: > + bulkPricingPackageDomainLimitUpgradeEmailBody: > Dear Support, - A package has exceeded its max domain limit for over 30 days and needs to be + A bulk pricing package has exceeded its max domain limit for over 30 days and needs to be upgraded to the next tier. - Package ID: %1$s - Package Token: %2$s + Bulk Pricing ID: %1$s + Bulk Token: %2$s Registrar: %3$s Active Domain Limit: %4$s Current Active Domains: %5$s diff --git a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java index 2c0e99228..2537f93a3 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java @@ -152,7 +152,7 @@ import org.joda.time.Duration; * @error {@link DomainCreateFlow.MustHaveSignedMarksInCurrentPhaseException} * @error {@link DomainCreateFlow.NoGeneralRegistrationsInCurrentPhaseException} * @error {@link DomainCreateFlow.NoTrademarkedRegistrationsBeforeSunriseException} - * @error {@link DomainCreateFlow.PackageDomainRegisteredForTooManyYearsException} + * @error {@link BulkDomainRegisteredForTooManyYearsException} * @error {@link DomainCreateFlow.SignedMarksOnlyDuringSunriseException} * @error {@link DomainFlowTmchUtils.NoMarksFoundMatchingDomainException} * @error {@link DomainFlowTmchUtils.FoundMarkNotYetValidException} @@ -405,12 +405,11 @@ public final class DomainCreateFlow implements TransactionalFlow { : hasClaimsNotice ? LordnPhase.CLAIMS : LordnPhase.NONE); Domain domain = domainBuilder.build(); if (allocationToken.isPresent() - && allocationToken.get().getTokenType().equals(TokenType.PACKAGE)) { + && allocationToken.get().getTokenType().equals(TokenType.BULK_PRICING)) { if (years > 1) { - throw new PackageDomainRegisteredForTooManyYearsException(allocationToken.get().getToken()); + throw new BulkDomainRegisteredForTooManyYearsException(allocationToken.get().getToken()); } - domain = - domain.asBuilder().setCurrentPackageToken(allocationToken.get().createVKey()).build(); + domain = domain.asBuilder().setCurrentBulkToken(allocationToken.get().createVKey()).build(); } DomainHistory domainHistory = buildDomainHistory(domain, tld, now, period, tld.getAddGracePeriodLength()); @@ -763,13 +762,12 @@ public final class DomainCreateFlow implements TransactionalFlow { } } - /** Package domain registered for too many years. */ - static class PackageDomainRegisteredForTooManyYearsException extends CommandUseErrorException { - public PackageDomainRegisteredForTooManyYearsException(String token) { + /** Bulk pricing domain registered for too many years. */ + static class BulkDomainRegisteredForTooManyYearsException extends CommandUseErrorException { + public BulkDomainRegisteredForTooManyYearsException(String token) { super( String.format( - "The package token %s cannot be used to register names for longer than 1 year.", - token)); + "The bulk token %s cannot be used to register names for longer than 1 year.", token)); } } } diff --git a/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java b/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java index 8cdad04e9..8c3d4f9dd 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java @@ -155,13 +155,13 @@ public final class DomainInfoFlow implements Flow { if (!gracePeriodStatuses.isEmpty()) { extensions.add(RgpInfoExtension.create(gracePeriodStatuses)); } - Optional packageInfo = + Optional bulkPricingInfo = eppInput.getSingleExtension(BulkTokenExtension.class); - if (packageInfo.isPresent()) { - // Package info was requested. + if (bulkPricingInfo.isPresent()) { + // Bulk pricing info was requested. if (isSuperuser || registrarId.equals(domain.getCurrentSponsorRegistrarId())) { - // Only show package info to owning registrar or superusers - extensions.add(BulkTokenResponseExtension.create(domain.getCurrentPackageToken())); + // Only show bulk pricing info to owning registrar or superusers + extensions.add(BulkTokenResponseExtension.create(domain.getCurrentBulkToken())); } } Optional feeInfo = diff --git a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java index b97ded978..4d289c7ba 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java @@ -30,7 +30,7 @@ import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge; import static google.registry.flows.domain.DomainFlowUtils.validateRegistrationPeriod; import static google.registry.flows.domain.DomainFlowUtils.verifyRegistrarIsActive; import static google.registry.flows.domain.DomainFlowUtils.verifyUnitIsYears; -import static google.registry.flows.domain.token.AllocationTokenFlowUtils.maybeApplyPackageRemovalToken; +import static google.registry.flows.domain.token.AllocationTokenFlowUtils.maybeApplyBulkPricingRemovalToken; import static google.registry.flows.domain.token.AllocationTokenFlowUtils.verifyTokenAllowedOnDomain; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_RENEW; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -53,8 +53,8 @@ import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponseRet import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeSaveParameters; import google.registry.flows.custom.EntityChanges; import google.registry.flows.domain.token.AllocationTokenFlowUtils; -import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnPackageDomainException; -import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonPackageDomainException; +import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnBulkPricingDomainException; +import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonBulkPricingDomainException; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingBase.Reason; import google.registry.model.billing.BillingEvent; @@ -121,8 +121,8 @@ import org.joda.time.Duration; * @error {@link DomainFlowUtils.RegistrarMustBeActiveForThisOperationException} * @error {@link DomainFlowUtils.UnsupportedFeeAttributeException} * @error {@link DomainRenewFlow.IncorrectCurrentExpirationDateException} - * @error {@link MissingRemoveDomainTokenOnPackageDomainException} - * @error {@link RemoveDomainTokenOnNonPackageDomainException} + * @error {@link MissingRemoveDomainTokenOnBulkPricingDomainException} + * @error {@link RemoveDomainTokenOnNonBulkPricingDomainException} * @error {@link * google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForDomainException} * @error {@link @@ -194,7 +194,7 @@ public final class DomainRenewFlow implements TransactionalFlow { verifyRenewAllowed(authInfo, existingDomain, command, allocationToken); // If client passed an applicable static token this updates the domain - existingDomain = maybeApplyPackageRemovalToken(existingDomain, allocationToken); + existingDomain = maybeApplyBulkPricingRemovalToken(existingDomain, allocationToken); int years = command.getPeriod().getValue(); DateTime newExpirationTime = @@ -328,7 +328,7 @@ public final class DomainRenewFlow implements TransactionalFlow { checkHasBillingAccount(registrarId, existingDomain.getTld()); } verifyUnitIsYears(command.getPeriod()); - // We only allow __REMOVE_PACKAGE__ token on promo package domains for now + // We only allow __REMOVE_PACKAGE__ token on bulk pricing domains for now verifyTokenAllowedOnDomain(existingDomain, allocationToken); // If the date they specify doesn't match the expiration, fail. (This is an idempotence check). if (!command.getCurrentExpirationDate().equals( diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java index a5aa479f4..2d124d29f 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -154,9 +154,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { tm().loadByKey(existingDomain.getAutorenewBillingEvent()); HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain); historyBuilder.setRevisionId(domainHistoryId.getRevisionId()); - boolean hasPackageToken = existingDomain.getCurrentPackageToken().isPresent(); + boolean hasBulkToken = existingDomain.getCurrentBulkToken().isPresent(); Money renewalPrice = - hasPackageToken ? null : existingBillingRecurrence.getRenewalPrice().orElse(null); + hasBulkToken ? null : existingBillingRecurrence.getRenewalPrice().orElse(null); Optional billingEvent = transferData.getTransferPeriod().getValue() == 0 ? Optional.empty() @@ -172,10 +172,10 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { Tld.get(tldStr), targetId, transferData.getTransferRequestTime(), - // When removing a domain from a package it should return to the + // When removing a domain from bulk pricing it should return to the // default recurrence billing behavior so the existing recurrence // billing event should not be passed in. - hasPackageToken ? null : existingBillingRecurrence) + hasBulkToken ? null : existingBillingRecurrence) .getRenewCost()) .setEventTime(now) .setBillingTime(now.plus(Tld.get(tldStr).getTransferGracePeriodLength())) @@ -213,7 +213,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { .setRegistrarId(gainingRegistrarId) .setEventTime(newExpirationTime) .setRenewalPriceBehavior( - hasPackageToken + hasBulkToken ? RenewalPriceBehavior.DEFAULT : existingBillingRecurrence.getRenewalPriceBehavior()) .setRenewalPrice(renewalPrice) @@ -258,9 +258,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { .orElseGet(ImmutableSet::of)) .setLastEppUpdateTime(now) .setLastEppUpdateRegistrarId(registrarId) - // Even if the existing domain had a package token, that package token should be removed + // Even if the existing domain had a bulk token, that bulk token should be removed // on transfer - .setCurrentPackageToken(null) + .setCurrentBulkToken(null) .build(); Tld tld = Tld.get(existingDomain.getTld()); diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java index c250fd06d..1d12d64ec 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -201,11 +201,12 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { Optional feesAndCredits; if (period.getValue() == 0) { feesAndCredits = Optional.empty(); - } else if (!existingDomain.getCurrentPackageToken().isPresent()) { + } else if (!existingDomain.getCurrentBulkToken().isPresent()) { feesAndCredits = Optional.of(pricingLogic.getTransferPrice(tld, targetId, now, existingBillingRecurrence)); } else { - // If existing domain is in a package, calculate the transfer price with default renewal price + // If existing domain is in a bulk pricing package, calculate the transfer price with default + // renewal price // behavior feesAndCredits = period.getValue() == 0 diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java b/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java index 7b82b04e9..d190dcad9 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java @@ -146,7 +146,7 @@ public final class DomainTransferUtils { return builder .add( createGainingClientAutorenewEvent( - existingDomain.getCurrentPackageToken().isPresent() + existingDomain.getCurrentBulkToken().isPresent() ? existingBillingRecurrence .asBuilder() .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT) diff --git a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java index e24e5d158..dca4cc19e 100644 --- a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java @@ -242,19 +242,19 @@ public class AllocationTokenFlowUtils { public static void verifyTokenAllowedOnDomain( Domain domain, Optional allocationToken) throws EppException { - boolean domainHasPackageToken = domain.getCurrentPackageToken().isPresent(); + boolean domainHasBulkToken = domain.getCurrentBulkToken().isPresent(); boolean hasRemoveDomainToken = allocationToken.isPresent() && TokenBehavior.REMOVE_DOMAIN.equals(allocationToken.get().getTokenBehavior()); - if (hasRemoveDomainToken && !domainHasPackageToken) { - throw new RemoveDomainTokenOnNonPackageDomainException(); - } else if (!hasRemoveDomainToken && domainHasPackageToken) { - throw new MissingRemoveDomainTokenOnPackageDomainException(); + if (hasRemoveDomainToken && !domainHasBulkToken) { + throw new RemoveDomainTokenOnNonBulkPricingDomainException(); + } else if (!hasRemoveDomainToken && domainHasBulkToken) { + throw new MissingRemoveDomainTokenOnBulkPricingDomainException(); } } - public static Domain maybeApplyPackageRemovalToken( + public static Domain maybeApplyBulkPricingRemovalToken( Domain domain, Optional allocationToken) { if (!allocationToken.isPresent() || !TokenBehavior.REMOVE_DOMAIN.equals(allocationToken.get().getTokenBehavior())) { @@ -274,10 +274,10 @@ public class AllocationTokenFlowUtils { tm().getEntityManager().flush(); tm().getEntityManager().clear(); - // Remove current package token + // Remove current bulk token return domain .asBuilder() - .setCurrentPackageToken(null) + .setCurrentBulkToken(null) .setAutorenewBillingEvent(newBillingRecurrence.createVKey()) .build(); } @@ -338,19 +338,19 @@ public class AllocationTokenFlowUtils { } } - /** The __REMOVEDOMAIN__ token is missing on a package domain command */ - public static class MissingRemoveDomainTokenOnPackageDomainException + /** The __REMOVEDOMAIN__ token is missing on a bulk pricing domain command */ + public static class MissingRemoveDomainTokenOnBulkPricingDomainException extends AssociationProhibitsOperationException { - MissingRemoveDomainTokenOnPackageDomainException() { - super("Domains that are inside packages cannot be explicitly renewed or transferred"); + MissingRemoveDomainTokenOnBulkPricingDomainException() { + super("Domains that are inside bulk pricing cannot be explicitly renewed or transferred"); } } - /** The __REMOVEDOMAIN__ token is not allowed on non package domains */ - public static class RemoveDomainTokenOnNonPackageDomainException + /** The __REMOVEDOMAIN__ token is not allowed on non bulk pricing domains */ + public static class RemoveDomainTokenOnNonBulkPricingDomainException extends AssociationProhibitsOperationException { - RemoveDomainTokenOnNonPackageDomainException() { - super("__REMOVEDOMAIN__ token is not allowed on non package domains"); + RemoveDomainTokenOnNonBulkPricingDomainException() { + super("__REMOVEDOMAIN__ token is not allowed on non bulk pricing domains"); } } } diff --git a/core/src/main/java/google/registry/model/domain/Domain.java b/core/src/main/java/google/registry/model/domain/Domain.java index 5b7740f97..04194dfba 100644 --- a/core/src/main/java/google/registry/model/domain/Domain.java +++ b/core/src/main/java/google/registry/model/domain/Domain.java @@ -200,7 +200,7 @@ public class Domain extends DomainBase implements ForeignKeyedEppResource { .setStatusValues(domainBase.getStatusValues()) .setTransferData(domainBase.getTransferData()) .setLordnPhase(domainBase.getLordnPhase()) - .setCurrentPackageToken(domainBase.getCurrentPackageToken().orElse(null)); + .setCurrentBulkToken(domainBase.getCurrentBulkToken().orElse(null)); } } } diff --git a/core/src/main/java/google/registry/model/domain/DomainBase.java b/core/src/main/java/google/registry/model/domain/DomainBase.java index e062848df..95b84ff9c 100644 --- a/core/src/main/java/google/registry/model/domain/DomainBase.java +++ b/core/src/main/java/google/registry/model/domain/DomainBase.java @@ -267,8 +267,12 @@ public class DomainBase extends EppResource @Enumerated(EnumType.STRING) LordnPhase lordnPhase = LordnPhase.NONE; - /** The {@link AllocationToken} for the package this domain is currently a part of. */ - @Nullable VKey currentPackageToken; + /** + * The {@link AllocationToken} for the bulk pricing package this domain is currently a part of. + */ + @Nullable + @Column(name = "current_package_token") + VKey currentBulkToken; public LordnPhase getLordnPhase() { return lordnPhase; @@ -302,8 +306,8 @@ public class DomainBase extends EppResource return smdId; } - public Optional> getCurrentPackageToken() { - return Optional.ofNullable(currentPackageToken); + public Optional> getCurrentBulkToken() { + return Optional.ofNullable(currentBulkToken); } /** @@ -478,7 +482,7 @@ public class DomainBase extends EppResource // events. .setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent()) .setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage()) - .setCurrentPackageToken(null); + .setCurrentBulkToken(null); if (transferData.getTransferPeriod().getValue() == 1) { // Set the grace period using a key to the pre-scheduled transfer billing event. Not using // GracePeriod.forBillingEvent() here in order to avoid the actual fetch. @@ -910,23 +914,22 @@ public class DomainBase extends EppResource return thisCastToDerived(); } - public B setCurrentPackageToken(@Nullable VKey currentPackageToken) { - if (currentPackageToken == null) { - getInstance().currentPackageToken = currentPackageToken; + public B setCurrentBulkToken(@Nullable VKey currentBulkToken) { + if (currentBulkToken == null) { + getInstance().currentBulkToken = currentBulkToken; return thisCastToDerived(); } AllocationToken token = - tm().transact(() -> tm().loadByKeyIfPresent(currentPackageToken)) + tm().transact(() -> tm().loadByKeyIfPresent(currentBulkToken)) .orElseThrow( () -> new IllegalArgumentException( String.format( - "The package token %s does not exist", - currentPackageToken.getKey()))); + "The bulk token %s does not exist", currentBulkToken.getKey()))); checkArgument( - token.getTokenType().equals(TokenType.PACKAGE), - "The currentPackageToken must have a PACKAGE TokenType"); - getInstance().currentPackageToken = currentPackageToken; + token.getTokenType().equals(TokenType.BULK_PRICING), + "The currentBulkToken must have a BULK_PRICING TokenType"); + getInstance().currentBulkToken = currentBulkToken; return thisCastToDerived(); } } diff --git a/core/src/main/java/google/registry/model/domain/token/AllocationToken.java b/core/src/main/java/google/registry/model/domain/token/AllocationToken.java index d73c2aa90..e684ec897 100644 --- a/core/src/main/java/google/registry/model/domain/token/AllocationToken.java +++ b/core/src/main/java/google/registry/model/domain/token/AllocationToken.java @@ -119,9 +119,14 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda /** Type of the token that indicates how and where it should be used. */ public enum TokenType { + /** Token used for bulk pricing */ + BULK_PRICING, /** Token saved on a TLD to use if no other token is passed from the client */ DEFAULT_PROMO, - /** Token used for package pricing */ + /** This is the old name for what is now BULK_PRICING. */ + // TODO(sarahbot@): Remove this type once all tokens of this type have been scrubbed from the + // database + @Deprecated PACKAGE, /** Invalid after use */ SINGLE_USE, @@ -137,8 +142,8 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda /** No special behavior */ DEFAULT, /** - * REMOVE_DOMAIN triggers domain removal from promotional bulk (package) pricing, bypasses - * DEFAULT token validations. + * REMOVE_DOMAIN triggers domain removal from a bulk pricing package, bypasses DEFAULT token + * validations. */ REMOVE_DOMAIN } @@ -344,12 +349,13 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda checkArgumentNotNull(getInstance().tokenType, "Token type must be specified"); checkArgument(!Strings.isNullOrEmpty(getInstance().token), "Token must not be null or empty"); checkArgument( - !getInstance().tokenType.equals(TokenType.PACKAGE) + !getInstance().tokenType.equals(TokenType.BULK_PRICING) || getInstance().renewalPriceBehavior.equals(RenewalPriceBehavior.SPECIFIED), - "Package tokens must have renewalPriceBehavior set to SPECIFIED"); + "Bulk tokens must have renewalPriceBehavior set to SPECIFIED"); checkArgument( - !getInstance().tokenType.equals(TokenType.PACKAGE) || !getInstance().discountPremiums, - "Package tokens cannot discount premium names"); + !getInstance().tokenType.equals(TokenType.BULK_PRICING) + || !getInstance().discountPremiums, + "Bulk tokens cannot discount premium names"); checkArgument( getInstance().domainName == null || TokenType.SINGLE_USE.equals(getInstance().tokenType), "Domain name can only be specified for SINGLE_USE tokens"); @@ -358,10 +364,10 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda || TokenType.SINGLE_USE.equals(getInstance().tokenType), "Redemption history entry can only be specified for SINGLE_USE tokens"); checkArgument( - getInstance().tokenType != TokenType.PACKAGE + getInstance().tokenType != TokenType.BULK_PRICING || (getInstance().allowedClientIds != null && getInstance().allowedClientIds.size() == 1), - "PACKAGE tokens must have exactly one allowed client registrar"); + "BULK_PRICING tokens must have exactly one allowed client registrar"); checkArgument( getInstance().discountFraction > 0 || !getInstance().discountPremiums, "Discount premiums can only be specified along with a discount fraction"); diff --git a/core/src/main/java/google/registry/model/domain/token/PackagePromotion.java b/core/src/main/java/google/registry/model/domain/token/BulkPricingPackage.java similarity index 68% rename from core/src/main/java/google/registry/model/domain/token/PackagePromotion.java rename to core/src/main/java/google/registry/model/domain/token/BulkPricingPackage.java index 88af4471e..cfea6c055 100644 --- a/core/src/main/java/google/registry/model/domain/token/PackagePromotion.java +++ b/core/src/main/java/google/registry/model/domain/token/BulkPricingPackage.java @@ -36,46 +36,53 @@ import org.hibernate.annotations.Type; import org.joda.money.Money; import org.joda.time.DateTime; -/** An entity representing a package promotion. */ -@Entity +/** + * An entity representing a bulk pricing promotion. Note that this table is still called + * PackagePromotion in Cloud SQL. + */ +@Entity(name = "PackagePromotion") @javax.persistence.Table(indexes = {@javax.persistence.Index(columnList = "token")}) -public class PackagePromotion extends ImmutableObject implements Buildable { +public class BulkPricingPackage extends ImmutableObject implements Buildable { - /** An autogenerated identifier for the package promotion. */ + /** An autogenerated identifier for the bulk pricing promotion. */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - long packagePromotionId; + @Column(name = "package_promotion_id") + long bulkPricingId; - /** The allocation token string for the package. */ + /** The allocation token string for the bulk pricing package. */ @Column(nullable = false) VKey token; - /** The maximum number of active domains the package allows at any given time. */ + /** The maximum number of active domains the bulk pricing package allows at any given time. */ @Column(nullable = false) int maxDomains; - /** The maximum number of domains that can be created in the package each year. */ + /** The maximum number of domains that can be created in the bulk pricing package each year. */ @Column(nullable = false) int maxCreates; - /** The annual price of the package. */ + /** The annual price of the bulk pricing package. */ @Type(type = JodaMoneyType.TYPE_NAME) @Columns( columns = { @Column(name = "package_price_amount", nullable = false), @Column(name = "package_price_currency", nullable = false) }) - Money packagePrice; + Money bulkPrice; - /** The next billing date of the package. */ + /** The next billing date of the bulk pricing package. */ @Column(nullable = false) DateTime nextBillingDate = END_OF_TIME; - /** Date the last warning email was sent that the package has exceeded the maxDomains limit. */ + /** + * Date the last warning email was sent that the bulk pricing package has exceeded the maxDomains + * limit. + */ @Nullable DateTime lastNotificationSent; public long getId() { - return packagePromotionId; + return bulkPricingId; } public VKey getToken() { @@ -90,8 +97,8 @@ public class PackagePromotion extends ImmutableObject implements Buildable { return maxCreates; } - public Money getPackagePrice() { - return packagePrice; + public Money getBulkPrice() { + return bulkPrice; } public DateTime getNextBillingDate() { @@ -102,18 +109,18 @@ public class PackagePromotion extends ImmutableObject implements Buildable { return Optional.ofNullable(lastNotificationSent); } - /** Loads and returns a PackagePromotion entity by its token string directly from Cloud SQL. */ - public static Optional loadByTokenString(String tokenString) { + /** Loads and returns a BulkPricingPackage entity by its token string directly from Cloud SQL. */ + public static Optional loadByTokenString(String tokenString) { tm().assertInTransaction(); - return tm().query("FROM PackagePromotion WHERE token = :token", PackagePromotion.class) + return tm().query("FROM PackagePromotion WHERE token = :token", BulkPricingPackage.class) .setParameter("token", VKey.create(AllocationToken.class, tokenString)) .getResultStream() .findFirst(); } @Override - public VKey createVKey() { - return VKey.create(PackagePromotion.class, packagePromotionId); + public VKey createVKey() { + return VKey.create(BulkPricingPackage.class, bulkPricingId); } @Override @@ -121,28 +128,29 @@ public class PackagePromotion extends ImmutableObject implements Buildable { return new Builder(clone(this)); } - /** A builder for constructing {@link PackagePromotion} objects, since they are immutable. */ - public static class Builder extends Buildable.Builder { + /** A builder for constructing {@link BulkPricingPackage} objects, since they are immutable. */ + public static class Builder extends Buildable.Builder { public Builder() {} - private Builder(PackagePromotion instance) { + private Builder(BulkPricingPackage instance) { super(instance); } @Override - public PackagePromotion build() { + public BulkPricingPackage build() { checkArgumentNotNull(getInstance().token, "Allocation token must be specified"); AllocationToken allocationToken = tm().transact(() -> tm().loadByKey(getInstance().token)); checkArgument( - allocationToken.tokenType == TokenType.PACKAGE, - "Allocation token must be a PACKAGE type"); + allocationToken.tokenType == TokenType.BULK_PRICING, + "Allocation token must be a BULK_PRICING type"); return super.build(); } public Builder setToken(AllocationToken token) { checkArgumentNotNull(token, "Allocation token must not be null"); checkArgument( - token.tokenType == TokenType.PACKAGE, "Allocation token must be a PACKAGE type"); + token.tokenType == TokenType.BULK_PRICING, + "Allocation token must be a BULK_PRICING type"); getInstance().token = token.createVKey(); return this; } @@ -159,9 +167,9 @@ public class PackagePromotion extends ImmutableObject implements Buildable { return this; } - public Builder setPackagePrice(Money packagePrice) { - checkArgumentNotNull(packagePrice, "Package price must not be null"); - getInstance().packagePrice = packagePrice; + public Builder setBulkPrice(Money bulkPrice) { + checkArgumentNotNull(bulkPrice, "Bulk price must not be null"); + getInstance().bulkPrice = bulkPrice; return this; } diff --git a/core/src/main/java/google/registry/tools/CreatePackagePromotionCommand.java b/core/src/main/java/google/registry/tools/CreateBulkPricingPackageCommand.java similarity index 61% rename from core/src/main/java/google/registry/tools/CreatePackagePromotionCommand.java rename to core/src/main/java/google/registry/tools/CreateBulkPricingPackageCommand.java index ff68a1f28..317ee1476 100644 --- a/core/src/main/java/google/registry/tools/CreatePackagePromotionCommand.java +++ b/core/src/main/java/google/registry/tools/CreateBulkPricingPackageCommand.java @@ -16,23 +16,23 @@ package google.registry.tools; import static com.google.common.base.Preconditions.checkArgument; import com.beust.jcommander.Parameters; -import google.registry.model.domain.token.PackagePromotion; +import google.registry.model.domain.token.BulkPricingPackage; import org.jetbrains.annotations.Nullable; -/** Command to create a PackagePromotion */ +/** Command to create a {@link BulkPricingPackage} */ @Parameters( separators = " =", commandDescription = - "Create new package promotion object(s) for registrars to register multiple names under" - + " one contractual annual package price using a package allocation token") -public final class CreatePackagePromotionCommand extends CreateOrUpdatePackagePromotionCommand { + "Create new bulk pricing package object(s) for registrars to register multiple names under" + + " one contractual annual bulk price using a bulk pricing allocation token") +public final class CreateBulkPricingPackageCommand extends CreateOrUpdateBulkPricingPackageCommand { @Nullable @Override - PackagePromotion getOldPackagePromotion(String tokenString) { + BulkPricingPackage getOldBulkPricingPackage(String tokenString) { checkArgument( - !PackagePromotion.loadByTokenString(tokenString).isPresent(), - "PackagePromotion with token %s already exists", + !BulkPricingPackage.loadByTokenString(tokenString).isPresent(), + "BulkPricingPackage with token %s already exists", tokenString); return null; } diff --git a/core/src/main/java/google/registry/tools/CreateOrUpdatePackagePromotionCommand.java b/core/src/main/java/google/registry/tools/CreateOrUpdateBulkPricingPackageCommand.java similarity index 65% rename from core/src/main/java/google/registry/tools/CreateOrUpdatePackagePromotionCommand.java rename to core/src/main/java/google/registry/tools/CreateOrUpdateBulkPricingPackageCommand.java index 18376b6f0..3fdd65e12 100644 --- a/core/src/main/java/google/registry/tools/CreateOrUpdatePackagePromotionCommand.java +++ b/core/src/main/java/google/registry/tools/CreateOrUpdateBulkPricingPackageCommand.java @@ -20,7 +20,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory. import com.beust.jcommander.Parameter; import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenType; -import google.registry.model.domain.token.PackagePromotion; +import google.registry.model.domain.token.BulkPricingPackage; import google.registry.persistence.VKey; import java.util.Date; import java.util.List; @@ -29,39 +29,40 @@ import javax.annotation.Nullable; import org.joda.money.Money; import org.joda.time.DateTime; -/** Shared base class for commands to create or update a PackagePromotion object. */ -abstract class CreateOrUpdatePackagePromotionCommand extends MutatingCommand { +/** Shared base class for commands to create or update a {@link BulkPricingPackage} object. */ +abstract class CreateOrUpdateBulkPricingPackageCommand extends MutatingCommand { - @Parameter(description = "Allocation token String of the package token", required = true) + @Parameter(description = "Allocation token String of the bulk token", required = true) List mainParameters; @Nullable @Parameter( names = {"-d", "--max_domains"}, - description = "Maximum concurrent active domains allowed in the package") + description = "Maximum concurrent active domains allowed in the bulk pricing package") Integer maxDomains; @Nullable @Parameter( names = {"-c", "--max_creates"}, - description = "Maximum domain creations allowed in the package each year") + description = "Maximum domain creations allowed in the bulk pricing package each year") Integer maxCreates; @Nullable @Parameter( names = {"-p", "--price"}, - description = "Annual price of the package") + description = "Annual price of the bulk pricing package") Money price; @Nullable @Parameter( names = "--next_billing_date", - description = "The next date that the package should be billed for its annual fee") + description = + "The next date that the bulk pricing package should be billed for its annual fee") Date nextBillingDate; - /** Returns the existing PackagePromotion or null if it does not exist. */ + /** Returns the existing BulkPricingPackage or null if it does not exist. */ @Nullable - abstract PackagePromotion getOldPackagePromotion(String token); + abstract BulkPricingPackage getOldBulkPricingPackage(String token); /** Returns the allocation token object. */ AllocationToken getAndCheckAllocationToken(String token) { @@ -69,12 +70,12 @@ abstract class CreateOrUpdatePackagePromotionCommand extends MutatingCommand { tm().transact(() -> tm().loadByKeyIfPresent(VKey.create(AllocationToken.class, token))); checkArgument( allocationToken.isPresent(), - "An allocation token with the token String %s does not exist. The package token must be" - + " created first before it can be used to create a PackagePromotion", + "An allocation token with the token String %s does not exist. The bulk token must be" + + " created first before it can be used to create a BulkPricingPackage", token); checkArgument( - allocationToken.get().getTokenType().equals(TokenType.PACKAGE), - "The allocation token must be of the PACKAGE token type"); + allocationToken.get().getTokenType().equals(TokenType.BULK_PRICING), + "The allocation token must be of the BULK_PRICING token type"); return allocationToken.get(); } @@ -88,21 +89,21 @@ abstract class CreateOrUpdatePackagePromotionCommand extends MutatingCommand { for (String token : mainParameters) { tm().transact( () -> { - PackagePromotion oldPackage = getOldPackagePromotion(token); + BulkPricingPackage oldBulkPricingPackage = getOldBulkPricingPackage(token); checkArgument( - oldPackage != null || price != null, - "PackagePrice is required when creating a new package"); + oldBulkPricingPackage != null || price != null, + "BulkPrice is required when creating a new bulk pricing package"); AllocationToken allocationToken = getAndCheckAllocationToken(token); - PackagePromotion.Builder builder = - (oldPackage == null) - ? new PackagePromotion.Builder().setToken(allocationToken) - : oldPackage.asBuilder(); + BulkPricingPackage.Builder builder = + (oldBulkPricingPackage == null) + ? new BulkPricingPackage.Builder().setToken(allocationToken) + : oldBulkPricingPackage.asBuilder(); Optional.ofNullable(maxDomains).ifPresent(builder::setMaxDomains); Optional.ofNullable(maxCreates).ifPresent(builder::setMaxCreates); - Optional.ofNullable(price).ifPresent(builder::setPackagePrice); + Optional.ofNullable(price).ifPresent(builder::setBulkPrice); Optional.ofNullable(nextBillingDate) .ifPresent( nextBillingDate -> @@ -110,8 +111,8 @@ abstract class CreateOrUpdatePackagePromotionCommand extends MutatingCommand { if (clearLastNotificationSent()) { builder.setLastNotificationSent(null); } - PackagePromotion newPackage = builder.build(); - stageEntityChange(oldPackage, newPackage); + BulkPricingPackage newBUlkPricingPackage = builder.build(); + stageEntityChange(oldBulkPricingPackage, newBUlkPricingPackage); }); } } diff --git a/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java b/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java index 113561926..15771c9ee 100644 --- a/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java @@ -18,8 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.Sets.difference; import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.DEFAULT; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -279,19 +279,20 @@ class GenerateAllocationTokensCommand implements Command { } if (!isNullOrEmpty(tokenStatusTransitions)) { - // Don't allow package tokens to be created with a scheduled end time since this could allow - // future domains to be attributed to the package and never be billed. Package promotion + // Don't allow bulk tokens to be created with a scheduled end time since this could allow + // future domains to be attributed to the bulk pricing package and never be billed. Bulk // tokens should only be scheduled to end with a brief time period before the status // transition occurs so that no new domains are registered using that token between when the // status is scheduled and when the transition occurs. - // TODO(@sarahbot): Create a cleaner way to handle ending packages once we actually have - // customers using them + // TODO(@sarahbot): Create a cleaner way to handle ending bulk pricing packages once we + // actually have customers using them boolean hasEnding = tokenStatusTransitions.containsValue(TokenStatus.ENDED) || tokenStatusTransitions.containsValue(TokenStatus.CANCELLED); checkArgument( - !(PACKAGE.equals(tokenType) && hasEnding), - "PACKAGE tokens should not be generated with ENDED or CANCELLED in their transition map"); + !(BULK_PRICING.equals(tokenType) && hasEnding), + "BULK_PRICING tokens should not be generated with ENDED or CANCELLED in their transition" + + " map"); } if (tokenStrings != null) { diff --git a/core/src/main/java/google/registry/tools/GetPackagePromotionCommand.java b/core/src/main/java/google/registry/tools/GetBulkPricingPackageCommand.java similarity index 65% rename from core/src/main/java/google/registry/tools/GetPackagePromotionCommand.java rename to core/src/main/java/google/registry/tools/GetBulkPricingPackageCommand.java index a0f806bc1..6f5d08f03 100644 --- a/core/src/main/java/google/registry/tools/GetPackagePromotionCommand.java +++ b/core/src/main/java/google/registry/tools/GetBulkPricingPackageCommand.java @@ -19,14 +19,14 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import google.registry.model.domain.token.PackagePromotion; +import google.registry.model.domain.token.BulkPricingPackage; import java.util.List; -/** Command to show a {@link PackagePromotion} object. */ -@Parameters(separators = " =", commandDescription = "Show package promotion object(s)") -public class GetPackagePromotionCommand extends GetEppResourceCommand { +/** Command to show a {@link BulkPricingPackage} object. */ +@Parameters(separators = " =", commandDescription = "Show bulk pricing package object(s)") +public class GetBulkPricingPackageCommand extends GetEppResourceCommand { - @Parameter(description = "Package token(s)", required = true) + @Parameter(description = "Bulk pricing token(s)", required = true) private List mainParameters; @Override @@ -34,12 +34,12 @@ public class GetPackagePromotionCommand extends GetEppResourceCommand { for (String token : mainParameters) { tm().transact( () -> { - PackagePromotion packagePromotion = + BulkPricingPackage bulkPricingPackage = checkArgumentPresent( - PackagePromotion.loadByTokenString(token), - "PackagePromotion with package token %s does not exist", + BulkPricingPackage.loadByTokenString(token), + "BulkPricingPackage with token %s does not exist", token); - System.out.println(packagePromotion); + System.out.println(bulkPricingPackage); }); } } diff --git a/core/src/main/java/google/registry/tools/RegistryTool.java b/core/src/main/java/google/registry/tools/RegistryTool.java index 53ffaf4ff..2971f2b48 100644 --- a/core/src/main/java/google/registry/tools/RegistryTool.java +++ b/core/src/main/java/google/registry/tools/RegistryTool.java @@ -36,6 +36,7 @@ public final class RegistryTool { .put("convert_idn", ConvertIdnCommand.class) .put("count_domains", CountDomainsCommand.class) .put("create_anchor_tenant", CreateAnchorTenantCommand.class) + .put("create_bulk_pricing_package", CreateBulkPricingPackageCommand.class) .put( "create_cancellations_for_billing_events", CreateCancellationsForBillingEventsCommand.class) @@ -43,7 +44,6 @@ public final class RegistryTool { .put("create_contact", CreateContactCommand.class) .put("create_domain", CreateDomainCommand.class) .put("create_host", CreateHostCommand.class) - .put("create_package_promotion", CreatePackagePromotionCommand.class) .put("create_premium_list", CreatePremiumListCommand.class) .put("create_registrar", CreateRegistrarCommand.class) .put("create_registrar_groups", CreateRegistrarGroupsCommand.class) @@ -67,13 +67,13 @@ public final class RegistryTool { .put("generate_lordn", GenerateLordnCommand.class) .put("generate_zone_files", GenerateZoneFilesCommand.class) .put("get_allocation_token", GetAllocationTokenCommand.class) + .put("get_bulk_pricing_package", GetBulkPricingPackageCommand.class) .put("get_claims_list", GetClaimsListCommand.class) .put("get_contact", GetContactCommand.class) .put("get_domain", GetDomainCommand.class) .put("get_history_entries", GetHistoryEntriesCommand.class) .put("get_host", GetHostCommand.class) .put("get_keyring_secret", GetKeyringSecretCommand.class) - .put("get_package_promotion", GetPackagePromotionCommand.class) .put("get_premium_list", GetPremiumListCommand.class) .put("get_registrar", GetRegistrarCommand.class) .put("get_reserved_list", GetReservedListCommand.class) @@ -104,10 +104,10 @@ public final class RegistryTool { .put("unlock_domain", UnlockDomainCommand.class) .put("unrenew_domain", UnrenewDomainCommand.class) .put("update_allocation_tokens", UpdateAllocationTokensCommand.class) + .put("update_bulk_pricing_package", UpdateBulkPricingPackageCommand.class) .put("update_cursors", UpdateCursorsCommand.class) .put("update_domain", UpdateDomainCommand.class) .put("update_keyring_secret", UpdateKeyringSecretCommand.class) - .put("update_package_promotion", UpdatePackagePromotionCommand.class) .put("update_premium_list", UpdatePremiumListCommand.class) .put("update_recurrence", UpdateRecurrenceCommand.class) .put("update_registrar", UpdateRegistrarCommand.class) diff --git a/core/src/main/java/google/registry/tools/RegistryToolComponent.java b/core/src/main/java/google/registry/tools/RegistryToolComponent.java index 3cd155f56..ca50eafa4 100644 --- a/core/src/main/java/google/registry/tools/RegistryToolComponent.java +++ b/core/src/main/java/google/registry/tools/RegistryToolComponent.java @@ -120,7 +120,7 @@ interface RegistryToolComponent { void inject(GetHostCommand command); - void inject(GetPackagePromotionCommand command); + void inject(GetBulkPricingPackageCommand command); void inject(GetKeyringSecretCommand command); diff --git a/core/src/main/java/google/registry/tools/UpdateAllocationTokensCommand.java b/core/src/main/java/google/registry/tools/UpdateAllocationTokensCommand.java index 0b2325d47..9435dd884 100644 --- a/core/src/main/java/google/registry/tools/UpdateAllocationTokensCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateAllocationTokensCommand.java @@ -169,18 +169,18 @@ final class UpdateAllocationTokensCommand extends UpdateOrDeleteAllocationTokens } private AllocationToken updateToken(AllocationToken original) { - if (endToken && original.getTokenType().equals(TokenType.PACKAGE)) { - Long domainsInPackage = - tm().query("SELECT COUNT(*) FROM Domain WHERE currentPackageToken = :token", Long.class) + if (endToken && original.getTokenType().equals(TokenType.BULK_PRICING)) { + Long domainsInBulkPackage = + tm().query("SELECT COUNT(*) FROM Domain WHERE currentBulkToken = :token", Long.class) .setParameter("token", original.createVKey()) .getSingleResult(); checkArgument( - domainsInPackage == 0, - "Package token %s can not end its promotion because it still has %s domains in the" - + " package", + domainsInBulkPackage == 0, + "Bulk token %s can not end its promotion because it still has %s domains in the" + + " promotion", original.getToken(), - domainsInPackage); + domainsInBulkPackage); } AllocationToken.Builder builder = original.asBuilder(); Optional.ofNullable(allowedClientIds) diff --git a/core/src/main/java/google/registry/tools/UpdatePackagePromotionCommand.java b/core/src/main/java/google/registry/tools/UpdateBulkPricingPackageCommand.java similarity index 64% rename from core/src/main/java/google/registry/tools/UpdatePackagePromotionCommand.java rename to core/src/main/java/google/registry/tools/UpdateBulkPricingPackageCommand.java index adade8cbe..74f7cc10a 100644 --- a/core/src/main/java/google/registry/tools/UpdatePackagePromotionCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateBulkPricingPackageCommand.java @@ -17,12 +17,12 @@ import static com.google.common.base.Preconditions.checkArgument; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import google.registry.model.domain.token.PackagePromotion; +import google.registry.model.domain.token.BulkPricingPackage; import java.util.Optional; -/** Command to update a PackagePromotion */ -@Parameters(separators = " =", commandDescription = "Update package promotion object(s)") -public final class UpdatePackagePromotionCommand extends CreateOrUpdatePackagePromotionCommand { +/** Command to update a {@link BulkPricingPackage} */ +@Parameters(separators = " =", commandDescription = "Update bulk pricing package object(s)") +public final class UpdateBulkPricingPackageCommand extends CreateOrUpdateBulkPricingPackageCommand { @Parameter( names = "--clear_last_notification_sent", @@ -32,10 +32,14 @@ public final class UpdatePackagePromotionCommand extends CreateOrUpdatePackagePr boolean clearLastNotificationSent; @Override - PackagePromotion getOldPackagePromotion(String token) { - Optional oldPackage = PackagePromotion.loadByTokenString(token); - checkArgument(oldPackage.isPresent(), "PackagePromotion with token %s does not exist", token); - return oldPackage.get(); + BulkPricingPackage getOldBulkPricingPackage(String token) { + Optional oldBulkPricingPackage = + BulkPricingPackage.loadByTokenString(token); + checkArgument( + oldBulkPricingPackage.isPresent(), + "BulkPricingPackage with token %s does not exist", + token); + return oldBulkPricingPackage.get(); } @Override diff --git a/core/src/main/resources/META-INF/persistence.xml b/core/src/main/resources/META-INF/persistence.xml index 35b702ade..db36beea4 100644 --- a/core/src/main/resources/META-INF/persistence.xml +++ b/core/src/main/resources/META-INF/persistence.xml @@ -53,7 +53,7 @@ google.registry.model.domain.secdns.DomainDsData google.registry.model.domain.secdns.DomainDsDataHistory google.registry.model.domain.token.AllocationToken - google.registry.model.domain.token.PackagePromotion + google.registry.model.domain.token.BulkPricingPackage google.registry.model.host.HostHistory google.registry.model.host.Host google.registry.model.poll.PollMessage diff --git a/core/src/test/java/google/registry/batch/CheckPackagesComplianceActionTest.java b/core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java similarity index 68% rename from core/src/test/java/google/registry/batch/CheckPackagesComplianceActionTest.java rename to core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java index 25469f048..d4c2a6d31 100644 --- a/core/src/test/java/google/registry/batch/CheckPackagesComplianceActionTest.java +++ b/core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java @@ -32,7 +32,7 @@ import google.registry.model.billing.BillingBase.RenewalPriceBehavior; import google.registry.model.contact.Contact; import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenType; -import google.registry.model.domain.token.PackagePromotion; +import google.registry.model.domain.token.BulkPricingPackage; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.DatabaseHelper; @@ -53,8 +53,8 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.ArgumentCaptor; import org.testcontainers.shaded.com.google.common.collect.ImmutableSet; -/** Unit tests for {@link CheckPackagesComplianceAction}. */ -public class CheckPackagesComplianceActionTest { +/** Unit tests for {@link CheckBulkComplianceAction}. */ +public class CheckBulkComplianceActionTest { // This is the default creation time for test data. private final FakeClock clock = new FakeClock(DateTime.parse("2012-03-25TZ")); private static final String CREATE_LIMIT_EMAIL_SUBJECT = "create limit subject"; @@ -72,14 +72,14 @@ public class CheckPackagesComplianceActionTest { final JpaIntegrationTestExtension jpa = new JpaTestExtensions.Builder().withClock(clock).buildIntegrationTestExtension(); - private CheckPackagesComplianceAction action; + private CheckBulkComplianceAction action; private AllocationToken token; private final TestLogHandler logHandler = new TestLogHandler(); private final Logger loggerToIntercept = - Logger.getLogger(CheckPackagesComplianceAction.class.getCanonicalName()); + Logger.getLogger(CheckBulkComplianceAction.class.getCanonicalName()); private final SendEmailService emailService = mock(SendEmailService.class); private Contact contact; - private PackagePromotion packagePromotion; + private BulkPricingPackage bulkPricingPackage; private SendEmailUtils sendEmailUtils; private ArgumentCaptor emailCaptor = ArgumentCaptor.forClass(EmailMessage.class); @@ -94,7 +94,7 @@ public class CheckPackagesComplianceActionTest { emailService); createTld("tld"); action = - new CheckPackagesComplianceAction( + new CheckBulkComplianceAction( sendEmailUtils, clock, CREATE_LIMIT_EMAIL_SUBJECT, @@ -108,19 +108,19 @@ public class CheckPackagesComplianceActionTest { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - packagePromotion = - new PackagePromotion.Builder() + bulkPricingPackage = + new BulkPricingPackage.Builder() .setToken(token) .setMaxDomains(3) .setMaxCreates(1) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z")) .setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z")) .build(); @@ -134,46 +134,48 @@ public class CheckPackagesComplianceActionTest { } @Test - void testSuccess_noPackageOverCreateLimit() { - tm().transact(() -> tm().put(packagePromotion)); + void testSuccess_noBulkPackageOverCreateLimit() { + tm().transact(() -> tm().put(bulkPricingPackage)); persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); action.run(); verifyNoInteractions(emailService); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found no packages over their create limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found no bulk pricing packages over their create limit."); } @Test - void testSuccess_onePackageOverCreateLimit() throws Exception { - tm().transact(() -> tm().put(packagePromotion)); + void testSuccess_oneBulkPackageOverCreateLimit() throws Exception { + tm().transact(() -> tm().put(bulkPricingPackage)); // Create limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 1 packages over their create limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 1 bulk pricing packages over their create limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceeded their max domain creation limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceeded their max domain creation" + + " limit by 1 name(s)."); verify(emailService).sendEmail(emailCaptor.capture()); EmailMessage emailMessage = emailCaptor.getValue(); assertThat(emailMessage.subject()).isEqualTo(CREATE_LIMIT_EMAIL_SUBJECT); @@ -182,92 +184,93 @@ public class CheckPackagesComplianceActionTest { } @Test - void testSuccess_multiplePackagesOverCreateLimit() { - tm().transact(() -> tm().put(packagePromotion)); + void testSuccess_multipleBulkPricingPackagesOverCreateLimit() { + tm().transact(() -> tm().put(bulkPricingPackage)); // Create limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); AllocationToken token2 = persistResource( new AllocationToken.Builder() .setToken("token") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - PackagePromotion packagePromotion2 = - new PackagePromotion.Builder() + BulkPricingPackage bulkPricingPackage2 = + new BulkPricingPackage.Builder() .setToken(token2) .setMaxDomains(8) .setMaxCreates(1) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z")) .build(); - tm().transact(() -> tm().put(packagePromotion2)); + tm().transact(() -> tm().put(bulkPricingPackage2)); persistEppResource( DatabaseHelper.newDomain("foo2.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz2.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 2 packages over their create limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 2 bulk pricing packages over their create limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceeded their max domain creation limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceeded their max domain creation" + + " limit by 1 name(s)."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token token has exceeded their max domain creation limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token token has exceeded their max domain creation" + + " limit by 1 name(s)."); verify(emailService, times(2)).sendEmail(any(EmailMessage.class)); } @Test void testSuccess_onlyChecksCurrentBillingYear() { - tm().transact(() -> tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); AllocationToken token2 = persistResource( new AllocationToken.Builder() .setToken("token") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - PackagePromotion packagePromotion2 = - new PackagePromotion.Builder() + BulkPricingPackage packagePromotion2 = + new BulkPricingPackage.Builder() .setToken(token2) .setMaxDomains(8) .setMaxCreates(1) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2015-11-12T05:00:00Z")) .build(); tm().transact(() -> tm().put(packagePromotion2)); @@ -276,289 +279,300 @@ public class CheckPackagesComplianceActionTest { persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found no packages over their create limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found no bulk pricing packages over their create limit."); verifyNoInteractions(emailService); } @Test - void testSuccess_noPackageOverActiveDomainsLimit() { - tm().transact(() -> tm().put(packagePromotion)); + void testSuccess_noBulkPricingPackageOverActiveDomainsLimit() { + tm().transact(() -> tm().put(bulkPricingPackage)); persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); action.run(); verifyNoInteractions(emailService); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found no packages over their active domains limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found no bulk pricing packages over their active domains limit."); } @Test - void testSuccess_onePackageOverActiveDomainsLimit() { - packagePromotion = packagePromotion.asBuilder().setMaxCreates(4).setMaxDomains(1).build(); - tm().transact(() -> tm().put(packagePromotion)); + void testSuccess_oneBulkPricingPackageOverActiveDomainsLimit() { + bulkPricingPackage = bulkPricingPackage.asBuilder().setMaxCreates(4).setMaxDomains(1).build(); + tm().transact(() -> tm().put(bulkPricingPackage)); // Domains limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); AllocationToken token2 = persistResource( new AllocationToken.Builder() .setToken("token") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - PackagePromotion packagePromotion2 = - new PackagePromotion.Builder() + BulkPricingPackage bulkPricingPackage2 = + new BulkPricingPackage.Builder() .setToken(token2) .setMaxDomains(8) .setMaxCreates(4) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z")) .build(); - tm().transact(() -> tm().put(packagePromotion2)); + tm().transact(() -> tm().put(bulkPricingPackage2)); persistEppResource( DatabaseHelper.newDomain("foo2.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 1 packages over their active domains limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 1 bulk pricing packages over their active domains limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceed their max active domains limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceed their max active domains limit" + + " by 1 name(s)."); verify(emailService).sendEmail(emailCaptor.capture()); EmailMessage emailMessage = emailCaptor.getValue(); assertThat(emailMessage.subject()).isEqualTo(DOMAIN_LIMIT_WARNING_EMAIL_SUBJECT); assertThat(emailMessage.body()) .isEqualTo( String.format(DOMAIN_LIMIT_WARNING_EMAIL_BODY, 1, "abc123", "The Registrar", 1, 2)); - PackagePromotion packageAfterCheck = - tm().transact(() -> PackagePromotion.loadByTokenString(token.getToken()).get()); + BulkPricingPackage packageAfterCheck = + tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get()); assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.nowUtc()); } @Test - void testSuccess_multiplePackagesOverActiveDomainsLimit() { + void testSuccess_multipleBulkPricingPackagesOverActiveDomainsLimit() { tm().transact( - () -> tm().put(packagePromotion.asBuilder().setMaxDomains(1).setMaxCreates(4).build())); + () -> + tm().put(bulkPricingPackage.asBuilder().setMaxDomains(1).setMaxCreates(4).build())); // Domains limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); AllocationToken token2 = persistResource( new AllocationToken.Builder() .setToken("token") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - PackagePromotion packagePromotion2 = - new PackagePromotion.Builder() + BulkPricingPackage bulkPricingPackage2 = + new BulkPricingPackage.Builder() .setToken(token2) .setMaxDomains(1) .setMaxCreates(5) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z")) .build(); - tm().transact(() -> tm().put(packagePromotion2)); + tm().transact(() -> tm().put(bulkPricingPackage2)); persistEppResource( DatabaseHelper.newDomain("foo2.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz2.tld", contact) .asBuilder() - .setCurrentPackageToken(token2.createVKey()) + .setCurrentBulkToken(token2.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 2 packages over their active domains limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 2 bulk pricing packages over their active domains limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceed their max active domains limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceed their max active domains limit" + + " by 1 name(s)."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token token has exceed their max active domains limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token token has exceed their max active domains limit" + + " by 1 name(s)."); verify(emailService, times(2)).sendEmail(any(EmailMessage.class)); } @Test - void testSuccess_packageOverActiveDomainsLimitAlreadySentWarningEmail_DoesNotSendAgain() { - packagePromotion = - packagePromotion + void + testSuccess_bulkPricingPackageOverActiveDomainsLimitAlreadySentWarningEmail_DoesNotSendAgain() { + bulkPricingPackage = + bulkPricingPackage .asBuilder() .setMaxCreates(4) .setMaxDomains(1) .setLastNotificationSent(clock.nowUtc().minusDays(5)) .build(); - tm().transact(() -> tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); // Domains limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 1 packages over their active domains limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 1 bulk pricing packages over their active domains limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceed their max active domains limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceed their max active domains limit" + + " by 1 name(s)."); verifyNoInteractions(emailService); - PackagePromotion packageAfterCheck = - tm().transact(() -> PackagePromotion.loadByTokenString(token.getToken()).get()); + BulkPricingPackage packageAfterCheck = + tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get()); assertThat(packageAfterCheck.getLastNotificationSent().get()) .isEqualTo(clock.nowUtc().minusDays(5)); } @Test - void testSuccess_packageOverActiveDomainsLimitAlreadySentWarningEmailOver40DaysAgo_SendsAgain() { - packagePromotion = - packagePromotion + void + testSuccess_bulkPricingPackageOverActiveDomainsLimitAlreadySentWarningEmailOver40DaysAgo_SendsAgain() { + bulkPricingPackage = + bulkPricingPackage .asBuilder() .setMaxCreates(4) .setMaxDomains(1) .setLastNotificationSent(clock.nowUtc().minusDays(45)) .build(); - tm().transact(() -> tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); // Domains limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 1 packages over their active domains limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 1 bulk pricing packages over their active domains limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceed their max active domains limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceed their max active domains limit" + + " by 1 name(s)."); verify(emailService).sendEmail(emailCaptor.capture()); EmailMessage emailMessage = emailCaptor.getValue(); assertThat(emailMessage.subject()).isEqualTo(DOMAIN_LIMIT_WARNING_EMAIL_SUBJECT); assertThat(emailMessage.body()) .isEqualTo( String.format(DOMAIN_LIMIT_WARNING_EMAIL_BODY, 1, "abc123", "The Registrar", 1, 2)); - PackagePromotion packageAfterCheck = - tm().transact(() -> PackagePromotion.loadByTokenString(token.getToken()).get()); + BulkPricingPackage packageAfterCheck = + tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get()); assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.nowUtc()); } @Test - void testSuccess_packageOverActiveDomainsLimitAlreadySentWarning30DaysAgo_SendsUpgradeEmail() { - packagePromotion = - packagePromotion + void + testSuccess_bulkPricingPackageOverActiveDomainsLimitAlreadySentWarning30DaysAgo_SendsUpgradeEmail() { + bulkPricingPackage = + bulkPricingPackage .asBuilder() .setMaxCreates(4) .setMaxDomains(1) .setLastNotificationSent(clock.nowUtc().minusDays(31)) .build(); - tm().transact(() -> tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); // Domains limit is 1, creating 2 domains to go over the limit persistEppResource( DatabaseHelper.newDomain("foo.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); persistEppResource( DatabaseHelper.newDomain("buzz.tld", contact) .asBuilder() - .setCurrentPackageToken(token.createVKey()) + .setCurrentBulkToken(token.createVKey()) .build()); action.run(); assertAboutLogs() .that(logHandler) - .hasLogAtLevelWithMessage(Level.INFO, "Found 1 packages over their active domains limit."); + .hasLogAtLevelWithMessage( + Level.INFO, "Found 1 bulk pricing packages over their active domains limit."); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.INFO, - "Package with package token abc123 has exceed their max active domains limit by 1" - + " name(s)."); + "Bulk pricing package with bulk token abc123 has exceed their max active domains limit" + + " by 1 name(s)."); verify(emailService).sendEmail(emailCaptor.capture()); EmailMessage emailMessage = emailCaptor.getValue(); assertThat(emailMessage.subject()).isEqualTo(DOMAIN_LIMIT_UPGRADE_EMAIL_SUBJECT); assertThat(emailMessage.body()) .isEqualTo( String.format(DOMAIN_LIMIT_UPGRADE_EMAIL_BODY, 1, "abc123", "The Registrar", 1, 2)); - PackagePromotion packageAfterCheck = - tm().transact(() -> PackagePromotion.loadByTokenString(token.getToken()).get()); + BulkPricingPackage packageAfterCheck = + tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get()); assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.nowUtc()); } } diff --git a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java index 5ea0736c6..f5cd305fc 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java @@ -26,8 +26,8 @@ import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.DEF import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.NONPREMIUM; import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.SPECIFIED; import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE; @@ -78,10 +78,10 @@ import google.registry.flows.FlowUtils.NotLoggedInException; import google.registry.flows.FlowUtils.UnknownCurrencyEppException; import google.registry.flows.ResourceFlowTestCase; import google.registry.flows.domain.DomainCreateFlow.AnchorTenantCreatePeriodException; +import google.registry.flows.domain.DomainCreateFlow.BulkDomainRegisteredForTooManyYearsException; import google.registry.flows.domain.DomainCreateFlow.MustHaveSignedMarksInCurrentPhaseException; import google.registry.flows.domain.DomainCreateFlow.NoGeneralRegistrationsInCurrentPhaseException; import google.registry.flows.domain.DomainCreateFlow.NoTrademarkedRegistrationsBeforeSunriseException; -import google.registry.flows.domain.DomainCreateFlow.PackageDomainRegisteredForTooManyYearsException; import google.registry.flows.domain.DomainCreateFlow.RenewalPriceInfo; import google.registry.flows.domain.DomainCreateFlow.SignedMarksOnlyDuringSunriseException; import google.registry.flows.domain.DomainFlowTmchUtils.FoundMarkExpiredException; @@ -3673,12 +3673,12 @@ class DomainCreateFlowTest extends ResourceFlowTestCase { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - domain = domain.asBuilder().setCurrentPackageToken(token.createVKey()).build(); + domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build(); persistResource(domain); setEppInput("domain_info_bulk.xml"); doSuccessfulTest("domain_info_response_bulk.xml", false); @@ -1111,14 +1111,14 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - domain = domain.asBuilder().setCurrentPackageToken(token.createVKey()).build(); + domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build(); persistResource(domain); sessionMetadata.setRegistrarId("TheRegistrar"); setEppInput("domain_info_bulk.xml"); @@ -1143,14 +1143,14 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - domain = domain.asBuilder().setCurrentPackageToken(token.createVKey()).build(); + domain = domain.asBuilder().setCurrentBulkToken(token.createVKey()).build(); persistResource(domain); sessionMetadata.setRegistrarId("TheRegistrar"); setEppInput("domain_info_bulk.xml"); diff --git a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java index 808f1d913..5b375a844 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java @@ -20,8 +20,8 @@ import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWit import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.DEFAULT; import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.NONPREMIUM; import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.SPECIFIED; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -77,8 +77,8 @@ import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTok import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException; import google.registry.flows.domain.token.AllocationTokenFlowUtils.AlreadyRedeemedAllocationTokenException; import google.registry.flows.domain.token.AllocationTokenFlowUtils.InvalidAllocationTokenException; -import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnPackageDomainException; -import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonPackageDomainException; +import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnBulkPricingDomainException; +import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonBulkPricingDomainException; import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException; import google.registry.model.billing.BillingBase.Flag; import google.registry.model.billing.BillingBase.Reason; @@ -1249,59 +1249,53 @@ class DomainRenewFlowTest extends ResourceFlowTestCase } @Test - void testFailsPackageDomainInvalidAllocationToken() throws Exception { + void testFailsBulkPricingDomainInvalidAllocationToken() throws Exception { AllocationToken token = persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setAllowedTlds(ImmutableSet.of("tld")) .setRenewalPriceBehavior(SPECIFIED) .build()); persistDomain(); persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); + reloadResourceByForeignKey().asBuilder().setCurrentBulkToken(token.createVKey()).build()); setEppInput( "domain_renew_allocationtoken.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "abc123")); EppException thrown = - assertThrows(MissingRemoveDomainTokenOnPackageDomainException.class, this::runFlow); + assertThrows(MissingRemoveDomainTokenOnBulkPricingDomainException.class, this::runFlow); assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test - void testFailsToRenewPackageDomainNoRemoveDomainToken() throws Exception { + void testFailsToRenewBulkPricingDomainNoRemoveDomainToken() throws Exception { AllocationToken token = persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setAllowedTlds(ImmutableSet.of("tld")) .setRenewalPriceBehavior(SPECIFIED) .build()); persistDomain(); persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); + reloadResourceByForeignKey().asBuilder().setCurrentBulkToken(token.createVKey()).build()); setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5")); EppException thrown = - assertThrows(MissingRemoveDomainTokenOnPackageDomainException.class, this::runFlow); + assertThrows(MissingRemoveDomainTokenOnBulkPricingDomainException.class, this::runFlow); assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test - void testFailsToRenewNonPackageDomainWithRemoveDomainToken() throws Exception { + void testFailsToRenewNonBulkPricingDomainWithRemoveDomainToken() throws Exception { persistDomain(); setEppInput( @@ -1309,7 +1303,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__")); EppException thrown = - assertThrows(RemoveDomainTokenOnNonPackageDomainException.class, this::runFlow); + assertThrows(RemoveDomainTokenOnNonBulkPricingDomainException.class, this::runFlow); assertAboutEppExceptions().that(thrown).marshalsToXml(); } @@ -1319,17 +1313,14 @@ class DomainRenewFlowTest extends ResourceFlowTestCase persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setAllowedTlds(ImmutableSet.of("tld")) .setRenewalPriceBehavior(SPECIFIED) .build()); persistDomain(SPECIFIED, Money.of(USD, 2)); persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); + reloadResourceByForeignKey().asBuilder().setCurrentBulkToken(token.createVKey()).build()); setEppInput( "domain_renew_allocationtoken.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__")); @@ -1339,10 +1330,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase 2, ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00Z")); - // We still need to verify that package token is removed as it's not being tested as a part of + // We still need to verify that the bulk token is removed as it's not being tested as a part of // doSuccessfulTest Domain domain = reloadResourceByForeignKey(); - Truth8.assertThat(domain.getCurrentPackageToken()).isEmpty(); + Truth8.assertThat(domain.getCurrentBulkToken()).isEmpty(); } @Test @@ -1351,17 +1342,14 @@ class DomainRenewFlowTest extends ResourceFlowTestCase persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setAllowedTlds(ImmutableSet.of("tld")) .setRenewalPriceBehavior(SPECIFIED) .build()); persistDomain(SPECIFIED, Money.of(USD, 2)); persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); + reloadResourceByForeignKey().asBuilder().setCurrentBulkToken(token.createVKey()).build()); setEppInput( "domain_renew_allocationtoken.xml", diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java index 7750b18eb..be8e98617 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java @@ -17,7 +17,7 @@ package google.registry.flows.domain; import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.NET_ADDS_4_YR; @@ -382,12 +382,12 @@ class DomainTransferApproveFlowTest } @Test - void testDryRun_PackageDomain() throws Exception { + void testDryRun_bulkPricingDomain() throws Exception { AllocationToken allocationToken = persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); @@ -398,8 +398,7 @@ class DomainTransferApproveFlowTest .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, new BigDecimal("10.00"))) .build()); - persistResource( - domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); + persistResource(domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); clock.advanceOneMilli(); setEppInput("domain_transfer_approve_wildcard.xml", ImmutableMap.of("DOMAIN", "example.tld")); dryRunFlowAssertResponse(loadFile("domain_transfer_approve_response.xml")); @@ -411,12 +410,12 @@ class DomainTransferApproveFlowTest } @Test - void testSuccess_removesPackageToken() throws Exception { + void testSuccess_removesBulkToken() throws Exception { AllocationToken allocationToken = persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); @@ -427,8 +426,7 @@ class DomainTransferApproveFlowTest .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, new BigDecimal("10.00"))) .build()); - persistResource( - domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); + persistResource(domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); clock.advanceOneMilli(); setEppInput("domain_transfer_approve_wildcard.xml", ImmutableMap.of("DOMAIN", "example.tld")); DateTime now = clock.nowUtc(); @@ -460,7 +458,7 @@ class DomainTransferApproveFlowTest .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, new BigDecimal("10.00"))) .build()); - assertThat(domain.getCurrentPackageToken()).isEmpty(); + assertThat(domain.getCurrentBulkToken()).isEmpty(); assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("NewRegistrar"); assertThat(loadByKey(domain.getAutorenewBillingEvent()).getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.DEFAULT); diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java index b1a4529b7..c6af3beb9 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -21,7 +21,7 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.batch.AsyncTaskEnqueuer.PARAM_REQUESTED_TIME; import static google.registry.batch.AsyncTaskEnqueuer.PARAM_RESOURCE_KEY; import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; @@ -1329,7 +1329,7 @@ class DomainTransferRequestFlowTest } @Test - void testSuccess_specifiedRenewalPrice_notCarriedOverForPackageName() throws Exception { + void testSuccess_specifiedRenewalPrice_notCarriedOverForBulkPricingName() throws Exception { setupDomain("example", "tld"); persistResource(Tld.get("tld").asBuilder().build()); domain = loadByEntity(domain); @@ -1343,13 +1343,13 @@ class DomainTransferRequestFlowTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); domain = persistResource( - domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); + domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); DateTime now = clock.nowUtc(); setEppInput("domain_transfer_request.xml"); @@ -1388,7 +1388,7 @@ class DomainTransferRequestFlowTest } @Test - void testSuccess_defaultRenewalPrice_carriedOverForPackageName() throws Exception { + void testSuccess_defaultRenewalPrice_carriedOverForBulkPricingName() throws Exception { setupDomain("example", "tld"); persistResource(Tld.get("tld").asBuilder().build()); domain = loadByEntity(domain); @@ -1401,13 +1401,13 @@ class DomainTransferRequestFlowTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); domain = persistResource( - domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); + domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); DateTime now = clock.nowUtc(); setEppInput("domain_transfer_request.xml"); @@ -1445,7 +1445,7 @@ class DomainTransferRequestFlowTest } @Test - void testSuccess_packageName_zeroPeriod() throws Exception { + void testSuccess_bulkPricingName_zeroPeriod() throws Exception { setupDomain("example", "tld"); persistResource(Tld.get("tld").asBuilder().build()); domain = loadByEntity(domain); @@ -1458,13 +1458,13 @@ class DomainTransferRequestFlowTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); domain = persistResource( - domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); + domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); doSuccessfulSuperuserExtensionTest( "domain_transfer_request_superuser_extension.xml", diff --git a/core/src/test/java/google/registry/model/domain/DomainSqlTest.java b/core/src/test/java/google/registry/model/domain/DomainSqlTest.java index 46b9f8f08..b73a565ad 100644 --- a/core/src/test/java/google/registry/model/domain/DomainSqlTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainSqlTest.java @@ -17,7 +17,7 @@ package google.registry.model.domain; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects; import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT_STARTED; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.insertInDb; @@ -131,7 +131,7 @@ public class DomainSqlTest { allocationToken = new AllocationToken.Builder() .setToken("abc123Unlimited") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("dev", "app")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -152,9 +152,9 @@ public class DomainSqlTest { } @Test - void testDomainBasePersistenceWithCurrentPackageToken() { + void testDomainBasePersistenceWithCurrentBulkToken() { persistResource(allocationToken); - domain = domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build(); + domain = domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build(); persistDomain(); assertEqualDomainExcept(loadByKey(domain.createVKey())); } diff --git a/core/src/test/java/google/registry/model/domain/DomainTest.java b/core/src/test/java/google/registry/model/domain/DomainTest.java index 3a0f35303..6cf9033a7 100644 --- a/core/src/test/java/google/registry/model/domain/DomainTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainTest.java @@ -20,7 +20,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.billing.BillingBase.RenewalPriceBehavior.SPECIFIED; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatabaseHelper.createTld; @@ -812,7 +812,7 @@ public class DomainTest { } @Test - void testClone_removesPackageFromTransferredDomain() { + void testClone_removesBulkTokenFromTransferredDomain() { // If the transfer implicitly succeeded, the expiration time should be extended even if it // hadn't already expired DateTime now = DateTime.now(UTC); @@ -831,7 +831,7 @@ public class DomainTest { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); @@ -841,13 +841,13 @@ public class DomainTest { .asBuilder() .setRegistrationExpirationTime(previousExpiration) .setTransferData(transferData) - .setCurrentPackageToken(allocationToken.createVKey()) + .setCurrentBulkToken(allocationToken.createVKey()) .build()); - assertThat(domain.getCurrentPackageToken()).isPresent(); + assertThat(domain.getCurrentBulkToken()).isPresent(); Domain clonedDomain = domain.cloneProjectedAtTime(now); assertThat(clonedDomain.getRegistrationExpirationTime()).isEqualTo(newExpiration); - assertThat(clonedDomain.getCurrentPackageToken()).isEmpty(); + assertThat(clonedDomain.getCurrentBulkToken()).isEmpty(); } @Test @@ -876,7 +876,7 @@ public class DomainTest { } @Test - void testClone_doesNotRemovePackageForPendingTransfer() { + void testClone_doesNotRemoveBulkTokenForPendingTransfer() { // Pending transfers shouldn't affect the expiration time DateTime now = DateTime.now(UTC); DateTime transferExpirationTime = now.plusDays(1); @@ -892,7 +892,7 @@ public class DomainTest { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); @@ -902,12 +902,12 @@ public class DomainTest { .asBuilder() .setRegistrationExpirationTime(previousExpiration) .setTransferData(transferData) - .setCurrentPackageToken(allocationToken.createVKey()) + .setCurrentBulkToken(allocationToken.createVKey()) .build()); Domain clonedDomain = domain.cloneProjectedAtTime(now); assertThat(clonedDomain.getRegistrationExpirationTime()).isEqualTo(previousExpiration); - assertThat(clonedDomain.getCurrentPackageToken().get()).isEqualTo(allocationToken.createVKey()); + assertThat(clonedDomain.getCurrentBulkToken().get()).isEqualTo(allocationToken.createVKey()); } @Test @@ -1043,48 +1043,48 @@ public class DomainTest { } @Test - void testFail_currentPackageTokenWrongPackageType() { + void testFail_currentBulkTokenWrongTokenType() { AllocationToken allocationToken = persistResource( new AllocationToken.Builder().setToken("abc123").setTokenType(SINGLE_USE).build()); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); + () -> domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); assertThat(thrown) .hasMessageThat() - .isEqualTo("The currentPackageToken must have a PACKAGE TokenType"); + .isEqualTo("The currentBulkToken must have a BULK_PRICING TokenType"); } @Test - void testFailure_packageTokenDoesNotExist() { + void testFailure_bulkTokenDoesNotExist() { AllocationToken allocationToken = new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build(); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build()); - assertThat(thrown).hasMessageThat().isEqualTo("The package token abc123 does not exist"); + () -> domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build()); + assertThat(thrown).hasMessageThat().isEqualTo("The bulk token abc123 does not exist"); } @Test - void testSuccess_removeCurrentPackageToken() { + void testSuccess_removeCurrentBulkToken() { AllocationToken allocationToken = persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .build()); - domain = domain.asBuilder().setCurrentPackageToken(allocationToken.createVKey()).build(); - assertThat(domain.getCurrentPackageToken().get()).isEqualTo(allocationToken.createVKey()); - domain = domain.asBuilder().setCurrentPackageToken(null).build(); - assertThat(domain.getCurrentPackageToken()).isEmpty(); + domain = domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build(); + assertThat(domain.getCurrentBulkToken().get()).isEqualTo(allocationToken.createVKey()); + domain = domain.asBuilder().setCurrentBulkToken(null).build(); + assertThat(domain.getCurrentBulkToken()).isEmpty(); } } diff --git a/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java b/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java index 721aa4cd7..02b4aad11 100644 --- a/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java +++ b/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java @@ -20,7 +20,7 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.CAN import static google.registry.model.domain.token.AllocationToken.TokenStatus.ENDED; import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT_STARTED; import static google.registry.model.domain.token.AllocationToken.TokenStatus.VALID; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.testing.DatabaseHelper.createTld; @@ -218,28 +218,28 @@ public class AllocationTokenTest extends EntityTestCase { } @Test - void testFail_packageTokenNotSpecifiedRenewalBehavior() { + void testFail_bulkTokenNotSpecifiedRenewalBehavior() { AllocationToken.Builder builder = new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, builder::build); assertThat(thrown) .hasMessageThat() - .isEqualTo("Package tokens must have renewalPriceBehavior set to SPECIFIED"); + .isEqualTo("Bulk tokens must have renewalPriceBehavior set to SPECIFIED"); } @Test - void testFail_packageTokenDiscountPremium() { + void testFail_bulkTokenDiscountPremium() { AllocationToken.Builder builder = new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountPremiums(true); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, builder::build); - assertThat(thrown).hasMessageThat().isEqualTo("Package tokens cannot discount premium names"); + assertThat(thrown).hasMessageThat().isEqualTo("Bulk tokens cannot discount premium names"); } @Test @@ -292,17 +292,17 @@ public class AllocationTokenTest extends EntityTestCase { } @Test - void testBuild_onlyOneClientInPackage() { + void testBuild_onlyOneClientInBulkPricingPackage() { Buildable.Builder builder = new AllocationToken.Builder() .setToken("foobar") - .setTokenType(PACKAGE) + .setTokenType(BULK_PRICING) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setAllowedRegistrarIds(ImmutableSet.of("foo", "bar")); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, builder::build); assertThat(thrown) .hasMessageThat() - .isEqualTo("PACKAGE tokens must have exactly one allowed client registrar"); + .isEqualTo("BULK_PRICING tokens must have exactly one allowed client registrar"); } @Test diff --git a/core/src/test/java/google/registry/model/domain/token/PackagePromotionTest.java b/core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java similarity index 81% rename from core/src/test/java/google/registry/model/domain/token/PackagePromotionTest.java rename to core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java index 3771a5378..f8208d74d 100644 --- a/core/src/test/java/google/registry/model/domain/token/PackagePromotionTest.java +++ b/core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java @@ -31,10 +31,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.testcontainers.shaded.com.google.common.collect.ImmutableSet; -/** Unit tests for {@link PackagePromotion}. */ -public class PackagePromotionTest extends EntityTestCase { +/** Unit tests for {@link BulkPricingPackage}. */ +public class BulkPricingPackageTest extends EntityTestCase { - public PackagePromotionTest() { + public BulkPricingPackageTest() { super(JpaEntityCoverageCheck.ENABLED); } @@ -49,7 +49,7 @@ public class PackagePromotionTest extends EntityTestCase { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -57,23 +57,23 @@ public class PackagePromotionTest extends EntityTestCase { .setDiscountFraction(1) .build()); - PackagePromotion packagePromotion = - new PackagePromotion.Builder() + BulkPricingPackage bulkPricingPackage = + new BulkPricingPackage.Builder() .setToken(token) - .setPackagePrice(Money.of(CurrencyUnit.USD, 10000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 10000)) .setMaxCreates(40) .setMaxDomains(10) .setNextBillingDate(DateTime.parse("2011-11-12T05:00:00Z")) .build(); - tm().transact(() -> tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); assertAboutImmutableObjects() - .that(tm().transact(() -> PackagePromotion.loadByTokenString("abc123")).get()) - .isEqualExceptFields(packagePromotion, "packagePromotionId"); + .that(tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")).get()) + .isEqualExceptFields(bulkPricingPackage, "bulkPricingId"); } @Test - void testFail_tokenIsNotPackage() { + void testFail_tokenIsNotBulkToken() { AllocationToken token = persistResource( new AllocationToken.Builder() @@ -90,14 +90,14 @@ public class PackagePromotionTest extends EntityTestCase { IllegalArgumentException.class, () -> persistResource( - new PackagePromotion.Builder() + new BulkPricingPackage.Builder() .setToken(token) - .setPackagePrice(Money.of(CurrencyUnit.USD, 10000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 10000)) .setMaxCreates(40) .setMaxDomains(10) .setNextBillingDate(DateTime.parse("2011-11-12T05:00:00Z")) .build())); - assertThat(thrown).hasMessageThat().isEqualTo("Allocation token must be a PACKAGE type"); + assertThat(thrown).hasMessageThat().isEqualTo("Allocation token must be a BULK_PRICING type"); } } diff --git a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java index 12f6b924e..27b674b60 100644 --- a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java +++ b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java @@ -23,7 +23,7 @@ import google.registry.model.console.UserTest; import google.registry.model.contact.ContactTest; import google.registry.model.domain.DomainSqlTest; import google.registry.model.domain.token.AllocationTokenTest; -import google.registry.model.domain.token.PackagePromotionTest; +import google.registry.model.domain.token.BulkPricingPackageTest; import google.registry.model.history.ContactHistoryTest; import google.registry.model.history.DomainHistoryTest; import google.registry.model.history.HostHistoryTest; @@ -82,6 +82,7 @@ import org.junit.runner.RunWith; BeforeSuiteTest.class, AllocationTokenTest.class, BillingBaseTest.class, + BulkPricingPackageTest.class, ClaimsListDaoTest.class, ContactHistoryTest.class, ContactTest.class, @@ -91,7 +92,6 @@ import org.junit.runner.RunWith; DomainHistoryTest.class, HostHistoryTest.class, LockTest.class, - PackagePromotionTest.class, PollMessageTest.class, PremiumListDaoTest.class, RdeRevisionTest.class, diff --git a/core/src/test/java/google/registry/tools/CreatePackagePromotionCommandTest.java b/core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java similarity index 68% rename from core/src/test/java/google/registry/tools/CreatePackagePromotionCommandTest.java rename to core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java index 04eb3e070..fc7ef238d 100644 --- a/core/src/test/java/google/registry/tools/CreatePackagePromotionCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import google.registry.model.billing.BillingBase.RenewalPriceBehavior; import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenType; -import google.registry.model.domain.token.PackagePromotion; +import google.registry.model.domain.token.BulkPricingPackage; import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -32,16 +32,16 @@ import org.joda.time.DateTime; import org.junit.jupiter.api.Test; import org.testcontainers.shaded.com.google.common.collect.ImmutableSet; -/** Unit tests for {@link google.registry.tools.CreatePackagePromotionCommand}. */ -public class CreatePackagePromotionCommandTest - extends CommandTestCase { +/** Unit tests for {@link CreateBulkPricingPackageCommand}. */ +public class CreateBulkPricingPackageCommandTest + extends CommandTestCase { @Test void testSuccess() throws Exception { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -55,20 +55,20 @@ public class CreatePackagePromotionCommandTest "--next_billing_date=2012-03-17", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - assertThat(packagePromotion.getMaxDomains()).isEqualTo(100); - assertThat(packagePromotion.getMaxCreates()).isEqualTo(500); - assertThat(packagePromotion.getPackagePrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); - assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(100); + assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(500); + assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); + assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2012-03-17T00:00:00Z")); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test - void testFailure_tokenIsNotPackageType() throws Exception { + void testFailure_tokenIsNotBulkType() throws Exception { persistResource( new AllocationToken.Builder() .setToken("abc123") @@ -90,7 +90,7 @@ public class CreatePackagePromotionCommandTest "--next_billing_date=2012-03-17T05:00:00Z", "abc123")); assertThat(thrown.getMessage()) - .isEqualTo("The allocation token must be of the PACKAGE token type"); + .isEqualTo("The allocation token must be of the BULK_PRICING token type"); } @Test @@ -107,16 +107,16 @@ public class CreatePackagePromotionCommandTest "abc123")); assertThat(thrown.getMessage()) .isEqualTo( - "An allocation token with the token String abc123 does not exist. The package token" - + " must be created first before it can be used to create a PackagePromotion"); + "An allocation token with the token String abc123 does not exist. The bulk token" + + " must be created first before it can be used to create a BulkPricingPackage"); } @Test - void testFailure_packagePromotionAlreadyExists() throws Exception { + void testFailure_bulkPricingPackageAlreadyExists() throws Exception { persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -129,9 +129,9 @@ public class CreatePackagePromotionCommandTest "--price=USD 1000.00", "--next_billing_date=2012-03-17T05:00:00Z", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, @@ -142,7 +142,8 @@ public class CreatePackagePromotionCommandTest "--price=USD 1000.00", "--next_billing_date=2012-03-17T05:00:00Z", "abc123")); - assertThat(thrown.getMessage()).isEqualTo("PackagePromotion with token abc123 already exists"); + assertThat(thrown.getMessage()) + .isEqualTo("BulkPricingPackage with token abc123 already exists"); } @Test @@ -150,7 +151,7 @@ public class CreatePackagePromotionCommandTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -158,16 +159,16 @@ public class CreatePackagePromotionCommandTest .setDiscountFraction(1) .build()); runCommandForced("--price=USD 1000.00", "--next_billing_date=2012-03-17", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - assertThat(packagePromotion.getMaxDomains()).isEqualTo(0); - assertThat(packagePromotion.getMaxCreates()).isEqualTo(0); - assertThat(packagePromotion.getPackagePrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); - assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(0); + assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(0); + assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); + assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2012-03-17T00:00:00Z")); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test @@ -175,7 +176,7 @@ public class CreatePackagePromotionCommandTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -184,15 +185,15 @@ public class CreatePackagePromotionCommandTest .build()); runCommandForced("--max_domains=100", "--max_creates=500", "--price=USD 1000.00", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - assertThat(packagePromotion.getMaxDomains()).isEqualTo(100); - assertThat(packagePromotion.getMaxCreates()).isEqualTo(500); - assertThat(packagePromotion.getPackagePrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); - assertThat(packagePromotion.getNextBillingDate()).isEqualTo(END_OF_TIME); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(100); + assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(500); + assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); + assertThat(bulkPricingPackage.getNextBillingDate()).isEqualTo(END_OF_TIME); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test @@ -200,7 +201,7 @@ public class CreatePackagePromotionCommandTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -217,6 +218,6 @@ public class CreatePackagePromotionCommandTest "--next_billing_date=2012-03-17T05:00:00Z", "abc123")); assertThat(thrown.getMessage()) - .isEqualTo("PackagePrice is required when creating a new package"); + .isEqualTo("BulkPrice is required when creating a new bulk pricing package"); } } diff --git a/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java b/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java index ed2b08d36..77ec65ab2 100644 --- a/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java +++ b/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java @@ -379,8 +379,8 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase { +/** Unit tests for {@link GetBulkPricingPackageCommand}. */ +public class GetBulkPricingPackageCommandTest + extends CommandTestCase { @BeforeEach void beforeEach() { @@ -45,33 +46,33 @@ public class GetPackagePromotionCommandTest extends CommandTestCase tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); runCommand("abc123"); } @Test - void testSuccessMultiplePackages() throws Exception { + void testSuccessMultipleBulkPricingPackages() throws Exception { AllocationToken token = persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -81,11 +82,11 @@ public class GetPackagePromotionCommandTest extends CommandTestCase tm().put( - new PackagePromotion.Builder() + new BulkPricingPackage.Builder() .setToken(token) .setMaxDomains(100) .setMaxCreates(500) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z")) .setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z")) .build())); @@ -93,7 +94,7 @@ public class GetPackagePromotionCommandTest extends CommandTestCase tm().put( - new PackagePromotion.Builder() + new BulkPricingPackage.Builder() .setToken(token2) .setMaxDomains(1000) .setMaxCreates(700) - .setPackagePrice(Money.of(CurrencyUnit.USD, 3000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 3000)) .setNextBillingDate(DateTime.parse("2014-11-12T05:00:00Z")) .setLastNotificationSent(DateTime.parse("2013-11-12T05:00:00Z")) .build())); @@ -116,12 +117,12 @@ public class GetPackagePromotionCommandTest extends CommandTestCase runCommand("fakeToken")); assertThat(thrown) .hasMessageThat() - .isEqualTo("PackagePromotion with package token fakeToken does not exist"); + .isEqualTo("BulkPricingPackage with token fakeToken does not exist"); } @Test diff --git a/core/src/test/java/google/registry/tools/UpdateAllocationTokensCommandTest.java b/core/src/test/java/google/registry/tools/UpdateAllocationTokensCommandTest.java index cee9ee4fa..285a43c97 100644 --- a/core/src/test/java/google/registry/tools/UpdateAllocationTokensCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateAllocationTokensCommandTest.java @@ -22,7 +22,7 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.CAN import static google.registry.model.domain.token.AllocationToken.TokenStatus.ENDED; import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT_STARTED; import static google.registry.model.domain.token.AllocationToken.TokenStatus.VALID; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; +import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.testing.DatabaseHelper.createTld; @@ -344,13 +344,13 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase { +/** Unit tests for {@link UpdateBulkPricingPackageCommand}. */ +public class UpdateBulkPricingPackageCommandTest + extends CommandTestCase { @BeforeEach void beforeEach() { @@ -42,23 +42,23 @@ public class UpdatePackagePromotionCommandTest persistResource( new AllocationToken.Builder() .setToken("abc123") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setDiscountFraction(1) .build()); - PackagePromotion packagePromotion = - new PackagePromotion.Builder() + BulkPricingPackage bulkPricingPackage = + new BulkPricingPackage.Builder() .setToken(token) .setMaxDomains(100) .setMaxCreates(500) - .setPackagePrice(Money.of(CurrencyUnit.USD, 1000)) + .setBulkPrice(Money.of(CurrencyUnit.USD, 1000)) .setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z")) .setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z")) .build(); - tm().transact(() -> tm().put(packagePromotion)); + tm().transact(() -> tm().put(bulkPricingPackage)); } @Test @@ -71,25 +71,24 @@ public class UpdatePackagePromotionCommandTest "--clear_last_notification_sent", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - Truth.assertThat(packagePromotion.getMaxDomains()).isEqualTo(200); - Truth.assertThat(packagePromotion.getMaxCreates()).isEqualTo(1000); - Truth.assertThat(packagePromotion.getPackagePrice()) - .isEqualTo(Money.of(CurrencyUnit.USD, 2000)); - Truth.assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + Truth.assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(200); + Truth.assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000); + Truth.assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000)); + Truth.assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2013-03-17T00:00:00Z")); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test - void testFailure_packageDoesNotExist() throws Exception { + void testFailure_bulkPackageDoesNotExist() throws Exception { persistResource( new AllocationToken.Builder() .setToken("nullPackage") - .setTokenType(TokenType.PACKAGE) + .setTokenType(TokenType.BULK_PRICING) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) @@ -107,7 +106,7 @@ public class UpdatePackagePromotionCommandTest "--next_billing_date=2012-03-17", "nullPackage")); Truth.assertThat(thrown.getMessage()) - .isEqualTo("PackagePromotion with token nullPackage does not exist"); + .isEqualTo("BulkPricingPackage with token nullPackage does not exist"); } @Test @@ -119,17 +118,16 @@ public class UpdatePackagePromotionCommandTest "--clear_last_notification_sent", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - Truth.assertThat(packagePromotion.getMaxDomains()).isEqualTo(100); - Truth.assertThat(packagePromotion.getMaxCreates()).isEqualTo(1000); - Truth.assertThat(packagePromotion.getPackagePrice()) - .isEqualTo(Money.of(CurrencyUnit.USD, 2000)); - Truth.assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + Truth.assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(100); + Truth.assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000); + Truth.assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000)); + Truth.assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2013-03-17T00:00:00Z")); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test @@ -141,17 +139,16 @@ public class UpdatePackagePromotionCommandTest "--clear_last_notification_sent", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - Truth.assertThat(packagePromotion.getMaxDomains()).isEqualTo(200); - Truth.assertThat(packagePromotion.getMaxCreates()).isEqualTo(1000); - Truth.assertThat(packagePromotion.getPackagePrice()) - .isEqualTo(Money.of(CurrencyUnit.USD, 2000)); - Truth.assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + Truth.assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(200); + Truth.assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000); + Truth.assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000)); + Truth.assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2012-11-12T05:00:00Z")); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test @@ -163,34 +160,32 @@ public class UpdatePackagePromotionCommandTest "--clear_last_notification_sent", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - Truth.assertThat(packagePromotion.getMaxDomains()).isEqualTo(200); - Truth.assertThat(packagePromotion.getMaxCreates()).isEqualTo(1000); - Truth.assertThat(packagePromotion.getPackagePrice()) - .isEqualTo(Money.of(CurrencyUnit.USD, 1000)); - Truth.assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + Truth.assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(200); + Truth.assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000); + Truth.assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000)); + Truth.assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2013-03-17T00:00:00Z")); - assertThat(packagePromotion.getLastNotificationSent()).isEmpty(); + assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty(); } @Test void testSuccess_dontClearLastNotificationSent() throws Exception { runCommandForced("--max_domains=200", "--max_creates=1000", "--price=USD 2000.00", "abc123"); - Optional packagePromotionOptional = - tm().transact(() -> PackagePromotion.loadByTokenString("abc123")); - assertThat(packagePromotionOptional).isPresent(); - PackagePromotion packagePromotion = packagePromotionOptional.get(); - Truth.assertThat(packagePromotion.getMaxDomains()).isEqualTo(200); - Truth.assertThat(packagePromotion.getMaxCreates()).isEqualTo(1000); - Truth.assertThat(packagePromotion.getPackagePrice()) - .isEqualTo(Money.of(CurrencyUnit.USD, 2000)); - Truth.assertThat(packagePromotion.getNextBillingDate()) + Optional bulkPricingPackageOptional = + tm().transact(() -> BulkPricingPackage.loadByTokenString("abc123")); + assertThat(bulkPricingPackageOptional).isPresent(); + BulkPricingPackage bulkPricingPackage = bulkPricingPackageOptional.get(); + Truth.assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(200); + Truth.assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000); + Truth.assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000)); + Truth.assertThat(bulkPricingPackage.getNextBillingDate()) .isEqualTo(DateTime.parse("2012-11-12T05:00:00Z")); - Truth.assertThat(packagePromotion.getLastNotificationSent().get()) + Truth.assertThat(bulkPricingPackage.getLastNotificationSent().get()) .isEqualTo(DateTime.parse("2010-11-12T05:00:00.000Z")); } } diff --git a/db/src/main/resources/sql/schema/db-schema.sql.generated b/db/src/main/resources/sql/schema/db-schema.sql.generated index 9ef0011a7..4feca52f8 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -498,12 +498,12 @@ create table "PackagePromotion" ( package_promotion_id bigserial not null, + package_price_amount numeric(19, 2) not null, + package_price_currency text not null, last_notification_sent timestamptz, max_creates int4 not null, max_domains int4 not null, next_billing_date timestamptz not null, - package_price_amount numeric(19, 2) not null, - package_price_currency text not null, token text not null, primary key (package_promotion_id) ); diff --git a/docs/flows.md b/docs/flows.md index bdc27346b..4d2f67c17 100644 --- a/docs/flows.md +++ b/docs/flows.md @@ -311,7 +311,7 @@ An EPP flow that creates a new domain resource. * Registrar is not logged in. * The current registry phase allows registrations only with signed marks. * The current registry phase does not allow for general registrations. - * Package domain registered for too many years. + * Bulk pricing domain registered for too many years. * Signed marks are only allowed during sunrise. * An allocation token was provided that is invalid for premium domains. * 2003 @@ -499,8 +499,8 @@ comes in at the exact millisecond that the domain would have expired. * Resource status prohibits this operation. * The allocation token is not currently valid. * 2305 - * The __REMOVEDOMAIN__ token is missing on a package domain command - * The __REMOVEDOMAIN__ token is not allowed on non package domains + * The __REMOVEDOMAIN__ token is missing on a bulk pricing domain command + * The __REMOVEDOMAIN__ token is not allowed on non bulk pricing domains * The allocation token is not valid for this domain. * The allocation token is not valid for this registrar. * The allocation token is not valid for this TLD.