1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 14:25:44 +00:00

Convert more @AutoValues to Java records (#2378)

This commit is contained in:
Ben McIlwain
2024-04-17 15:30:23 -04:00
committed by GitHub
parent 903b7979de
commit fa6898167b
19 changed files with 182 additions and 228 deletions

View File

@@ -29,6 +29,7 @@ import org.apache.beam.sdk.coders.NullableCoder;
import org.apache.beam.sdk.coders.StringUtf8Coder; import org.apache.beam.sdk.coders.StringUtf8Coder;
import org.apache.beam.sdk.coders.VarIntCoder; import org.apache.beam.sdk.coders.VarIntCoder;
import org.apache.beam.sdk.coders.VarLongCoder; import org.apache.beam.sdk.coders.VarLongCoder;
import org.jetbrains.annotations.NotNull;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
@@ -173,7 +174,7 @@ public abstract class BillingEvent {
/** Returns the grouping key for this {@code BillingEvent}, to generate the overall invoice. */ /** Returns the grouping key for this {@code BillingEvent}, to generate the overall invoice. */
InvoiceGroupingKey getInvoiceGroupingKey() { InvoiceGroupingKey getInvoiceGroupingKey() {
return new AutoValue_BillingEvent_InvoiceGroupingKey( return new InvoiceGroupingKey(
billingTime().toLocalDate().withDayOfMonth(1).toString(), billingTime().toLocalDate().withDayOfMonth(1).toString(),
years() == 0 years() == 0
? "" ? ""
@@ -196,9 +197,28 @@ public abstract class BillingEvent {
return String.format("%s_%s", registrarId(), tld()); return String.format("%s_%s", registrarId(), tld());
} }
/** Key for each {@code BillingEvent}, when aggregating for the overall invoice. */ /**
@AutoValue * Key for each {@code BillingEvent}, when aggregating for the overall invoice.
abstract static class InvoiceGroupingKey { *
* @param startDate The first day this invoice is valid, in yyyy-MM-dd format.
* @param endDate The last day this invoice is valid, in yyyy-MM-dd format.
* @param productAccountKey The billing account id, which is the {@code BillingEvent.billingId}.
* @param usageGroupingKey The invoice grouping key, which is the registrar ID.
* @param description The description of the item, formatted as: {@code action | TLD: tld | TERM:
* n-year}.
* @param unitPrice The cost per invoice item.
* @param unitPriceCurrency The 3-digit currency code the unit price uses.
* @param poNumber The purchase order number for the item, blank for most registrars.
*/
record InvoiceGroupingKey(
String startDate,
String endDate,
String productAccountKey,
String usageGroupingKey,
String description,
Double unitPrice,
String unitPriceCurrency,
String poNumber) {
private static final ImmutableList<String> INVOICE_HEADERS = private static final ImmutableList<String> INVOICE_HEADERS =
ImmutableList.of( ImmutableList.of(
@@ -217,29 +237,6 @@ public abstract class BillingEvent {
"UnitPriceCurrency", "UnitPriceCurrency",
"PONumber"); "PONumber");
/** Returns the first day this invoice is valid, in yyyy-MM-dd format. */
abstract String startDate();
/** Returns the last day this invoice is valid, in yyyy-MM-dd format. */
abstract String endDate();
/** Returns the billing account id, which is the {@code BillingEvent.billingId}. */
abstract String productAccountKey();
/** Returns the invoice grouping key, which is the registrar ID. */
abstract String usageGroupingKey();
/** Returns a description of the item, formatted as "action | TLD: tld | TERM: n-year." */
abstract String description();
/** Returns the cost per invoice item. */
abstract Double unitPrice();
/** Returns the 3-digit currency code the unit price uses. */
abstract String unitPriceCurrency();
/** Returns the purchase order number for the item, blank for most registrars. */
abstract String poNumber();
/** Generates the CSV header for the overall invoice. */ /** Generates the CSV header for the overall invoice. */
static String invoiceHeader() { static String invoiceHeader() {
@@ -280,7 +277,8 @@ public abstract class BillingEvent {
private InvoiceGroupingKeyCoder() {} private InvoiceGroupingKeyCoder() {}
@Override @Override
public void encode(InvoiceGroupingKey value, OutputStream outStream) throws IOException { public void encode(InvoiceGroupingKey value, @NotNull OutputStream outStream)
throws IOException {
Coder<String> stringCoder = StringUtf8Coder.of(); Coder<String> stringCoder = StringUtf8Coder.of();
stringCoder.encode(value.startDate(), outStream); stringCoder.encode(value.startDate(), outStream);
stringCoder.encode(value.endDate(), outStream); stringCoder.encode(value.endDate(), outStream);
@@ -293,8 +291,8 @@ public abstract class BillingEvent {
} }
@Override @Override
public InvoiceGroupingKey decode(InputStream inStream) throws IOException { public InvoiceGroupingKey decode(@NotNull InputStream inStream) throws IOException {
return new AutoValue_BillingEvent_InvoiceGroupingKey( return new InvoiceGroupingKey(
stringCoder.decode(inStream), stringCoder.decode(inStream),
stringCoder.decode(inStream), stringCoder.decode(inStream),
stringCoder.decode(inStream), stringCoder.decode(inStream),

View File

@@ -21,7 +21,6 @@ import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Multimaps.newListMultimap; import static com.google.common.collect.Multimaps.newListMultimap;
import static com.google.common.collect.Multimaps.toMultimap; import static com.google.common.collect.Multimaps.toMultimap;
import com.google.auto.value.AutoValue;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -192,8 +191,8 @@ class BsaDiffCreator {
newAndRemaining.values().stream() newAndRemaining.values().stream()
.filter(value -> !Objects.equals(ORDER_ID_SENTINEL, value)) .filter(value -> !Objects.equals(ORDER_ID_SENTINEL, value))
.distinct() .distinct()
.map(id -> BlockOrder.of(id, OrderType.CREATE)), .map(id -> BlockOrder.create(id, OrderType.CREATE)),
deleted.values().stream().distinct().map(id -> BlockOrder.of(id, OrderType.DELETE))); deleted.values().stream().distinct().map(id -> BlockOrder.create(id, OrderType.DELETE)));
} }
Stream<BlockLabel> getLabels() { Stream<BlockLabel> getLabels() {
@@ -203,7 +202,7 @@ class BsaDiffCreator {
.filter(entry -> entry.getValue().contains(ORDER_ID_SENTINEL)) .filter(entry -> entry.getValue().contains(ORDER_ID_SENTINEL))
.map( .map(
entry -> entry ->
BlockLabel.of( BlockLabel.create(
entry.getKey(), entry.getKey(),
LabelType.NEW_ORDER_ASSOCIATION, LabelType.NEW_ORDER_ASSOCIATION,
getAllValidIdnNames(entry.getKey()))), getAllValidIdnNames(entry.getKey()))),
@@ -212,12 +211,14 @@ class BsaDiffCreator {
.filter(entry -> !entry.getValue().contains(ORDER_ID_SENTINEL)) .filter(entry -> !entry.getValue().contains(ORDER_ID_SENTINEL))
.map( .map(
entry -> entry ->
BlockLabel.of( BlockLabel.create(
entry.getKey(), entry.getKey(),
LabelType.CREATE, LabelType.CREATE,
getAllValidIdnNames(entry.getKey()))), getAllValidIdnNames(entry.getKey()))),
Sets.difference(deleted.keySet(), newAndRemaining.keySet()).stream() Sets.difference(deleted.keySet(), newAndRemaining.keySet()).stream()
.map(label -> BlockLabel.of(label, LabelType.DELETE, getAllValidIdnNames(label)))) .map(
label ->
BlockLabel.create(label, LabelType.DELETE, getAllValidIdnNames(label))))
.flatMap(x -> x); .flatMap(x -> x);
} }
@@ -241,29 +242,21 @@ class BsaDiffCreator {
} }
} }
@AutoValue record LabelOrderPair(String label, Long orderId) {
abstract static class LabelOrderPair {
abstract String label();
abstract Long orderId();
static LabelOrderPair of(String key, Long value) { static LabelOrderPair of(String key, Long value) {
return new AutoValue_BsaDiffCreator_LabelOrderPair(key, value); return new LabelOrderPair(key, value);
} }
} }
@AutoValue record Line(String label, ImmutableList<Long> orderIds) {
abstract static class Line {
abstract String label();
abstract ImmutableList<Long> orderIds();
Stream<LabelOrderPair> labelOrderPairs(Canonicals<Long> canonicals) { Stream<LabelOrderPair> labelOrderPairs(Canonicals<Long> canonicals) {
return orderIds().stream().map(id -> LabelOrderPair.of(label(), canonicals.get(id))); return orderIds().stream().map(id -> LabelOrderPair.of(label(), canonicals.get(id)));
} }
static Line of(String label, ImmutableList<Long> orderIds) { static Line of(String label, ImmutableList<Long> orderIds) {
return new AutoValue_BsaDiffCreator_Line(label, orderIds); return new Line(label, orderIds);
} }
} }
} }

View File

@@ -14,7 +14,6 @@
package google.registry.bsa.api; package google.registry.bsa.api;
import com.google.auto.value.AutoValue;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@@ -24,18 +23,11 @@ import java.util.List;
* A BSA label to block. New domains with matching second-level domain (SLD) will be denied * A BSA label to block. New domains with matching second-level domain (SLD) will be denied
* registration in TLDs enrolled with BSA. * registration in TLDs enrolled with BSA.
*/ */
@AutoValue public record BlockLabel(String label, LabelType labelType, ImmutableSet<String> idnTables) {
public abstract class BlockLabel {
static final Joiner JOINER = Joiner.on(','); static final Joiner JOINER = Joiner.on(',');
static final Splitter SPLITTER = Splitter.on(',').trimResults(); static final Splitter SPLITTER = Splitter.on(',').trimResults();
public abstract String label();
public abstract LabelType labelType();
public abstract ImmutableSet<String> idnTables();
public String serialize() { public String serialize() {
return JOINER.join(label(), labelType().name(), idnTables().stream().sorted().toArray()); return JOINER.join(label(), labelType().name(), idnTables().stream().sorted().toArray());
} }
@@ -43,7 +35,7 @@ public abstract class BlockLabel {
public static BlockLabel deserialize(String text) { public static BlockLabel deserialize(String text) {
List<String> items = SPLITTER.splitToList(text); List<String> items = SPLITTER.splitToList(text);
try { try {
return of( return create(
items.get(0), items.get(0),
LabelType.valueOf(items.get(1)), LabelType.valueOf(items.get(1)),
ImmutableSet.copyOf(items.subList(2, items.size()))); ImmutableSet.copyOf(items.subList(2, items.size())));
@@ -52,8 +44,8 @@ public abstract class BlockLabel {
} }
} }
public static BlockLabel of(String label, LabelType type, ImmutableSet<String> idnTables) { public static BlockLabel create(String label, LabelType type, ImmutableSet<String> idnTables) {
return new AutoValue_BlockLabel(label, type, idnTables); return new BlockLabel(label, type, idnTables);
} }
public enum LabelType { public enum LabelType {

View File

@@ -14,7 +14,6 @@
package google.registry.bsa.api; package google.registry.bsa.api;
import com.google.auto.value.AutoValue;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import java.util.List; import java.util.List;
@@ -23,12 +22,7 @@ import java.util.List;
* A BSA order, which are needed when communicating with the BSA API while processing downloaded * A BSA order, which are needed when communicating with the BSA API while processing downloaded
* block lists. * block lists.
*/ */
@AutoValue public record BlockOrder(long orderId, OrderType orderType) {
public abstract class BlockOrder {
public abstract long orderId();
public abstract OrderType orderType();
static final Joiner JOINER = Joiner.on(','); static final Joiner JOINER = Joiner.on(',');
static final Splitter SPLITTER = Splitter.on(','); static final Splitter SPLITTER = Splitter.on(',');
@@ -40,14 +34,14 @@ public abstract class BlockOrder {
public static BlockOrder deserialize(String text) { public static BlockOrder deserialize(String text) {
List<String> items = SPLITTER.splitToList(text); List<String> items = SPLITTER.splitToList(text);
try { try {
return of(Long.valueOf(items.get(0)), OrderType.valueOf(items.get(1))); return create(Long.valueOf(items.get(0)), OrderType.valueOf(items.get(1)));
} catch (NumberFormatException ne) { } catch (NumberFormatException ne) {
throw new IllegalArgumentException(text); throw new IllegalArgumentException(text);
} }
} }
public static BlockOrder of(long orderId, OrderType orderType) { public static BlockOrder create(long orderId, OrderType orderType) {
return new AutoValue_BlockOrder(orderId, orderType); return new BlockOrder(orderId, orderType);
} }
public enum OrderType { public enum OrderType {

View File

@@ -17,8 +17,6 @@ package google.registry.bsa.api;
import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verify;
import static google.registry.bsa.BsaStringUtils.PROPERTY_JOINER; import static google.registry.bsa.BsaStringUtils.PROPERTY_JOINER;
import com.google.auto.value.AutoValue;
import com.google.auto.value.extension.memoized.Memoized;
import google.registry.bsa.BsaStringUtils; import google.registry.bsa.BsaStringUtils;
import google.registry.bsa.api.UnblockableDomain.Reason; import google.registry.bsa.api.UnblockableDomain.Reason;
import java.util.List; import java.util.List;
@@ -26,8 +24,7 @@ import java.util.Objects;
import java.util.Optional; import java.util.Optional;
/** Change record of an {@link UnblockableDomain}. */ /** Change record of an {@link UnblockableDomain}. */
@AutoValue public record UnblockableDomainChange(UnblockableDomain unblockable, Optional<Reason> newReason) {
public abstract class UnblockableDomainChange {
/** /**
* The text used in place of an empty {@link #newReason()} when an instance is serialized to * The text used in place of an empty {@link #newReason()} when an instance is serialized to
@@ -38,15 +35,10 @@ public abstract class UnblockableDomainChange {
*/ */
private static final String DELETE_REASON_PLACEHOLDER = "IS_DELETE"; private static final String DELETE_REASON_PLACEHOLDER = "IS_DELETE";
abstract UnblockableDomain unblockable();
abstract Optional<Reason> newReason();
public String domainName() { public String domainName() {
return unblockable().domainName(); return unblockable().domainName();
} }
@Memoized
public UnblockableDomain newValue() { public UnblockableDomain newValue() {
verify(newReason().isPresent(), "Removed unblockable does not have new value."); verify(newReason().isPresent(), "Removed unblockable does not have new value.");
return new UnblockableDomain(unblockable().domainName(), newReason().get()); return new UnblockableDomain(unblockable().domainName(), newReason().get());
@@ -77,27 +69,28 @@ public abstract class UnblockableDomainChange {
public static UnblockableDomainChange deserialize(String text) { public static UnblockableDomainChange deserialize(String text) {
List<String> items = BsaStringUtils.PROPERTY_SPLITTER.splitToList(text); List<String> items = BsaStringUtils.PROPERTY_SPLITTER.splitToList(text);
return of( return create(
new UnblockableDomain(items.get(0), Reason.valueOf(items.get(1))), new UnblockableDomain(items.get(0), Reason.valueOf(items.get(1))),
Objects.equals(items.get(2), DELETE_REASON_PLACEHOLDER) Objects.equals(items.get(2), DELETE_REASON_PLACEHOLDER)
? Optional.empty() ? Optional.empty()
: Optional.of(Reason.valueOf(items.get(2)))); : Optional.of(Reason.valueOf(items.get(2))));
} }
public static UnblockableDomainChange ofNew(UnblockableDomain unblockable) { public static UnblockableDomainChange createNew(UnblockableDomain unblockable) {
return of(unblockable, Optional.of(unblockable.reason())); return create(unblockable, Optional.of(unblockable.reason()));
} }
public static UnblockableDomainChange ofDeleted(UnblockableDomain unblockable) { public static UnblockableDomainChange createDeleted(UnblockableDomain unblockable) {
return of(unblockable, Optional.empty()); return create(unblockable, Optional.empty());
} }
public static UnblockableDomainChange ofChanged(UnblockableDomain unblockable, Reason newReason) { public static UnblockableDomainChange createChanged(
return of(unblockable, Optional.of(newReason)); UnblockableDomain unblockable, Reason newReason) {
return create(unblockable, Optional.of(newReason));
} }
private static UnblockableDomainChange of( private static UnblockableDomainChange create(
UnblockableDomain unblockable, Optional<Reason> newReason) { UnblockableDomain unblockable, Optional<Reason> newReason) {
return new AutoValue_UnblockableDomainChange(unblockable, newReason); return new UnblockableDomainChange(unblockable, newReason);
} }
} }

View File

@@ -177,7 +177,7 @@ public final class DomainsRefresher {
BsaUnblockableDomain domain = nameToEntity.get(domainName); BsaUnblockableDomain domain = nameToEntity.get(domainName);
UnblockableDomain unblockable = UnblockableDomain unblockable =
UnblockableDomain.of(domain.label, domain.tld, Reason.valueOf(domain.reason.name())); UnblockableDomain.of(domain.label, domain.tld, Reason.valueOf(domain.reason.name()));
changes.add(UnblockableDomainChange.ofChanged(unblockable, Reason.REGISTERED)); changes.add(UnblockableDomainChange.createChanged(unblockable, Reason.REGISTERED));
} }
// No longer registered: registered -> reserved/NONE // No longer registered: registered -> reserved/NONE
for (String domainName : noLongerRegistered) { for (String domainName : noLongerRegistered) {
@@ -186,8 +186,8 @@ public final class DomainsRefresher {
UnblockableDomain.of(domain.label, domain.tld, Reason.valueOf(domain.reason.name())); UnblockableDomain.of(domain.label, domain.tld, Reason.valueOf(domain.reason.name()));
changes.add( changes.add(
currReserved.contains(domainName) currReserved.contains(domainName)
? UnblockableDomainChange.ofChanged(unblockable, Reason.RESERVED) ? UnblockableDomainChange.createChanged(unblockable, Reason.RESERVED)
: UnblockableDomainChange.ofDeleted(unblockable)); : UnblockableDomainChange.createDeleted(unblockable));
} }
// No longer reserved: reserved -> registered/None (the former duplicates with newly-registered) // No longer reserved: reserved -> registered/None (the former duplicates with newly-registered)
for (String domainName : noLongerReserved) { for (String domainName : noLongerReserved) {
@@ -195,7 +195,7 @@ public final class DomainsRefresher {
UnblockableDomain unblockable = UnblockableDomain unblockable =
UnblockableDomain.of(domain.label, domain.tld, Reason.valueOf(domain.reason.name())); UnblockableDomain.of(domain.label, domain.tld, Reason.valueOf(domain.reason.name()));
if (!currRegistered.contains(domainName)) { if (!currRegistered.contains(domainName)) {
changes.add(UnblockableDomainChange.ofDeleted(unblockable)); changes.add(UnblockableDomainChange.createDeleted(unblockable));
} }
} }
return changes.build(); return changes.build();
@@ -230,7 +230,7 @@ public final class DomainsRefresher {
reservedNotCreated.remove(domainName); reservedNotCreated.remove(domainName);
if (newCreated.remove(domainName)) { if (newCreated.remove(domainName)) {
changes.add( changes.add(
UnblockableDomainChange.ofChanged( UnblockableDomainChange.createChanged(
unblockable.toUnblockableDomain(), Reason.REGISTERED)); unblockable.toUnblockableDomain(), Reason.REGISTERED));
} }
} }
@@ -240,10 +240,10 @@ public final class DomainsRefresher {
Streams.concat( Streams.concat(
newCreated.stream() newCreated.stream()
.map(name -> new UnblockableDomain(name, Reason.REGISTERED)) .map(name -> new UnblockableDomain(name, Reason.REGISTERED))
.map(UnblockableDomainChange::ofNew), .map(UnblockableDomainChange::createNew),
reservedNotCreated.stream() reservedNotCreated.stream()
.map(name -> new UnblockableDomain(name, Reason.RESERVED)) .map(name -> new UnblockableDomain(name, Reason.RESERVED))
.map(UnblockableDomainChange::ofNew)) .map(UnblockableDomainChange::createNew))
.forEach(changes::add); .forEach(changes::add);
return changes.build(); return changes.build();
} }

View File

@@ -21,33 +21,26 @@ import static google.registry.bsa.DownloadStage.MAKE_ORDER_AND_LABEL_DIFF;
import static google.registry.bsa.DownloadStage.NOP; import static google.registry.bsa.DownloadStage.NOP;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.bsa.BlockListType; import google.registry.bsa.BlockListType;
import google.registry.bsa.DownloadStage; import google.registry.bsa.DownloadStage;
import java.util.Optional; import java.util.Optional;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** Information needed when handling a download from BSA. */ /**
@AutoValue * Information needed when handling a download from BSA.
public abstract class DownloadSchedule { *
* @param latestCompleted The most recent job that ended in the {@code DONE} stage.
abstract long jobId(); * @param alwaysDownload Whether the download should be processed even if the checksums show that it
* has not changed from the previous one.
abstract DateTime jobCreationTime(); */
public record DownloadSchedule(
public abstract String jobName(); long jobId,
DateTime jobCreationTime,
public abstract DownloadStage stage(); String jobName,
DownloadStage stage,
/** The most recent job that ended in the {@code DONE} stage. */ Optional<CompletedJob> latestCompleted,
public abstract Optional<CompletedJob> latestCompleted(); boolean alwaysDownload) {
/**
* Returns true if download should be processed even if the checksums show that it has not changed
* from the previous one.
*/
public abstract boolean alwaysDownload();
/** Updates the current job to the new stage. */ /** Updates the current job to the new stage. */
public void updateJobStage(DownloadStage stage) { public void updateJobStage(DownloadStage stage) {
@@ -88,12 +81,12 @@ public abstract class DownloadSchedule {
bsaDownload.setStage(stage); bsaDownload.setStage(stage);
bsaDownload.setChecksums(checksums); bsaDownload.setChecksums(checksums);
tm().put(bsaDownload); tm().put(bsaDownload);
return of(bsaDownload); return create(bsaDownload);
}); });
} }
static DownloadSchedule of(BsaDownload currentJob) { static DownloadSchedule create(BsaDownload currentJob) {
return new AutoValue_DownloadSchedule( return new DownloadSchedule(
currentJob.getJobId(), currentJob.getJobId(),
currentJob.getCreationTime(), currentJob.getCreationTime(),
currentJob.getJobName(), currentJob.getJobName(),
@@ -102,9 +95,9 @@ public abstract class DownloadSchedule {
/* alwaysDownload= */ true); /* alwaysDownload= */ true);
} }
static DownloadSchedule of( static DownloadSchedule create(
BsaDownload currentJob, CompletedJob latestCompleted, boolean alwaysDownload) { BsaDownload currentJob, CompletedJob latestCompleted, boolean alwaysDownload) {
return new AutoValue_DownloadSchedule( return new DownloadSchedule(
currentJob.getJobId(), currentJob.getJobId(),
currentJob.getCreationTime(), currentJob.getCreationTime(),
currentJob.getJobName(), currentJob.getJobName(),
@@ -114,15 +107,10 @@ public abstract class DownloadSchedule {
} }
/** Information about a completed BSA download job. */ /** Information about a completed BSA download job. */
@AutoValue public record CompletedJob(String jobName, ImmutableMap<BlockListType, String> checksums) {
public abstract static class CompletedJob {
public abstract String jobName();
public abstract ImmutableMap<BlockListType, String> checksums(); public static CompletedJob create(BsaDownload completedJob) {
return new CompletedJob(completedJob.getJobName(), completedJob.getChecksums());
static CompletedJob of(BsaDownload completedJob) {
return new AutoValue_DownloadSchedule_CompletedJob(
completedJob.getJobName(), completedJob.getChecksums());
} }
} }
} }

View File

@@ -100,15 +100,15 @@ public final class DownloadScheduler {
: Optional.empty(); : Optional.empty();
} else if (recentDownloads.size() == 1) { } else if (recentDownloads.size() == 1) {
// First job ever, still in progress // First job ever, still in progress
return Optional.of(DownloadSchedule.of(recentDownloads.get(0))); return Optional.of(DownloadSchedule.create(recentDownloads.get(0)));
} else { } else {
// Job in progress, with completed previous jobs. // Job in progress, with completed previous jobs.
BsaDownload prev = recentDownloads.get(1); BsaDownload prev = recentDownloads.get(1);
verify(prev.getStage().equals(DONE), "Unexpectedly found two ongoing jobs."); verify(prev.getStage().equals(DONE), "Unexpectedly found two ongoing jobs.");
return Optional.of( return Optional.of(
DownloadSchedule.of( DownloadSchedule.create(
mostRecent, mostRecent,
CompletedJob.of(prev), CompletedJob.create(prev),
isTimeAgain(mostRecent, maxNopInterval))); isTimeAgain(mostRecent, maxNopInterval)));
} }
}); });
@@ -127,8 +127,9 @@ public final class DownloadScheduler {
return prevJob return prevJob
.map( .map(
prev -> prev ->
DownloadSchedule.of(job, CompletedJob.of(prev), isTimeAgain(prev, maxNopInterval))) DownloadSchedule.create(
.orElseGet(() -> DownloadSchedule.of(job)); job, CompletedJob.create(prev), isTimeAgain(prev, maxNopInterval)))
.orElseGet(() -> DownloadSchedule.create(job));
} }
/** /**

View File

@@ -17,25 +17,21 @@ package google.registry.bsa.persistence;
import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verify;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import com.google.auto.value.AutoValue;
import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.CanIgnoreReturnValue;
import google.registry.bsa.RefreshStage; import google.registry.bsa.RefreshStage;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** Information needed when handling a domain refresh. */ /**
@AutoValue * Information needed when handling a domain refresh.
public abstract class RefreshSchedule { *
* @param prevRefreshTime The most recent job that ended in the {@code DONE} stage.
abstract long jobId(); */
public record RefreshSchedule(
abstract DateTime jobCreationTime(); long jobId,
DateTime jobCreationTime,
public abstract String jobName(); String jobName,
RefreshStage stage,
public abstract RefreshStage stage(); DateTime prevRefreshTime) {
/** The most recent job that ended in the {@code DONE} stage. */
public abstract DateTime prevRefreshTime();
/** Updates the current job to the new stage. */ /** Updates the current job to the new stage. */
@CanIgnoreReturnValue @CanIgnoreReturnValue
@@ -50,12 +46,12 @@ public abstract class RefreshSchedule {
stage); stage);
bsaRefresh.setStage(stage); bsaRefresh.setStage(stage);
tm().put(bsaRefresh); tm().put(bsaRefresh);
return of(bsaRefresh, prevRefreshTime()); return create(bsaRefresh, prevRefreshTime());
}); });
} }
static RefreshSchedule of(BsaDomainRefresh job, DateTime prevJobCreationTime) { static RefreshSchedule create(BsaDomainRefresh job, DateTime prevJobCreationTime) {
return new AutoValue_RefreshSchedule( return new RefreshSchedule(
job.getJobId(), job.getJobId(),
job.getCreationTime(), job.getCreationTime(),
job.getJobName(), job.getJobName(),

View File

@@ -68,11 +68,11 @@ public class RefreshScheduler {
RefreshSchedule scheduleNewJob(DateTime prevRefreshTime) { RefreshSchedule scheduleNewJob(DateTime prevRefreshTime) {
BsaDomainRefresh newJob = new BsaDomainRefresh(); BsaDomainRefresh newJob = new BsaDomainRefresh();
tm().insert(newJob); tm().insert(newJob);
return RefreshSchedule.of(newJob, prevRefreshTime); return RefreshSchedule.create(newJob, prevRefreshTime);
} }
RefreshSchedule rescheduleOngoingJob(BsaDomainRefresh ongoingJob, DateTime prevJobStartTime) { RefreshSchedule rescheduleOngoingJob(BsaDomainRefresh ongoingJob, DateTime prevJobStartTime) {
return RefreshSchedule.of(ongoingJob, prevJobStartTime); return RefreshSchedule.create(ongoingJob, prevJobStartTime);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -57,7 +57,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.leapSafeAddYears; import static google.registry.util.DateTimeUtils.leapSafeAddYears;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
@@ -698,18 +697,13 @@ public final class DomainCreateFlow implements MutatingFlow {
} }
} }
/** A class to store renewal info used in {@link BillingRecurrence} billing events. */ /** A record to store renewal info used in {@link BillingRecurrence} billing events. */
@AutoValue public record RenewalPriceInfo(
public abstract static class RenewalPriceInfo { RenewalPriceBehavior renewalPriceBehavior, @Nullable Money renewalPrice) {
static DomainCreateFlow.RenewalPriceInfo create( static RenewalPriceInfo create(
RenewalPriceBehavior renewalPriceBehavior, @Nullable Money renewalPrice) { RenewalPriceBehavior renewalPriceBehavior, @Nullable Money renewalPrice) {
return new AutoValue_DomainCreateFlow_RenewalPriceInfo(renewalPriceBehavior, renewalPrice); return new RenewalPriceInfo(renewalPriceBehavior, renewalPrice);
} }
public abstract RenewalPriceBehavior renewalPriceBehavior();
@Nullable
public abstract Money renewalPrice();
} }
private static ImmutableList<FeeTransformResponseExtension> createResponseExtensions( private static ImmutableList<FeeTransformResponseExtension> createResponseExtensions(

View File

@@ -72,15 +72,15 @@ class BsaDiffCreatorTest {
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly( .containsExactly(
BlockLabel.of("test1", LabelType.CREATE, ImmutableSet.of("JA")), BlockLabel.create("test1", LabelType.CREATE, ImmutableSet.of("JA")),
BlockLabel.of("test2", LabelType.CREATE, ImmutableSet.of("JA")), BlockLabel.create("test2", LabelType.CREATE, ImmutableSet.of("JA")),
BlockLabel.of("test3", LabelType.CREATE, ImmutableSet.of("JA"))); BlockLabel.create("test3", LabelType.CREATE, ImmutableSet.of("JA")));
assertThat(diff.getOrders()) assertThat(diff.getOrders())
.containsExactly( .containsExactly(
BlockOrder.of(1, OrderType.CREATE), BlockOrder.create(1, OrderType.CREATE),
BlockOrder.of(2, OrderType.CREATE), BlockOrder.create(2, OrderType.CREATE),
BlockOrder.of(3, OrderType.CREATE), BlockOrder.create(3, OrderType.CREATE),
BlockOrder.of(4, OrderType.CREATE)); BlockOrder.create(4, OrderType.CREATE));
} }
@Test @Test
@@ -96,16 +96,16 @@ class BsaDiffCreatorTest {
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly( .containsExactly(
BlockLabel.of("test1", LabelType.CREATE, ImmutableSet.of("JA")), BlockLabel.create("test1", LabelType.CREATE, ImmutableSet.of("JA")),
BlockLabel.of("test2", LabelType.CREATE, ImmutableSet.of("JA")), BlockLabel.create("test2", LabelType.CREATE, ImmutableSet.of("JA")),
BlockLabel.of("test3", LabelType.CREATE, ImmutableSet.of("JA"))); BlockLabel.create("test3", LabelType.CREATE, ImmutableSet.of("JA")));
assertThat(diff.getOrders()) assertThat(diff.getOrders())
.containsExactly( .containsExactly(
BlockOrder.of(1, OrderType.CREATE), BlockOrder.create(1, OrderType.CREATE),
BlockOrder.of(2, OrderType.CREATE), BlockOrder.create(2, OrderType.CREATE),
BlockOrder.of(3, OrderType.CREATE), BlockOrder.create(3, OrderType.CREATE),
BlockOrder.of(4, OrderType.CREATE), BlockOrder.create(4, OrderType.CREATE),
BlockOrder.of(5, OrderType.CREATE)); BlockOrder.create(5, OrderType.CREATE));
} }
@Test @Test
@@ -140,15 +140,15 @@ class BsaDiffCreatorTest {
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly( .containsExactly(
BlockLabel.of("test1", LabelType.DELETE, ImmutableSet.of("JA")), BlockLabel.create("test1", LabelType.DELETE, ImmutableSet.of("JA")),
BlockLabel.of("test2", LabelType.DELETE, ImmutableSet.of("JA")), BlockLabel.create("test2", LabelType.DELETE, ImmutableSet.of("JA")),
BlockLabel.of("test3", LabelType.DELETE, ImmutableSet.of("JA"))); BlockLabel.create("test3", LabelType.DELETE, ImmutableSet.of("JA")));
assertThat(diff.getOrders()) assertThat(diff.getOrders())
.containsExactly( .containsExactly(
BlockOrder.of(1, OrderType.DELETE), BlockOrder.create(1, OrderType.DELETE),
BlockOrder.of(2, OrderType.DELETE), BlockOrder.create(2, OrderType.DELETE),
BlockOrder.of(3, OrderType.DELETE), BlockOrder.create(3, OrderType.DELETE),
BlockOrder.of(4, OrderType.DELETE)); BlockOrder.create(4, OrderType.DELETE));
} }
@Test @Test
@@ -167,8 +167,8 @@ class BsaDiffCreatorTest {
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly( .containsExactly(
BlockLabel.of("test1", LabelType.NEW_ORDER_ASSOCIATION, ImmutableSet.of("JA"))); BlockLabel.create("test1", LabelType.NEW_ORDER_ASSOCIATION, ImmutableSet.of("JA")));
assertThat(diff.getOrders()).containsExactly(BlockOrder.of(5, OrderType.CREATE)); assertThat(diff.getOrders()).containsExactly(BlockOrder.create(5, OrderType.CREATE));
} }
@Test @Test
@@ -187,8 +187,8 @@ class BsaDiffCreatorTest {
when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob)); when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob));
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly(BlockLabel.of("test4", LabelType.CREATE, ImmutableSet.of("JA"))); .containsExactly(BlockLabel.create("test4", LabelType.CREATE, ImmutableSet.of("JA")));
assertThat(diff.getOrders()).containsExactly(BlockOrder.of(5, OrderType.CREATE)); assertThat(diff.getOrders()).containsExactly(BlockOrder.create(5, OrderType.CREATE));
} }
@Test @Test
@@ -205,7 +205,7 @@ class BsaDiffCreatorTest {
when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob)); when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob));
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()).isEmpty(); assertThat(diff.getLabels()).isEmpty();
assertThat(diff.getOrders()).containsExactly(BlockOrder.of(4, OrderType.DELETE)); assertThat(diff.getOrders()).containsExactly(BlockOrder.create(4, OrderType.DELETE));
} }
@Test @Test
@@ -222,7 +222,7 @@ class BsaDiffCreatorTest {
when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob)); when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob));
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()).isEmpty(); assertThat(diff.getLabels()).isEmpty();
assertThat(diff.getOrders()).containsExactly(BlockOrder.of(1, OrderType.DELETE)); assertThat(diff.getOrders()).containsExactly(BlockOrder.create(1, OrderType.DELETE));
} }
@Test @Test
@@ -240,8 +240,8 @@ class BsaDiffCreatorTest {
when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob)); when(schedule.latestCompleted()).thenReturn(Optional.of(completedJob));
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly(BlockLabel.of("test2", LabelType.DELETE, ImmutableSet.of("JA"))); .containsExactly(BlockLabel.create("test2", LabelType.DELETE, ImmutableSet.of("JA")));
assertThat(diff.getOrders()).containsExactly(BlockOrder.of(3, OrderType.DELETE)); assertThat(diff.getOrders()).containsExactly(BlockOrder.create(3, OrderType.DELETE));
} }
@Test @Test
@@ -260,13 +260,13 @@ class BsaDiffCreatorTest {
BsaDiff diff = diffCreator.createDiff(schedule, idnChecker); BsaDiff diff = diffCreator.createDiff(schedule, idnChecker);
assertThat(diff.getLabels()) assertThat(diff.getLabels())
.containsExactly( .containsExactly(
BlockLabel.of("test1", LabelType.DELETE, ImmutableSet.of("JA")), BlockLabel.create("test1", LabelType.DELETE, ImmutableSet.of("JA")),
BlockLabel.of("test3", LabelType.DELETE, ImmutableSet.of("JA"))); BlockLabel.create("test3", LabelType.DELETE, ImmutableSet.of("JA")));
assertThat(diff.getOrders()) assertThat(diff.getOrders())
.containsExactly( .containsExactly(
BlockOrder.of(1, OrderType.DELETE), BlockOrder.create(1, OrderType.DELETE),
BlockOrder.of(2, OrderType.DELETE), BlockOrder.create(2, OrderType.DELETE),
BlockOrder.of(4, OrderType.DELETE)); BlockOrder.create(4, OrderType.DELETE));
} }
@Test @Test

View File

@@ -144,7 +144,7 @@ class BsaRefreshFunctionalTest {
UnblockableDomain newUnblockable = new UnblockableDomain("blocked1.app", Reason.RESERVED); UnblockableDomain newUnblockable = new UnblockableDomain("blocked1.app", Reason.RESERVED);
assertThat(queryUnblockableDomains()).containsExactly(newUnblockable); assertThat(queryUnblockableDomains()).containsExactly(newUnblockable);
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly(UnblockableDomainChange.ofNew(newUnblockable)); .containsExactly(UnblockableDomainChange.createNew(newUnblockable));
verify(bsaReportSender, never()).removeUnblockableDomainsUpdates(anyString()); verify(bsaReportSender, never()).removeUnblockableDomainsUpdates(anyString());
verify(bsaReportSender, times(1)) verify(bsaReportSender, times(1))
.addUnblockableDomainsUpdates("{\n \"reserved\": [\n \"blocked1.app\"\n ]\n}"); .addUnblockableDomainsUpdates("{\n \"reserved\": [\n \"blocked1.app\"\n ]\n}");
@@ -161,7 +161,7 @@ class BsaRefreshFunctionalTest {
UnblockableDomain newUnblockable = new UnblockableDomain("blocked1.dev", Reason.REGISTERED); UnblockableDomain newUnblockable = new UnblockableDomain("blocked1.dev", Reason.REGISTERED);
assertThat(queryUnblockableDomains()).containsExactly(newUnblockable); assertThat(queryUnblockableDomains()).containsExactly(newUnblockable);
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly(UnblockableDomainChange.ofNew(newUnblockable)); .containsExactly(UnblockableDomainChange.createNew(newUnblockable));
verify(bsaReportSender, never()).removeUnblockableDomainsUpdates(anyString()); verify(bsaReportSender, never()).removeUnblockableDomainsUpdates(anyString());
verify(bsaReportSender, times(1)) verify(bsaReportSender, times(1))
@@ -184,7 +184,7 @@ class BsaRefreshFunctionalTest {
assertThat(queryUnblockableDomains()).isEmpty(); assertThat(queryUnblockableDomains()).isEmpty();
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly( .containsExactly(
UnblockableDomainChange.ofDeleted( UnblockableDomainChange.createDeleted(
new UnblockableDomain("blocked1.dev", Reason.REGISTERED))); new UnblockableDomain("blocked1.dev", Reason.REGISTERED)));
verify(bsaReportSender, never()).addUnblockableDomainsUpdates(anyString()); verify(bsaReportSender, never()).addUnblockableDomainsUpdates(anyString());
@@ -207,7 +207,7 @@ class BsaRefreshFunctionalTest {
assertThat(queryUnblockableDomains()).isEmpty(); assertThat(queryUnblockableDomains()).isEmpty();
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly( .containsExactly(
UnblockableDomainChange.ofDeleted( UnblockableDomainChange.createDeleted(
new UnblockableDomain("blocked1.app", Reason.RESERVED))); new UnblockableDomain("blocked1.app", Reason.RESERVED)));
verify(bsaReportSender, never()).addUnblockableDomainsUpdates(anyString()); verify(bsaReportSender, never()).addUnblockableDomainsUpdates(anyString());
@@ -233,7 +233,7 @@ class BsaRefreshFunctionalTest {
.containsExactly(new UnblockableDomain("blocked1.app", Reason.RESERVED)); .containsExactly(new UnblockableDomain("blocked1.app", Reason.RESERVED));
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly( .containsExactly(
UnblockableDomainChange.ofChanged( UnblockableDomainChange.createChanged(
new UnblockableDomain("blocked1.app", Reason.REGISTERED), Reason.RESERVED)); new UnblockableDomain("blocked1.app", Reason.REGISTERED), Reason.RESERVED));
InOrder inOrder = Mockito.inOrder(bsaReportSender); InOrder inOrder = Mockito.inOrder(bsaReportSender);
inOrder.verify(bsaReportSender).removeUnblockableDomainsUpdates("[\n \"blocked1.app\"\n]"); inOrder.verify(bsaReportSender).removeUnblockableDomainsUpdates("[\n \"blocked1.app\"\n]");
@@ -260,7 +260,7 @@ class BsaRefreshFunctionalTest {
assertThat(queryUnblockableDomains()).containsExactly(changed); assertThat(queryUnblockableDomains()).containsExactly(changed);
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly( .containsExactly(
UnblockableDomainChange.ofChanged( UnblockableDomainChange.createChanged(
new UnblockableDomain("blocked1.app", Reason.RESERVED), Reason.REGISTERED)); new UnblockableDomain("blocked1.app", Reason.RESERVED), Reason.REGISTERED));
InOrder inOrder = Mockito.inOrder(bsaReportSender); InOrder inOrder = Mockito.inOrder(bsaReportSender);
inOrder.verify(bsaReportSender).removeUnblockableDomainsUpdates("[\n \"blocked1.app\"\n]"); inOrder.verify(bsaReportSender).removeUnblockableDomainsUpdates("[\n \"blocked1.app\"\n]");
@@ -279,7 +279,7 @@ class BsaRefreshFunctionalTest {
UnblockableDomain newUnblockable = new UnblockableDomain("blocked1.app", Reason.REGISTERED); UnblockableDomain newUnblockable = new UnblockableDomain("blocked1.app", Reason.REGISTERED);
assertThat(queryUnblockableDomains()).containsExactly(newUnblockable); assertThat(queryUnblockableDomains()).containsExactly(newUnblockable);
assertThat(gcsClient.readRefreshChanges(jobName)) assertThat(gcsClient.readRefreshChanges(jobName))
.containsExactly(UnblockableDomainChange.ofNew(newUnblockable)); .containsExactly(UnblockableDomainChange.createNew(newUnblockable));
} }
@Test @Test

View File

@@ -79,7 +79,8 @@ class GcsClientTest {
@Test @Test
void readWriteOrderDiffs_success() throws Exception { void readWriteOrderDiffs_success() throws Exception {
ImmutableList<BlockOrder> orders = ImmutableList<BlockOrder> orders =
ImmutableList.of(BlockOrder.of(1, OrderType.CREATE), BlockOrder.of(2, OrderType.DELETE)); ImmutableList.of(
BlockOrder.create(1, OrderType.CREATE), BlockOrder.create(2, OrderType.DELETE));
gcsClient.writeOrderDiffs("job", orders.stream()); gcsClient.writeOrderDiffs("job", orders.stream());
assertThat(gcsClient.readOrderDiffs("job")).containsExactlyElementsIn(orders); assertThat(gcsClient.readOrderDiffs("job")).containsExactlyElementsIn(orders);
} }
@@ -88,9 +89,9 @@ class GcsClientTest {
void readWriteLabelDiffs_success() throws Exception { void readWriteLabelDiffs_success() throws Exception {
ImmutableList<BlockLabel> labels = ImmutableList<BlockLabel> labels =
ImmutableList.of( ImmutableList.of(
BlockLabel.of("1", LabelType.CREATE.CREATE, ImmutableSet.of()), BlockLabel.create("1", LabelType.CREATE.CREATE, ImmutableSet.of()),
BlockLabel.of("2", LabelType.NEW_ORDER_ASSOCIATION, ImmutableSet.of("JA")), BlockLabel.create("2", LabelType.NEW_ORDER_ASSOCIATION, ImmutableSet.of("JA")),
BlockLabel.of("3", LabelType.DELETE, ImmutableSet.of("JA", "EXTENDED_LATIN"))); BlockLabel.create("3", LabelType.DELETE, ImmutableSet.of("JA", "EXTENDED_LATIN")));
gcsClient.writeLabelDiffs("job", labels.stream()); gcsClient.writeLabelDiffs("job", labels.stream());
assertThat(gcsClient.readLabelDiffs("job")).containsExactlyElementsIn(labels); assertThat(gcsClient.readLabelDiffs("job")).containsExactlyElementsIn(labels);
} }

View File

@@ -28,7 +28,7 @@ class BlockLabelTest {
@BeforeEach @BeforeEach
void setup() { void setup() {
label = BlockLabel.of("buy", LabelType.CREATE, ImmutableSet.of("JA", "EXTENDED_LATIN")); label = BlockLabel.create("buy", LabelType.CREATE, ImmutableSet.of("JA", "EXTENDED_LATIN"));
} }
@Test @Test
@@ -43,7 +43,7 @@ class BlockLabelTest {
@Test @Test
void emptyIdns() { void emptyIdns() {
label = BlockLabel.of("buy", LabelType.CREATE, ImmutableSet.of()); label = BlockLabel.create("buy", LabelType.CREATE, ImmutableSet.of());
assertThat(label.serialize()).isEqualTo("buy,CREATE"); assertThat(label.serialize()).isEqualTo("buy,CREATE");
assertThat(BlockLabel.deserialize("buy,CREATE")).isEqualTo(label); assertThat(BlockLabel.deserialize("buy,CREATE")).isEqualTo(label);
} }

View File

@@ -27,7 +27,7 @@ class BlockOrderTest {
@BeforeEach @BeforeEach
void setup() { void setup() {
order = BlockOrder.of(123, OrderType.CREATE); order = BlockOrder.create(123, OrderType.CREATE);
} }
@Test @Test

View File

@@ -44,7 +44,7 @@ class JsonSerializationsTest {
" \"status\": \"ActivationInProgress\"", " \"status\": \"ActivationInProgress\"",
" }", " }",
"]")); "]"));
assertThat(toInProgressOrdersReport(Stream.of(BlockOrder.of(1, OrderType.CREATE)))) assertThat(toInProgressOrdersReport(Stream.of(BlockOrder.create(1, OrderType.CREATE))))
.hasValue(expected); .hasValue(expected);
} }
@@ -66,7 +66,9 @@ class JsonSerializationsTest {
"]")); "]"));
assertThat( assertThat(
toInProgressOrdersReport( toInProgressOrdersReport(
Stream.of(BlockOrder.of(1, OrderType.CREATE), BlockOrder.of(2, OrderType.DELETE)))) Stream.of(
BlockOrder.create(1, OrderType.CREATE),
BlockOrder.create(2, OrderType.DELETE))))
.hasValue(expected); .hasValue(expected);
} }
@@ -82,7 +84,7 @@ class JsonSerializationsTest {
" \"status\": \"Active\"", " \"status\": \"Active\"",
" }", " }",
"]")); "]"));
assertThat(toCompletedOrdersReport(Stream.of(BlockOrder.of(1, OrderType.CREATE)))) assertThat(toCompletedOrdersReport(Stream.of(BlockOrder.create(1, OrderType.CREATE))))
.hasValue(expected); .hasValue(expected);
} }
@@ -104,7 +106,9 @@ class JsonSerializationsTest {
"]")); "]"));
assertThat( assertThat(
toCompletedOrdersReport( toCompletedOrdersReport(
Stream.of(BlockOrder.of(1, OrderType.CREATE), BlockOrder.of(2, OrderType.DELETE)))) Stream.of(
BlockOrder.create(1, OrderType.CREATE),
BlockOrder.create(2, OrderType.DELETE))))
.hasValue(expected); .hasValue(expected);
} }

View File

@@ -68,7 +68,7 @@ public class DomainsRefresherTest {
tm().transact(() -> tm().insert(BsaUnblockableDomain.of("label.tld", Reason.REGISTERED))); tm().transact(() -> tm().insert(BsaUnblockableDomain.of("label.tld", Reason.REGISTERED)));
assertThat(refresher.refreshStaleUnblockables()) assertThat(refresher.refreshStaleUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofDeleted( UnblockableDomainChange.createDeleted(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.REGISTERED))); new UnblockableDomain("label.tld", UnblockableDomain.Reason.REGISTERED)));
} }
@@ -78,7 +78,7 @@ public class DomainsRefresherTest {
tm().transact(() -> tm().insert(BsaUnblockableDomain.of("label.tld", Reason.RESERVED))); tm().transact(() -> tm().insert(BsaUnblockableDomain.of("label.tld", Reason.RESERVED)));
assertThat(refresher.refreshStaleUnblockables()) assertThat(refresher.refreshStaleUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofDeleted( UnblockableDomainChange.createDeleted(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED))); new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED)));
} }
@@ -88,7 +88,7 @@ public class DomainsRefresherTest {
persistBsaLabel("label"); persistBsaLabel("label");
assertThat(refresher.getNewUnblockables()) assertThat(refresher.getNewUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofNew( UnblockableDomainChange.createNew(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.REGISTERED))); new UnblockableDomain("label.tld", UnblockableDomain.Reason.REGISTERED)));
} }
@@ -99,7 +99,7 @@ public class DomainsRefresherTest {
addReservedListsToTld("tld", ImmutableList.of("reservedList")); addReservedListsToTld("tld", ImmutableList.of("reservedList"));
assertThat(refresher.getNewUnblockables()) assertThat(refresher.getNewUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofNew( UnblockableDomainChange.createNew(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED))); new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED)));
} }
@@ -112,7 +112,7 @@ public class DomainsRefresherTest {
assertThat(refresher.refreshStaleUnblockables()) assertThat(refresher.refreshStaleUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofChanged( UnblockableDomainChange.createChanged(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.REGISTERED), new UnblockableDomain("label.tld", UnblockableDomain.Reason.REGISTERED),
UnblockableDomain.Reason.RESERVED)); UnblockableDomain.Reason.RESERVED));
} }
@@ -125,7 +125,7 @@ public class DomainsRefresherTest {
persistResource(newDomain("label.tld")); persistResource(newDomain("label.tld"));
assertThat(refresher.refreshStaleUnblockables()) assertThat(refresher.refreshStaleUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofChanged( UnblockableDomainChange.createChanged(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED), new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED),
UnblockableDomain.Reason.REGISTERED)); UnblockableDomain.Reason.REGISTERED));
} }
@@ -140,7 +140,7 @@ public class DomainsRefresherTest {
persistResource(newDomain("label.tld")); persistResource(newDomain("label.tld"));
assertThat(refresher.refreshStaleUnblockables()) assertThat(refresher.refreshStaleUnblockables())
.containsExactly( .containsExactly(
UnblockableDomainChange.ofChanged( UnblockableDomainChange.createChanged(
new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED), new UnblockableDomain("label.tld", UnblockableDomain.Reason.RESERVED),
UnblockableDomain.Reason.REGISTERED)); UnblockableDomain.Reason.REGISTERED));
} }

View File

@@ -94,7 +94,7 @@ class LabelDiffUpdatesTest {
ImmutableList<UnblockableDomain> unblockableDomains = ImmutableList<UnblockableDomain> unblockableDomains =
applyLabelDiff( applyLabelDiff(
ImmutableList.of(BlockLabel.of("label", LabelType.DELETE, ImmutableSet.of())), ImmutableList.of(BlockLabel.create("label", LabelType.DELETE, ImmutableSet.of())),
idnChecker, idnChecker,
schedule, schedule,
fakeClock.nowUtc()); fakeClock.nowUtc());
@@ -119,7 +119,7 @@ class LabelDiffUpdatesTest {
ImmutableList<UnblockableDomain> unblockableDomains = ImmutableList<UnblockableDomain> unblockableDomains =
applyLabelDiff( applyLabelDiff(
ImmutableList.of( ImmutableList.of(
BlockLabel.of("label", LabelType.NEW_ORDER_ASSOCIATION, ImmutableSet.of())), BlockLabel.create("label", LabelType.NEW_ORDER_ASSOCIATION, ImmutableSet.of())),
idnChecker, idnChecker,
schedule, schedule,
fakeClock.nowUtc()); fakeClock.nowUtc());
@@ -146,7 +146,7 @@ class LabelDiffUpdatesTest {
ImmutableList<UnblockableDomain> unblockableDomains = ImmutableList<UnblockableDomain> unblockableDomains =
applyLabelDiff( applyLabelDiff(
ImmutableList.of(BlockLabel.of("label", LabelType.CREATE, ImmutableSet.of())), ImmutableList.of(BlockLabel.create("label", LabelType.CREATE, ImmutableSet.of())),
idnChecker, idnChecker,
schedule, schedule,
fakeClock.nowUtc()); fakeClock.nowUtc());